You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug?
webpack should support requiring JSONs out of the box.
What is the current behavior?
It throws because of a syntax error. This is technically correct, because a JSON is not a JS module.
If this is a feature request, what is motivation or use case for changing the behavior?
We're currently using a lot of browserify modules in node-libs-browser. These browserify modules assume a node-like environment where they can just require JSON files. This resulted in broken builds when the diffie-hellman module added a require() statement. The module was not released as breaking change (of course), so it got shipped without any update of webpack.
Of course, we could document "Oh, you have to use the json-loader for that", but I would like to make webpack easier. Things should work out of the box if possible. And webpack is already doing a lot to shim the node.js environment (like setImmediate, Buffer, process, essentially the whole node-libs-browser module). So that should work too.
Reacted by Andriej Komoda, Kees Kluskens, Evan Jacobs, Florent Cailhol, Victor Malaret, Louis DeScioli, Kacper Golinski, Chris Cinelli, Dan Homola, Basarat Ali Syed and 12 more
Activity
Add support for .json files out of the box
Add section on JSON support to migrating.md
bebraw commentedon Nov 30, 2016
Can we bump this to critical and make sure it gets to the release? Less confusion for everyone.
basarat commentedon Dec 2, 2016
Another reason this would be awesome:
aws-sdkworks with browserify out of the box, but for webpack you need to install json-loader for it to work : https://aws.amazon.com/blogs/developer/using-webpack-and-the-aws-sdk-for-javascript-to-create-and-bundle-an-application-part-1/ glad that it will no longer be the case with webpack 2 🌹 ❤️Add support for .json files out of the box
Add support for .json files out of the box
jhnns commentedon Dec 7, 2016
The PR was merged and will soon be shipped :)
Add support for .json files out of the box
gaearon commentedon Jul 22, 2017
Could this PR cause a false positive warning in
json-loader? Please see webpack-contrib/json-loader#57.