Drop double minify via Uglifier in Middleman build#925
Merged
Conversation
Webpack production mode already minifies bundles with Terser. The extra Middleman-side minify_javascript pass fed the webpack output back into uglifier (4.2.1), which cannot parse the modern JS syntax (optional chaining etc.) that webpack 5.108.x emits in its runtime. That triggered "Unexpected token: punc (.)" on build/bundle-critical-*.js and failed the CircleCI build for #920 (webpack 5.107.2 -> 5.108.3). Uglifier gem itself is unmaintained (last release 2020-03) and the underlying UglifyJS does not support modern JS, so keeping the pass would only defer the problem. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The webpack bump PR #920 (5.107.2 → 5.108.3) started failing the CircleCI
buildjob withUnexpected token: punc (.)onbuild/bundle-critical-*.js. The stack trace points atuglifier-4.2.1/lib/uglifier.rb:166 #compile, invoked fromactivate :minify_javascript, compressor: -> { Uglifier.new(harmony: true) }inconfig.rb.Root cause is a double minify path, not the bump itself:
uglifiergem, whose bundled UglifyJS only understands ES5-ish syntax.The
uglifiergem has also gone quiet — 4.2.1 shipped on 2024-09-22 after a ~5-year gap from 4.2.0 (2019-09-25), so keeping the pass alive as a Ruby-side minifier is not a good long-term bet either.What
Remove the Middleman-side JS minify pass. The webpack production build (
webpack --config webpack.prod.js,mode: 'production') keeps handling minification for the bundles that actually ship.The
uglifiergem is only a transitive dependency inGemfile.lock, so no Gemfile change is needed. It will drop out on the nextbundle updatenaturally.Verification
npm run buildon this branch produces minified.tmp/dist/bundle-critical.jsand.tmp/dist/bundle-main.js(IIFE, single-char idents, no whitespace) and both passnode --check.Size comparison (bytes):
bundle-critical.jsbundle-main.jsFollow-up