Support JSON out of the box #3363

Closed
jhnns opened this Issue Nov 23, 2016 · 4 comments

Comments

Projects
None yet
5 participants
@jhnns
Member

jhnns commented Nov 23, 2016

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.

jhnns added a commit that referenced this issue Nov 24, 2016

@jhnns jhnns referenced this issue Nov 24, 2016

Merged

Add JSON support #3374

jhnns added a commit to webpack/webpack.js.org that referenced this issue Nov 24, 2016

@bebraw

This comment has been minimized.

Show comment
Hide comment
@bebraw

bebraw Nov 30, 2016

Member

Can we bump this to critical and make sure it gets to the release? Less confusion for everyone.

Member

bebraw commented Nov 30, 2016

Can we bump this to critical and make sure it gets to the release? Less confusion for everyone.

@sokra sokra added this to the 2.1-RC Blocking milestone Nov 30, 2016

@basarat

This comment has been minimized.

Show comment
Hide comment
@basarat

basarat Dec 2, 2016

Another reason this would be awesome: aws-sdk works 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 🌹 ❤️

basarat commented Dec 2, 2016

Another reason this would be awesome: aws-sdk works 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 🌹 ❤️

@SamHH SamHH referenced this issue in imperodesign/generator-impero Dec 2, 2016

Closed

Change vue-i18n locale files to JSON #62

sokra added a commit that referenced this issue Dec 7, 2016

jhnns added a commit that referenced this issue Dec 7, 2016

@jhnns

This comment has been minimized.

Show comment
Hide comment
@jhnns

jhnns Dec 7, 2016

Member

The PR was merged and will soon be shipped :)

Member

jhnns commented Dec 7, 2016

The PR was merged and will soon be shipped :)

@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Jul 22, 2017

Contributor

Could this PR cause a false positive warning in json-loader? Please see webpack-contrib/json-loader#57.

Contributor

gaearon commented Jul 22, 2017

Could this PR cause a false positive warning in json-loader? Please see webpack-contrib/json-loader#57.

@agrcrobles agrcrobles referenced this issue in aspnet/JavaScriptServices Aug 17, 2017

Closed

Remove json-loader dependency from React Redux #1203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment