You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
webpack Version: 4.29.6 (bug first appeared in 4.26.0 with the switch to terser)
terser-webpack-plugin Version: 1.2.3
Expected Behavior
Webpack production mode emits valid javascript that can be executed by a browser. E.g.
(function(e){returne})`one`
Actual Behavior
Webpack production mode is emitting invalid javascript. Specifically it's emitting an unnamed function (i.e. function() {...}) that is not syntactically valid. E.g.
functiontpl(str){returnstr;}constunused=tpl`one`;// Uncomment the line below to work around the bug:// const anotherUnused = tpl`two`;
build/repro.min.js (webpack default wrappers removed for clarity)
function(e){returne}`one`
You can see that a single unused tagged template literal is producing an unnamed function error. It can be worked around by referencing the template literal function multiple times but wasn't a bug before terser was introduced as the minification engine for webpack.
Interestingly enough, I was not able to reproduce the bug in terser (v3.16.1), which leads me to believe the bug exists in this plugin.
How Do We Reproduce?
I've created a really small repo which should help you reproduce the issue (instructions assume you're on a mac since it uses the open command to open the index file in a browser):
git clone [email protected]:jondlm/webpack-template-literal-bug.git
cd webpack-template-literal-bug
npm install
npm start
The text was updated successfully, but these errors were encountered:
We just wrapper around terser (https://github.com/terser-js/terser), if you think it is bug please open issue in their repo, we can't do something on our side (we don't modify your code, just send this code to terser and return output), thanks!
Sounds good. I'll try a bit harder to reproduce the issue in terser. I didn't try taking the entire output from webpack and using that as a test case over there. Sorry for the noise!
Expected Behavior
Webpack production mode emits valid javascript that can be executed by a browser. E.g.
Actual Behavior
Webpack production mode is emitting invalid javascript. Specifically it's emitting an unnamed function (i.e.
function() {...}
) that is not syntactically valid. E.g.Code
webpack.config.js
src/index.js
build/repro.min.js (webpack default wrappers removed for clarity)
You can see that a single unused tagged template literal is producing an unnamed function error. It can be worked around by referencing the template literal function multiple times but wasn't a bug before terser was introduced as the minification engine for webpack.
Interestingly enough, I was not able to reproduce the bug in terser (v3.16.1), which leads me to believe the bug exists in this plugin.
How Do We Reproduce?
I've created a really small repo which should help you reproduce the issue (instructions assume you're on a mac since it uses the
open
command to open the index file in a browser):The text was updated successfully, but these errors were encountered: