Skip to content

core: frontend: Fail build on corrupt emitted JavaScript - #4101

Merged
patrickelectric merged 1 commit into
bluerobotics:masterfrom
joaoantoniocardoso:fail_build_on_corrupt_frontend_js
Aug 7, 2026
Merged

core: frontend: Fail build on corrupt emitted JavaScript#4101
patrickelectric merged 1 commit into
bluerobotics:masterfrom
joaoantoniocardoso:fail_build_on_corrupt_frontend_js

Conversation

@joaoantoniocardoso

Copy link
Copy Markdown
Member

Brings the fix for #4091 from #4094 (1.4) into master.

@joaoantoniocardoso
joaoantoniocardoso requested a review from a team August 7, 2026 18:13
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Automated PR Review

0. Summary

  • Verdict: LGTM :shipit:

Adds a post-compression Vite plugin (validate-emitted-javascript) that recursively walks dist/, gunzips each .js/.js.gz chunk, and runs esbuild.transformSync on it — so a corrupt emitted chunk (like the source-map-as-chunk regression in 1.4.4-beta.14) fails the build instead of only breaking the route that imports it at runtime. enforce: 'post' plus closeBundle: { sequential: true } correctly orders it after viteCompression, so it validates the exact bytes nginx serves via gzip_static. esbuild is a transitive dep of Vite so require('esbuild') resolves reliably; the regex /\.js(\.gz)?$/ correctly ignores .js.map sourcemaps (which aren't in the compression filter and remain as-is on disk) and doesn't accidentally match .mjs/.cjs. Comment style explains the "why" without parroting, and the change follows the existing CommonJS require() pattern already used in this file.

No further comments, nice job 👍

Generated by PR Review Bot. This is advisory, a human reviewer must still approve.

@patrickelectric
patrickelectric merged commit 2fe71b1 into bluerobotics:master Aug 7, 2026
10 of 11 checks passed
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.

2 participants