webpack: throwing an error if I disable source map in uglifyjs plugin
I think this is a more appropriate location to file this issue: https://github.com/webpack/extract-text-webpack-plugin/issues/98
I disabled extract text plugin and it still gives an error. Its probably in webpack.
So just re posting this:
I get an error if I turn off source map in
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
, sourceMap: false
})
I’m trying to disable source map since my build takes 5 minutes long. Removing it yields 1 minute 40 seconds.
Here’s part of my stack trace
ERROR in bundle.js from UglifyJs
TypeError: Cannot read property 'sections' of null
at new SourceMapConsumer (/var/www/project/node_modules/webpack/node_modules/webpack-core/node_modules/source-map/lib/source-map/source-map-consumer.js:24:21)
at /var/www/project/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:62:23
at Array.forEach (native)
at Tapable.<anonymous> (/var/www/project/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:44:10)
at Tapable.next (/var/www/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:69:14)
at Tapable.<anonymous> (/var/www/project/node_modules/webpack/lib/optimize/UglifyJsPlugin.js:136:4)
at Tapable.applyPluginsAsync (/var/www/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13)
at Tapable.<anonymous> (/var/www/project/node_modules/webpack/lib/Compilation.js:564:9)
at Tapable.next (/var/www/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11)
at ExtractTextPlugin.<anonymous> (/var/www/project/node_modules/extract-text-webpack-plugin/index.js:303:4)
at Tapable.applyPluginsAsync (/var/www/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:71:13)
at Tapable.<anonymous> (/var/www/project/node_modules/webpack/lib/Compilation.js:560:8)
at Tapable.next (/var/www/project/node_modules/webpack/node_modules/tapable/lib/Tapable.js:67:11)
at ExtractTextPlugin.<anonymous> (/var/www/project/node_modules/extract-text-webpack-plugin/index.js:279:5)
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:52:16
at done (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:248:21)
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:44:16
at /var/www/project/node_modules/extract-text-webpack-plugin/index.js:270:6
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:52:16
at done (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:248:21)
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:44:16
at /var/www/project/node_modules/extract-text-webpack-plugin/index.js:267:13
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:187:20
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:239:13
at _arrayEach (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:91:13)
at _each (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:82:13)
at Object.async.forEachOf.async.eachOf (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:238:9)
at Object.async.forEach.async.each (/var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:215:22)
at /var/www/project/node_modules/extract-text-webpack-plugin/index.js:241:11
at /var/www/project/node_modules/extract-text-webpack-plugin/node_modules/async/lib/async.js:187:20
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 26
- Comments: 35 (4 by maintainers)
Commits related to this issue
- Possibel fix for the production build. Uglify throws an error for devtool set as source-map. Based on https://github.com/webpack/webpack/issues/1385 changed to eval. After adding a constructor to app.... — committed to nimishamukherjee/fabric8-planner by deleted user 8 years ago
- New changes for 'hosting' branch — committed to uidotdev/react-course by tylermcginnis 7 years ago
- https://github.com/webpack/webpack/issues/1385 — committed to muehan/angular-starter by muehan 7 years ago
- fix(webpack.prod): https://github.com/webpack/webpack/issues/1385 when using new UglifyJsPlugin and --opimize-minimize (or -p) you are adding the UglifyJsPlugin twice. Omit the CLI option. — committed to Beace/expressjs-react-blog by Beace 7 years ago
- Fix webpack build scripts Adds a `build-vendor:dev` script for local development. This fixes the issue where building the vendor scripts in production mode but running the server in development mode ... — committed to ystros/throneteki by ystros 7 years ago
- Fix webpack build scripts (#1621) * Fix webpack build scripts Adds a `build-vendor:dev` script for local development. This fixes the issue where building the vendor scripts in production mode but... — committed to throneteki/throneteki by ystros 7 years ago
when using
new UglifyJsPlugin
and--opimize-minimize
(or-p
) you are adding the UglifyJsPlugin twice. Omit the CLI option.try to reinstall all dependencies.
@sokra just tried reinstalling dependencies. Still getting the same error on build:
With Webpack 4,
mode: 'production'
will automatically add optimizations plugins.If you get the following warning/error message when building with
mode: 'production'
, try fixing by below instruction.+1 fix by remove
-p
Is there a fix coming for this? In my opinion Webpack should be smart enough to omit one or the other f both are present.
+1 fix by remove -p
Have similar issue, but i don’t specify
sourceMap: false
. Only when i declare this, build pass.Thanks so much @sokra, This helped me!
@damianobarbati, you might pass it as
minimizer
option rather than push it as plugin part.@sokra removing
-p
does indeed fixes it for me. Is this intended behavior though? if a flag in cli does the same thing in config, it will just apply it twice?I’ll gladly make a PR if you can just give me pointers where to look. Let me know if we don’t plan to fix this, and I’ll have this close.
I am getting the same error here when using sourcemap false and --optimize-minimize (if I leave the optimize out it works).
do not remove UglifyJsPlugin, just add
sourceMap: true
to its config@sokra I’ve setup a sample repo to reproduce the bug: https://github.com/deezahyn/webpack-production-test
Another way I was able to get rid of this issue was by removing
devtool: 'source-map'
from webpack config.What’s your
devtool
?when using yarn, you could add this to your package.json file:
this will replace webpack original dependency with a more recent one, so you could still use -p switch.
Thanks @sokra it also fixed it for me as well
Thanks @sokra, you fixed this bug for me too 😃
Thanks @sokra it also fixed it for me
same error