https://github.com/sindresorhus/got/blob/8b040afc0749523fcaaf6db81702c27e74f7a1d2/index.js#L27
Could it be possible to replace const pkg = require('./package'); with const pkg = require('./package.json'); ? It would remove ambiguity and avoid fiddling with webpack conf just to fix this issue.
Thank you
Duplicate of https://github.com/sindresorhus/got/issues/266 and https://github.com/sindresorhus/got/pull/349
This is a problem with Webpack and its bad compatibility with the Node.js ecosystem. Open an issue on Webpack: https://github.com/webpack/webpack/issues
I understand that @sindresorhus . However it won't break your code to use *.json and it's not a huge refactoring. Dropping the filetype in require is usually for js files, not json
I understand that and I'm sorry for the trouble, but I don't want to set a precedence that Webpack can do whatever they want and force the Node.js ecosystem to change. Webpack is the one that is interacting badly and should be fixed, not every Node.js module using a supported feature.
See: https://nodejs.org/api/modules.html#modules_file_modules
Please do open an issue on Webpack and let them know they're causing pain for both Webpack users and Node.js module maintainers.
I understand your position @sindresorhus , I do. And the extensions fix in webpack worked for me.
However I don't think it is about setting a precedence and giving up to webpack. Ultimately it comes to making life easier for the users. And it is true that nowadays, lots of user are using webpack. You chose to open-source your code and that's wonderful because your tool is damn fine. But open sourcing is also about listening to the community. And as you said, lots of issues has been opened regarding this require.
I don't want to create a debate here, I just want to express my opinion, hoping that you'll consider it.
Thank you anyway for creating got
Most helpful comment
I understand your position @sindresorhus , I do. And the
extensionsfix in webpack worked for me.However I don't think it is about setting a precedence and giving up to webpack. Ultimately it comes to making life easier for the users. And it is true that nowadays, lots of user are using webpack. You chose to open-source your code and that's wonderful because your tool is damn fine. But open sourcing is also about listening to the community. And as you said, lots of issues has been opened regarding this
require.I don't want to create a debate here, I just want to express my opinion, hoping that you'll consider it.
Thank you anyway for creating got