Closed prewk closed 8 years ago
If I, instead of using the webpack
built module for my routes.js
(target: node
and libraryTarget: commonjs
), just require my original unbuilt non-minified version with babel-node
instead - it works.
Therefore, the error must have something to do with creating a transpiled webpack bundle of routes.js
and all of its React stuff. Can you think of something that might disappear in the build step?
My webpack build config doesn't have anything fancy, really:
{
entry: [path.join(__dirname, '..', 'src', 'front', 'routes')],
output: {
path: path.join(__dirname, '..', 'build', 'front'),
filename: 'routes.js',
libraryTarget: 'commonjs',
},
target: 'node',
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.NormalModuleReplacementPlugin(/\/iconv-loader$/, 'node-noop'),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
minimize: false,
mangle: false,
compressor: {
warnings: false
}
})
],
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel'], include: path.join(__dirname, '..', 'src') },
{ test: /\.json$/, loaders: ['json'] },
],
},
}
Probably it's because externals
is missing in your webpack config. See https://github.com/denvned/isomorphic-relay-router/issues/5#issuecomment-156984817.
Thanks, I tried it out externals: /^[^.]/
, assuming it would exclude all non-relative imports. It spat out a small module whose only purpose, it seems, is to require the unminified version, by absolute path (wtf) instead:
module.exports=function(r){function e(t){if(o[t])return o[t].exports;var n=o[t]={exports:{},id:t,loaded:!1};return r[t].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var o={};return e.m=r,e.c=o,e.p="",e(0)}([function(r,e,o){r.exports=o(1)},function(r,e){r.exports=require("/Users/oskar/src/my-relay-project/src/front/routes")}]);
I guess it's more of a webpack question, but do you know if that exclude rule screws up if you're consistently using import x from '../y'
instead of require
, because that's what I'm doing?
it seems, is to require the unminified version, by absolute path (wtf)
It must be because you use absolute path for entry
. Try the following instead:
context: path.join(__dirname, '..', 'src'),
entry: './front/routes',
Good eye, thank you very much!
Hi, I saw issue #10 but since I'm not using decorators I didn't want to lead anyone astray.
I've started with the basic
relay-starter-kit
and worked my way from there.isomorphic-relay
works fine with rehydration etc, until... I do a webpack build (Bothwebpack -p
andwebpack -d
causes this problem).My dev environment consists of running the server with
babel-node
and WDS as watch, whereas my production build transpiles the server files with babel and theroutes
file (The React application entry fromisomorphic-relay
s perspective) as a CommonJS module.It perhaps sounds more complex than it is, I can open the transpiled server files and just
console.log
the importedroutes
module and get the same results as in the dev environment so I don't see why there should be a difference.Anyway, when I run the built server and visit a route which in the dev env will server-render without any problems, the application crashes with this stack trace:
I perform the render from the server through this module:
I know it's a lot to swallow, but do you have any pointers on where to look? Thanks!