Skip to content

fix(deploy): skip dist/assets/js in minify-dist to keep Vite/esbuild bundles intact#2456

Merged
pethers merged 2 commits into
mainfrom
copilot/fix-console-issues-dashboards
May 13, 2026
Merged

fix(deploy): skip dist/assets/js in minify-dist to keep Vite/esbuild bundles intact#2456
pethers merged 2 commits into
mainfrom
copilot/fix-console-issues-dashboards

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

All 9 CIA dashboards on every language hub broke with SyntaxError: Unexpected token 'this' after the deploy-time minify-dist pass corrupted assets/js/papa-*.js.

coderaiser/minify (→ @putout/minify) strips the outer parens of a comma-expression initializer in a var declarator, turning valid esbuild output into invalid JS:

// esbuild — valid:
var n = this._partialLine + t,
    r = (this._partialLine = "", this._handle.parse(n, this._baseIndex, !this._finished));

// after coderaiser/minify — SyntaxError:
var n = this._partialLine + t,
    r = this._partialLine = "",
    this._handle.parse(n, this._baseIndex, !this._finished);   // not a valid var declarator

The broken papa-*.js module then fails to parse, taking down every chunk that imports it (cia-entry on the hub plus every lazy-loaded *-dashboard-*.js).

Changes

  • scripts/minify-dist.ts — add assets/js to SKIP_SUBPATHS. Vite already minifies these chunks with esbuild (build.minify: 'esbuild'); re-running coderaiser/minify yields zero compression and corrupts them. Authored static JS under dist/js/ (back-to-top, theme-toggle) is unaffected.
  • tests/css-purge-and-minify.test.ts — regression test using the exact failing PapaParse pattern as fixture; asserts the bundle is byte-identical after minifyRun while a sibling authored JS file outside the skip subtree still shrinks.

Verification

vite build + tsx scripts/minify-dist.ts dist leaves dist/assets/js/papa-*.js byte-identical (MD5 unchanged) and @babel/parser parses it cleanly. Pipeline log confirms scope: .js: 3 files, 17.7 KiB → 4.5 KiB — only the 3 authored static files outside assets/js/ are minified.

@pethers pethers marked this pull request as ready for review May 13, 2026 10:13
Copilot AI review requested due to automatic review settings May 13, 2026 10:13
@github-actions github-actions Bot added testing Test coverage refactor Code refactoring size-m Medium change (50-250 lines) labels May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This PR has been automatically labeled based on the files changed and PR metadata.

Applied Labels: testing,refactor,size-m

Label Categories

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a deploy-time regression where scripts/minify-dist.ts re-minified Vite/esbuild output under dist/assets/js/, and coderaiser/minify (@putout/minify) could miscompile certain comma-expression var initializers (observed in the PapaParse chunk), producing invalid JavaScript that broke all CIA dashboards.

Changes:

  • Update scripts/minify-dist.ts to skip the assets/js subtree (Vite/esbuild bundles) during the deploy minify pass.
  • Add a Vitest regression test ensuring assets/js/* bundles remain byte-identical while authored JS outside that subtree is still minified.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
scripts/minify-dist.ts Adds assets/js to SKIP_SUBPATHS so Vite/esbuild output is never re-minified by coderaiser/minify.
tests/css-purge-and-minify.test.ts Adds a regression test proving assets/js is skipped (PapaParse pattern) while other JS files are still minified.

@pethers pethers merged commit 18a73d1 into main May 13, 2026
19 checks passed
@pethers pethers deleted the copilot/fix-console-issues-dashboards branch May 13, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring size-m Medium change (50-250 lines) testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants