Skip to content

Support JSON out of the box #3363

Closed
Closed

Description

@jhnns

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.

Activity

  1. bebraw commented on Nov 30, 2016

    @bebraw
    Contributor

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

  2. added this to the 2.1-RC Blocking milestone on Nov 30, 2016
  3. basarat commented on Dec 2, 2016

    @basarat

    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 🌹 ❤️

  4. jhnns commented on Dec 7, 2016

    @jhnns
    ContributorAuthor

    The PR was merged and will soon be shipped :)

  5. gaearon commented on Jul 22, 2017

    @gaearon
    Contributor

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions