Skip to content
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

require(package) makes webpack fail #363

Closed
carvallegro opened this issue Aug 24, 2017 · 4 comments
Closed

require(package) makes webpack fail #363

carvallegro opened this issue Aug 24, 2017 · 4 comments

Comments

@carvallegro
Copy link

got/index.js

Line 27 in 8b040af

const pkg = require('./package');

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

@sindresorhus
Copy link
Owner

Duplicate of #266 and #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

@carvallegro
Copy link
Author

carvallegro commented Aug 24, 2017

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

@sindresorhus
Copy link
Owner

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.

@carvallegro
Copy link
Author

carvallegro commented Aug 24, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants