So I've discovered a bug where webpack isn't liking a require'd json file from a dependent npm package. This is in dev-mode and the error is this:
ERROR in ./~/entities/maps/legacy.json
Module parse failed: /home/mike/dev/crater/node_modules/entities/maps/legacy.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
at Parser.pp$4.raise (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/home/mike/dev/crater/node_modules/webpack/node_modules/acorn/dist/acorn.js:3098:39)
@ ./~/entities/lib/decode.js 2:16-46
To reproduce this I just included the react-markdown package:
npm install --save react-markdown
And then included it in the App.js component:
import Markdown from 'react-markdown'
...
<Markdown source="This is a test"/>
If you edit the node_modules/entities/lib/*.js files and add the json! prefix to the require statements: require("json!../maps/entities.json") then webpack compiles properly.
Is this a webpack configuration issue or a problem with the entities npm module?
So I've discovered a bug where webpack isn't liking a require'd json file from a dependent npm package. This is in dev-mode and the error is this:
To reproduce this I just included the react-markdown package:
npm install --save react-markdown
And then included it in the
App.js
component:import Markdown from 'react-markdown'
...<Markdown source="This is a test"/>
If you edit the
node_modules/entities/lib/*.js
files and add thejson!
prefix to the require statements:require("json!../maps/entities.json")
then webpack compiles properly.Is this a webpack configuration issue or a problem with the entities npm module?