catamphetamine / webpack-isomorphic-tools

Server-side rendering for your Webpack-built applications (e.g. React)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR in (webpack)-isomorphic-tools/package.json

peter-mouland opened this issue · comments

Hi,

I'm not sure what's changed, possibly not even webpack-isomorphic tools, but for some reason i've started getting this error:

ERROR in (webpack)-isomorphic-tools/package.json

It is puzzling, because i've not changed my code and it was working for me perfectly previously.

have you seen it before?

I have this app where the problem can be reproduced:
https://github.com/peter-mouland/react-lego/tree/express--svg

The full error is:
screen shot 2016-10-22 at 14 56 58

That's weird.
Why is it writing webpack in parentheses.
Seems that you're require()ing webpack-isomorphic-tools/package.json (or even *.json) somewhere in your code and you haven't set up a webpack loader for json extension.
Try adding JSON loader in your webpack configuration.

And when you do add JSON loader in Webpack configuration, don't exclude node_modules/webpack-isomorphic-tools from it (include/exclude).
This might work, but still this package.json should not be required I guess.

yeah, it is weird because i'm not requiring that file.

Adding the json loader was the first thing i tried. I reverted the change, because it shouldn't be needed by my code and also because i then got the following error:

screen shot 2016-10-22 at 17 32 46

if it makes it easier - this is the code added to get webpack-isomorphic-tools to work previously (which now no longer works) peter-mouland/react-lego@express...express--svg

I think the package.json error arises when webpack-isomorphic-tools are require()d.

const IsomorphicTools = require('webpack-isomorphic-tools');

Put console.log before and after this line to find out if that's the case.

the console.log occur in sequence with no errors in between. The error comes later.

If i comment out the following line from within write assets.js the error goes and the app works:

log.debug('running write assets webpack plugin v' + require('../../package.json').version + ' with options', options);

This error only occurs when i compile my server code using npm run build:server from the example repo

Oh, there it is...
Ok, I see, so it runs Webpack, applies webpack-isomorphic-tools/plugin, executes that line of code and then, for some reason, it tries to bundle webpack-isomorphic-tools/plugin into the server bundle.
I don't think node_modules should be included inside the server-side bundle.
In my other project I just declare all node_modules as externals
https://github.com/halt-hammerzeit/universal-webpack/blob/master/source/server%20configuration.js#L65

The other thing is why you even use webpack-isomorphic-tools when you're already using target: node in the server-side build.
webpack-isomorphic-tools shouldn't be needed in this case.

(and you shouldn't bundle webpack-isomorphic-tools/plugin in your server-side bundle at all)

I expect that's the problem then. Thanks for spending the time to walk me through this.