Repository navigation
fix(@angular/build): use distinct chunk naming for web worker bundles - #34379
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the web worker bundling configuration in the Angular application builder by adding a 'chunkNames' property to ensure that chunks referenced by web workers are correctly emitted during optimization. A new test case was added to verify this behavior. I have reviewed the code and the feedback provided, which correctly identifies a potential runtime error in the test suite due to unsafe access of the 'workerMatch' variable. I have no further feedback to provide.
Previously, `bundleWebWorker` inherited `chunkNames` from the main esbuild configuration while bundling web workers in a separate synchronous esbuild pass. When both the main application bundle and a web worker dynamically imported modules that shared a common dependency, esbuild generated a shared chunk with identical content and the same `chunk-[hash].js` filename in both builds. During post-build chunk optimization, Rolldown traced only the main application entrypoint, merged the shared chunk into new optimized chunks, and removed the original `chunk-[hash].js` file from the build outputs while the unoptimized web worker chunks still imported it. Setting `chunkNames` to `'worker-chunk-[hash]'` in `bundleWebWorker` ensures that chunks emitted for web workers have distinct filenames and do not collide with main bundle chunks during metafile merging or chunk optimization. Closes angular#34292
1700a33 to
58a9667
Compare
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously,
bundleWebWorkerinheritedchunkNamesfrom the main esbuild configuration while bundling web workers in a separate synchronous esbuild pass. When both the main application bundle and a web worker dynamically imported modules that shared a common dependency, esbuild generated a shared chunk with identical content and the samechunk-[hash].jsfilename in both builds. During post-build chunk optimization, Rolldown traced only the main application entrypoint, merged the shared chunk into new optimized chunks, and removed the originalchunk-[hash].jsfile from the build outputs while the unoptimized web worker chunks still imported it.Setting
chunkNamesto'worker-chunk-[hash]'inbundleWebWorkerensures that chunks emitted for web workers have distinct filenames and do not collide with main bundle chunks during metafile merging or chunk optimization.Closes #34292