Skip to content

uglifyjs output no longer ES5, introduces arrow functions #5967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mirabilos opened this issue Jan 10, 2025 · 0 comments
Open

uglifyjs output no longer ES5, introduces arrow functions #5967

mirabilos opened this issue Jan 10, 2025 · 0 comments

Comments

@mirabilos
Copy link

Uglify version (uglifyjs -V)

3.19.3

JavaScript input

Dygraphs 2.2.1

The uglifyjs CLI command executed or minify() options used.

uglifyjs --compress --mangle --output-opts 'preamble='\''/*! @license https://github.com/danvk/dygraphs/blob/v2.2.1/LICENSE.txt (MIT) */'\' --source-map 'content='\''dygraph.min.tmp.js.map'\'',includeSources=true,url='\''dygraph.min.js.map'\' -o dygraph.min.js dygraph.min.tmp.js

JavaScript output or error produced.

2025-01-10T20:46:43.6114772Z > ./scripts/run-tests.sh min
2025-01-10T20:46:43.6114926Z 
2025-01-10T20:46:44.8011713Z (node:4096) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
2025-01-10T20:46:44.8012354Z (Use `node --trace-deprecation ...` to show where the warning was created)
2025-01-10T20:46:44.8496307Z SyntaxError: Parse error

This is because the tests run in PhantomJS, which is ES5 only (and the output is supposed to be usable in ES5-only browsers as well).

The actual problem is (diffing between a working output from an older uglifyjs version and the newer one):

[…] "dygraphs/src/dygraph-canvas.js":[function(t,e,a){[-"use strict";-]Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var T=[-function-]{+(+}(t,e){+=>+}{if(!e&&t&&t.__esModule)return t; […]

So it’s removing the “use strict” and changing a function to an arrow function. This is a hard bug, a regression and a showstopper.

mirabilos added a commit to danvk/dygraphs that referenced this issue Jan 10, 2025
• --v8 and --webkit for improved browser support,
  we will skip on --ie though I think
• --no-module which is undocumented but may work around
  mishoo/UglifyJS#5967
mgol added a commit to mgol/jquery-ui that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5.

Ref mishoo/UglifyJS#5967
mgol added a commit to mgol/jquery-ui that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5.

Ref mishoo/UglifyJS#5967
Ref jquery/download.jqueryui.com#629
mgol added a commit to mgol/jquery-ui that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5.

Ref mishoo/UglifyJS#5967
Ref jquery/download.jqueryui.com#629
mgol added a commit to mgol/jquery-ui that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5.

Ref mishoo/UglifyJS#5967
Ref jquery/download.jqueryui.com#629
mgol added a commit to mgol/download.jqueryui.com that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5. But the
bigger problem is that we generate ES2015+ minified code even for 1.13.3
releases which support IE.

Closes jquerygh-629
Ref mishoo/UglifyJS#5967
Ref jquery#629
mgol added a commit to mgol/download.jqueryui.com that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5. But the
bigger problem is that we generate ES2015+ minified code even for 1.13.3
releases which support IE.

Closes jquerygh-629
Ref mishoo/UglifyJS#5967
Ref jquery#629
mgol added a commit to mgol/download.jqueryui.com that referenced this issue Mar 2, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5. But the
bigger problem is that we generate ES2015+ minified code even for 1.13.3
releases which support IE.

Closes jquerygh-629
Ref mishoo/UglifyJS#5967
Ref jquery#629
mgol added a commit to jquery/jquery-ui that referenced this issue Mar 3, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in 1.14.x as long as we keep the source file in ES5.

Closes gh-2335
Ref mishoo/UglifyJS#5967
Ref jquery/download.jqueryui.com#629
mgol added a commit to jquery/download.jqueryui.com that referenced this issue Mar 6, 2025
More recent UglifyJS versions have started converting regular functions to arrow
ones, making ES5 source file migrated to a ES2015+ minified one. We want to
avoid that even in `1.14.x` as long as we keep the source file in ES5. But the
bigger problem is that we generate ES2015+ minified code even for `1.13.3`
releases which support IE.

This change switches the minfied to SWC and ensures ES5 output. Tests
ensuring this behavior have been added.

Also, GitHub Actions were updated, as the previous versions stopped working.
To avoid this happening in the future, automatic dependabot PRs updating
actions are now enabled.

Fixes gh-629
Closes gh-630
Ref mishoo/UglifyJS#5967
Ref #629
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant