Skip to content

Drop double minify via Uglifier in Middleman build#925

Merged
ikuwow merged 1 commit into
masterfrom
drop-uglifier-double-minify
Jul 3, 2026
Merged

Drop double minify via Uglifier in Middleman build#925
ikuwow merged 1 commit into
masterfrom
drop-uglifier-double-minify

Conversation

@ikuwow

@ikuwow ikuwow commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Why

The webpack bump PR #920 (5.107.2 → 5.108.3) started failing the CircleCI build job with Unexpected token: punc (.) on build/bundle-critical-*.js. The stack trace points at uglifier-4.2.1/lib/uglifier.rb:166 #compile, invoked from activate :minify_javascript, compressor: -> { Uglifier.new(harmony: true) } in config.rb.

Root cause is a double minify path, not the bump itself:

  • Webpack production mode already minifies the emitted bundles with Terser.
  • Middleman then re-minifies the same output through the uglifier gem, whose bundled UglifyJS only understands ES5-ish syntax.
  • Webpack 5.108.x now ships modern JS (e.g. optional chaining) in its runtime code, which UglifyJS cannot parse.

The uglifier gem 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 uglifier gem is only a transitive dependency in Gemfile.lock, so no Gemfile change is needed. It will drop out on the next bundle update naturally.

Verification

  • Local npm run build on this branch produces minified .tmp/dist/bundle-critical.js and .tmp/dist/bundle-main.js (IIFE, single-char idents, no whitespace) and both pass node --check.
  • Compared to the currently deployed live bundles (double-minify): the Terser-only output is smaller uncompressed and gzip-neutral, so removing the Uglifier pass does not regress ship size.

Size comparison (bytes):

bundle live (Terser+Uglifier) this branch (Terser only) delta delta (gzip)
bundle-critical.js 141,451 133,753 −7,698 +255
bundle-main.js 4,425 4,416 −9 −25

Follow-up

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]>
@ikuwow ikuwow marked this pull request as ready for review July 3, 2026 04:26
@ikuwow ikuwow merged commit 6304de8 into master Jul 3, 2026
6 checks passed
@ikuwow ikuwow deleted the drop-uglifier-double-minify branch July 3, 2026 04:30
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

Successfully merging this pull request may close these issues.

1 participant