universal-webpack: Error: [universal-webpack] Your server source file must export a function

I try to start the server build server like following:

nodemon -L ./start-server.js --exec babel-node --watch ./build/server

The server.js (built with webpack located in ./build/server/server.js) have a special webpack exported format and start-server.js and universal-webpack/server.js run in a normal node environment and tries to include the buit server.js here

https://github.com/halt-hammerzeit/universal-webpack/blob/master/source/server.js#L41

The result is that the “starter” variable become following:

[ 0, 1 ]

What did I miss?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

The comparison is not correct, it don’t remove any plugins now. It must check if the constructor.

return plugin!== _webpack2.default.HotModuleReplacementPlugin && plugin!== _webpack2.default.optimize.CommonsChunkPlugin;

should be:

return plugin.constructor !== _webpack2.default.HotModuleReplacementPlugin && plugin.constructor !== _webpack2.default.optimize.CommonsChunkPlugin;

Maybe a instanceof check do the job as well.