Skip to content

fix(vite-plugin-angular): skip rolldown dep optimizer transform in test mode and close transformer#2373

Merged
brandonroberts merged 1 commit into
analogjs:betafrom
fyvfyv:fix/rolldown-dep-optimizer-test-mode
Jun 11, 2026
Merged

fix(vite-plugin-angular): skip rolldown dep optimizer transform in test mode and close transformer#2373
brandonroberts merged 1 commit into
analogjs:betafrom
fyvfyv:fix/rolldown-dep-optimizer-test-mode

Conversation

@fyvfyv

@fyvfyv fyvfyv commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

PR Checklist

On Vite 8 (rolldown), the dep optimizer compiler plugin runs Angular's JavaScriptTransformer over every prebundled .js/.cjs/.mjs dependency even in test mode, and never closes the transformer's worker. The esbuild variant of the same plugin skips the transform in test mode (if (!isTest)) and closes the transformer in onEnd. Large packages in optimizeDeps.include can stall the optimizer before the vitest RUN banner because everything funnels through that single never-closed worker.

Closes #2371

Affected scope

  • Primary scope: vite-plugin-angular
  • Secondary scopes: none

Recommended merge strategy for maintainer [optional]

  • Squash merge
  • Rebase merge
  • Other

Commit preservation note [optional]

n/a

What is the new behavior?

createRolldownCompilerPlugin now takes the same isTest and closeTransformer flags as the esbuild variant:

  • in test mode it does not register the load transform, so prebundled deps are not piped through the Babel linker — same as the esbuild path;
  • when closeTransformer is set (everything except the Astro integration), the transformer is closed in buildEnd. JavaScriptTransformer.close() resets its lazy worker pool, so a later optimizer run re-creates it on demand.

createDepOptimizerConfig passes opts.isTest and !opts.isAstroIntegration, mirroring the esbuild call right below it.

Test plan

  • nx format:check
  • pnpm build (nx build-package vite-plugin-angular, tsc, no errors)
  • pnpm test (full workspace green; nx test vite-plugin-angular: 625 passed, 3 skipped)
  • Manual verification: new unit tests in compiler-plugin.spec.ts fail on the old code (the load hook was registered in test mode; no buildEnd) and pass with the fix

Does this PR introduce a breaking change?

  • Yes
  • No

createRolldownCompilerPlugin is internal — the package entry point only exports angular. The only call site is createDepOptimizerConfig.

Other information

The rest of the dep optimizer behavior on the rolldown path is unchanged.

@fyvfyv fyvfyv requested a review from brandonroberts as a code owner June 10, 2026 22:23
@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for analog-docs ready!

Name Link
🔨 Latest commit f511c86
🔍 Latest deploy log https://app.netlify.com/projects/analog-docs/deploys/6a29e3d90de8f70008bc4a76
😎 Deploy Preview https://deploy-preview-2373--analog-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for analog-blog ready!

Name Link
🔨 Latest commit f511c86
🔍 Latest deploy log https://app.netlify.com/projects/analog-blog/deploys/6a29e3d9fe2d1b0008804545
😎 Deploy Preview https://deploy-preview-2373--analog-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 10, 2026

Copy link
Copy Markdown

Deploy Preview for analog-app ready!

Name Link
🔨 Latest commit f511c86
🔍 Latest deploy log https://app.netlify.com/projects/analog-app/deploys/6a29e3d98c666c0009c224d6
😎 Deploy Preview https://deploy-preview-2373--analog-app.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a3ba15e-a207-40a3-ae85-41dc35fab38c

📥 Commits

Reviewing files that changed from the base of the PR and between 744b684 and f511c86.

📒 Files selected for processing (3)
  • packages/vite-plugin-angular/src/lib/compiler-plugin.spec.ts
  • packages/vite-plugin-angular/src/lib/compiler-plugin.ts
  • packages/vite-plugin-angular/src/lib/utils/plugin-config.ts

📝 Walkthrough

Walkthrough

This PR adds conditional test-mode skip and transformer lifecycle management to the Rolldown compiler plugin in the Vite Angular dependency optimizer. The createRolldownCompilerPlugin function signature is updated to accept isTest and closeTransformer boolean parameters. The plugin.load handler, which transforms .js/.mjs/.cjs dependencies via JavaScriptTransformer, is now attached only when isTest is false. When closeTransformer is true, a plugin.buildEnd hook closes the transformer to reset its worker pool. The callsite in createDepOptimizerConfig is updated to pass these flags based on build context, and test coverage verifies the conditional behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title follows Conventional Commit style with vite-plugin-angular scope and clearly summarizes the main fix: skipping the rolldown transform in test mode and closing the transformer.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem (rolldown plugin running transforms in test mode and never closing the worker) and the solution (adding isTest and closeTransformer flags).
Linked Issues check ✅ Passed The PR fully addresses issue #2371 by implementing the exact suggested fix: adding isTest and closeTransformer flags, skipping the load transform in test mode, and closing the transformer in buildEnd.
Out of Scope Changes check ✅ Passed All changes are strictly in-scope: updating createRolldownCompilerPlugin signature, conditionally attaching the load hook based on isTest, adding buildEnd to close the transformer, and updating the call site in createDepOptimizerConfig.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@brandonroberts

Copy link
Copy Markdown
Member

Thanks @fyvfyv!

@brandonroberts brandonroberts merged commit 756d510 into analogjs:beta Jun 11, 2026
20 of 21 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.

vite-plugin-angular: rolldown dep optimizer plugin runs in test mode and never closes its worker

2 participants