Open evelant opened 8 years ago
This is a very important question, and one I wish I had looked into sooner. I don't think I'll be able to look into this in the next few days, but I'm pretty sure the unexpected reserved word is import
because "modules": false
prevents babel
from transpiling import
statements that get run on the server side.
So it sounds like we may have to have to keep the current config on the server, but use the config you mentioned in webpack (by adding it as a query
to the "happy"
loader, since it's wrapping babel-loader
).
Do you have a link to somewhere that says you have to use "modules": false
? I'm kind of surprised about that, I thought webpack 2 still supports require
statements even though it also supports import
statements natively.
Actually I started looking into this already. The code on the webpack2 branch now uses {loose: true, modules: false}
in the webpack configs, so theoretically it should work, though I haven't actually verified that it does tree shaking.
Is it possible to use tree shaking with webpack2 in this skeleton?
On the webpack2 branch I changed my .babelrc to the following
Which as I understand it causes babel to no longer process imports because we want webpack to do it. This breaks the start script however. Changing the package.json scripts entry to
Allows the webpack build to start, but running the server fails with
I am not really familiar with how smart-restart works. Is it possible to build with modules: false in babel to have webpack2 do tree shaking? This could massively reduce the bundle size on a lot of applications if it can be made to work.