-
-
Notifications
You must be signed in to change notification settings - Fork 148
Error building with Webpack 2's UglifyJsPlugin #192
Comments
I think there is another open issue for this from @piuccio. Personally I think it's silly to only transpile ES Modules, we should be transpiring es2016 in its entirety since that's the spec :( That said I do want to support this and I'm not wanting anyone to use es2015 in prod just because of me. We should merge that PR I think. |
FYI, temporary workaround in webpack config is to remove the ...
resolve: {
mainFields: ['main', 'web'],
... |
I made it work turning on babel on node_modules/preact |
Aha thats much better! I assume you meant For clarities' sake, an example: {
test: /\.jsx?$/,
loader: 'babel-loader',
include: [
path.resolve(appRootPath, './src'),
path.resolve(appRootPath, './node_modules/preact-compat'),
],
query: {
presets: [
// JSX
'react',
// All the latest JS goodies, except for ES6 modules which
// webpack has native support for.
['latest', { modules: false }],
],
},
}, |
@ctrlplusb going to test this out with Webpack 2 now :) |
Yeah something like that. I actually included all node modules and excluded the ones that don't work. You might have to include proptypes as well, can't remember, sorry |
@developit 100% working. I have the config in my repo with all the latest goodies. :) |
wow! Thanks for this solution @ctrlplusb . I still don't quite understand why it works yet but thanks. |
Another option is using the build version,I try to replace 'alias': {
'react': 'preact-compat/dist/preact-compat',
'react-dom': 'preact-compat/dist/preact-compat'
} |
I came across this as well—solved using the "include" syntax mentioned above. I think it would be worthwhile to document this under Usage with Webpack—I could submit a pull request if it's helpful! |
Readme would be okay, but I'd prefer to not require a workaround. Need to produce an ES Modules bundle and point |
FWIW I showed another solution to this on Twitter - it involves running |
Just realized this is a duplicate of #155, which was closed perhaps a little prematurely. Let's move discussion there :) |
I'm trying to run a
--preact
build while testing nwb's Webpack 2 upgrade and getting the following error:jsnext:main
andmodule
are pointing tosrc/index.js
, which contains some untranspiled ES6 (which UglifyJS can't currently handle) - it's my understanding that the current approach which needs to be used with these package.json configs is to create a build which transpiles everything except ES6 module syntax back to ES5 and point to that.The text was updated successfully, but these errors were encountered: