update of `webpack-sources` breaks our bundling in production mode
See original GitHub issueBug report
The issue happens in the Theia repository where Webpack emits a bogus bundle in production mode.
I tracked this issue down to the update to webpack-sources
: https://github.com/webpack/webpack/commit/c3a0145b49e62fbda7fe1372b87b0cef517a6c7f
Any version webpack-sources@3
fails our build, previous versions seem to work fine.
What is the current behavior?
Bogus bundle code being emitted, such as:
ffunction then(...
Note the duplicated f
from function
.
The exact error is:
ERROR in bundle.js from Terser
Unexpected token: name (then) [webpack://../node_modules/es6-promise/dist/lib/es6-promise/-internal.js:129,4][bundle.js:46850,10]
at js_error (theia\node_modules\terser\dist\bundle.min.js:548:11)
at croak (theia\node_modules\terser\dist\bundle.min.js:1272:9)
at token_error (theia\node_modules\terser\dist\bundle.min.js:1280:9)
at unexpected (theia\node_modules\terser\dist\bundle.min.js:1286:9)
at semicolon (theia\node_modules\terser\dist\bundle.min.js:1324:56)
at simple_statement (theia\node_modules\terser\dist\bundle.min.js:1581:73)
at statement (theia\node_modules\terser\dist\bundle.min.js:1394:19)
at _embed_tokens_wrapper (theia\node_modules\terser\dist\bundle.min.js:1337:26)
at block_ (theia\node_modules\terser\dist\bundle.min.js:2170:20)
at _function_body (theia\node_modules\terser\dist\bundle.min.js:2082:21)
If the current behavior is a bug, please provide the steps to reproduce.
Building a Theia application has a few prerequisites.
Unless you know how to skip node-gyp building, you’ll need to have the proper shared libraries installed on Linux.
git clone https://github.com/eclipse-theia/theia.git
cd theia
git checkout 3716c0716f4f7fe30ef5b36faff4f85e833b20be
yarn upgrade
yarn # you can CTRL+C once you see linting output...
cd examples/browser
# <checkpoint>
yarn theia build # this runs webpack in production mode among other things
The above steps should lead to the error.
You can start again from <checkpoint>
and edit webpack.config.js
to add:
config.optimization = {
minimize: false
};
This will allow you to take a look at the generated bundles. The bogus generation should be in lib/bundle.js
line 46850.
What is the expected behavior?
Emitted code to not be bogus, notably the duplicated f
character in the previous examples.
Other relevant information: webpack version: 5.47.0 Node.js version: 12.22.3 Operating System: Windows 10 Additional tools: n/a
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:14 (8 by maintainers)
Top GitHub Comments
Yep, we are currently in progress of sorting out some bugs in the new implementation.
I think this one should be fixed in webpack-sources@3.0.3, but not sure and there is at least one other bug that we know about, and going to fix hopefully today.
Ok it’s caused by a weird SourceMap of es6-promise. It contains:
0 sized mappings
column 0 is mapped to
[lib/es6-promise/utils.js] 6:0
and[lib/es6-promise/utils.js] 6:7
, which doesn’t really makes sense.non-monotonic ordered mappings
column 1 is mapped before column 0.
I’ll now ignore all mappings that don’t have an increasing column index. Basically dropping invalid mappings.
But that should probably fixed in the source map generation, since some of these mappings are really weird. e. g. mapping to
asap.js
instead ofthen.js
. @stefanpenner