-
-
Notifications
You must be signed in to change notification settings - Fork 922
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
Add json extension to require package. Fixes webpack v2 beeing unable… #271
Conversation
… to resolve package.
I don't really see how that's something Got should fix. It is Webpack not following the Node.js resolution logic. // @TheLarkInn |
@sindresorhus I think it makes sense to add extensions for non-js files. Anyway it seems like a fairly minor change to help people using Webpack. |
@sindresorhus I agree that this is webpack not following require convention. However you would do me a big favour in merging this. It would be an easy fix for anyone using webpack with your package. It could be weeks until webpack fixes this. It also has no effect on your code. |
@sindresorhus what part of the pattern is off? |
Um so webpack does have extentions for .js and .json by default (in that respective order) |
@cgrossde can you please share your webpack config for me, I have a suspicion that you have |
@TheLarkInn, damn you are right. I was migrating vom webpack v1 to v2 and never thought of adding new extensions, just removed the empty one.
After (webpack v2) - results in the mentioned error:
Solution:
Sry guys, was working on it after a long day at work. Missed the obvious. |
@sindresorhus thanks fur the ping 🐶 |
@cgrossde no prob you can always check webpack.js.org/configuration to see the defaults. In this case the array is an complete override so order is important. |
Ran into this problem with an Angular2 based app, the angularcli, and default assumptions about webpack. The recommended approach was was run ng eject to generate a non default webpack config file. That all worked, but ended up making big changes to my package.json. The changes were big enough that I'm not going to continue with this approach. Bottom line: It sure would be nice if this merge request (changing from package to package.json) was accepted. It would make things a lot simpler. See also #285 |
@TheLarkInn Webpack should resolve I'm not going to change anything in Got as it's Webpack that is not compatible with Node.js and I'm tired of all the churn. People always want the easy solution instead of fixing the actual problem. |
Webpack v2 doesn't allow empty extensions anymore: webpack/webpack#3043
Running webpack v2 on a project with
got
will result in the following error:Adding the
.json
extension torequire('./package')
=>require('./package.json')
fixes the problem.