Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is meant to fix #61
I'm also using request which uses this module:
https://github.com/mikeal/request/blob/master/request.js#L17
Proof current code fails:
Difference between the original patch:
without doing any initialization stuff.
I've added an extra check within the test to see if
fs
has the readFileSync method,a bit lame, but that part is using the load() method and otherwise the test will fail. (
browserify test.js | node
)The build script does the same thing as the one from @dominictarr, I've just created
the extra parse method to avoid the duplication and it might come in handy by itself.
Note: If any code does call mime.load() within the browser it will fail with the original error, on the
server-side it just behaves like normal.
To clarify browserify; there is no harm in
fs
being required, but it will just be an empty object:@see https://github.com/substack/node-browserify/blob/master/lib/builtins.js#L12
Also notice that the types/*.types files can just be considered source files now and could be added to .npmignore
Since quite a lot of packages depend on node-mime it would be nice if it would just compile without having to do any manual overwrites while using browserify.