-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue when bundling with webpack #172
Comments
In looking at this, I realized that my comment on #124 that referred to Please give that a try and see if it fixes your issue. If not, let me know and I'll reopen this. [As an aside, webpack is able to load |
I was only able to fix it by adding the extensions manually inside node_modules. Some details regarding my env:
|
Can provide detailed steps for repro'ing this? |
Adding '.json' to the configuration in webpack also solves the issue. resolve: {
// Look for modules in .js files first
extensions: [".js", ".json"], Still, it's a workaround and I would say it could be avoided if mime package used the extension in the require statements in the first place. It doesn't feel right to adjust a bundler configuration based on a 3rd party package's dependencies (i.e., it's not even something to do with mime directly, but a dependency within. I don't use json files in my project, so adding that to webpack purely because of that doesn't feel right at all). I guess a repository with a standard webpack configuration without the extension '.json' should reproduce the errors mentioned above. |
I'm afraid I have to conclude this is an issue with your project/webpack configuration. When I try a basic "hello world" test of webpack's JSON loading behavior, it works fine:
If I try the same thing when requiring the
Note, too, that JSON-loading behavior of |
So, I'm going to go out on a limb here and offer some unsolicited advice:
I know that may be a bit of hubris on my part. If I'm wrong, and this really is an issue in |
Thanks for taking the time to dig on this and for the advice. I apologize for not referencing a test case right away. I should have done so in the first place. Just recreated the issue in a test project, so you can now take a look at it: https://github.com/Apidcloud/webpack-babel/tree/issueNodeMime The use of mime is done in As aforementioned, it can be solved by specifically resolving Thanks again! |
|
Tried with variants of |
I believe you are in |
Checked out Looks like the problem is that you're supplying a custom definition of Webpack is almost certainly "working as designed" here. Regardless of whether this is a good thing, this is well-documented behavior for CommonJS module loading. Omitting
|
Glad you found the root of the problem. That makes sense despite not being aware of the webpack defaults to .js and .json. Nevertheless, I guess (part of) the point remains the same: on whether this package (and possibly many others using json files) couldn't mitigate such (breaking) behaviour by adding the extension. I understand it's not a problem per se, but the package is still depending on a specific external configuration (even if the default), which could be avoided I would argue. Again, not saying it's this package problem. There are multiple solutions to make it work, so it ends up being just a suggestion. Thanks again! |
Good evening!
While attempting to use your package with webpack, I've noticed an issue in index.js:
Doing specific requires does the trick (note the extension):
Let me know if you want me to do a PR.
Thanks!
The text was updated successfully, but these errors were encountered: