question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

update of `webpack-sources` breaks our bundling in production mode

See original GitHub issue

Bug 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
sokracommented, Jul 29, 2021

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.

1reaction
sokracommented, Jul 30, 2021

Ok it’s caused by a weird SourceMap of es6-promise. It contains:

0 sized mappings

20:0 -> [lib/es6-promise/utils.js] 6:0, :0 -> [lib/es6-promise/utils.js] 6:7, :9 -> [lib/es6-promise/utils.js] 6:16, :19 -> [lib/es6-promise/utils.js] 6:26, :20 -> [lib/es6-promise/utils.js] 6:27, :21 -> [lib/es6-promise/utils.js] 6:28, :23 -> [lib/es6-promise/utils.js] 6:30
function isFunction(x) {
^________^_________^^^_^

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

161:1 -> [lib/es6-promise/asap.js] 123:1, :0 -> [lib/es6-promise/then.js] 5:15, :9 -> [lib/es6-promise/then.js] 5:24, :13 -> [lib/es6-promise/then.js] 5:28, :14 -> [lib/es6-promise/then.js] 5:29, :27 -> [lib/es6-promise/then.js] 5:42, :29 -> [lib/es6-promise/then.js] 5:44, :40 -> [lib/es6-promise/then.js] 5:55, :42 -> [lib/es6-promise/then.js] 5:57
function then(onFulfillment, onRejection) {
.^_______^___^^____________^_^__________^_^

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 of then.js. @stefanpenner

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code Splitting - webpack
This feature allows you to split your code into various bundles which can then be loaded on ... src/index.js', + mode: 'development', +...
Read more >
How I solved and debugged my Webpack issue through trial ...
When webpack bundles your source code, it can become difficult to track down errors and warnings to their original location.
Read more >
Hot loader bundled in production · Issue #602 - GitHub
Description All the assets from react-hot-loader seems to bundle in production builds. I might have misinterpreted it but they should be ...
Read more >
Webpack-dev-server compiles files but does not refresh or ...
I think you have not made your webpack working properly, bundle.js is missing in your browser console. · 6.
Read more >
When using react.js webpack-dev-server does not bundle
Now, you can either update your package.json file to use webpack or run ... either because when you bundle for production, our bundle.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found