json-loader icon indicating copy to clipboard operation
json-loader copied to clipboard

webpack v4 - compatibility

Open deleonio opened this issue 7 years ago • 7 comments

thx

deleonio avatar Feb 26 '18 05:02 deleonio

webpack >= v2.0.0 has 'native'/direct JSON support. Since webpack >= v4.0.0 it's a module.type (no JS wrapper needed anymore). You can remove the json-loader from your setup. Otherwise please provide more info about what 'compatibility' exactly means here :).

⚠️ It's possible the json-loader causes issue with webpack >= v4.0.0, because the loader issues a JS Module (module.type = 'javascript/auto'), which isn't needed anymore/doesn't work with module.type = 'json' (JSONParser) by default

michael-ciniawsky avatar Feb 26 '18 07:02 michael-ciniawsky

This (removing json-loader) fixed an issue I was having with webpack throwing errors about Unexpected token in package.jsons.

zjr avatar Feb 26 '18 19:02 zjr

@zjr I will add a note to the README when I have a few minutes :)

michael-ciniawsky avatar Feb 26 '18 19:02 michael-ciniawsky

Thanks!

zjr avatar Feb 26 '18 19:02 zjr

@michael-ciniawsky removing the loader works. Thank you all.

deleonio avatar Feb 28 '18 01:02 deleonio

Is there a possibility to override the webpack-builtin json-loader? I have my own and it looks like the output of mine is being fed into json-loader (which then errors out, because my loader returns JS code, not JSON code)

retorquere avatar Mar 01 '18 14:03 retorquere

@retorquere https://github.com/webpack/webpack/issues/6572

michael-ciniawsky avatar Mar 01 '18 22:03 michael-ciniawsky