Skip to content

feat: add toggable injectCjsGlobals option#10709

Open
sheremet-va wants to merge 7 commits into
mainfrom
feat/inject-cjs-globals
Open

feat: add toggable injectCjsGlobals option#10709
sheremet-va wants to merge 7 commits into
mainfrom
feat/inject-cjs-globals

Conversation

@sheremet-va

@sheremet-va sheremet-va commented Jul 4, 2026

Copy link
Copy Markdown
Member

This PR adds injectCjsGlobals for projects that keep using the module runner to run tests, but need a more fair environment (ESM files do not have access to CJS globals).

Thanks Fable

I am hoping to disable this by default in Vitest 6

@netlify

netlify Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit b196c87
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6a4d03c9c9fb7f000929551c
😎 Deploy Preview https://deploy-preview-10709--vitest-dev.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.

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm. Made a few comments.

I am hoping to disable this by default in Vitest 6

Also agree.

Comment thread packages/vitest/src/node/resolver.ts Outdated
Comment thread packages/vitest/src/runtime/moduleRunner/moduleEvaluator.ts Outdated
Comment thread packages/vitest/src/node/environments/fetchModule.ts
@sheremet-va

Copy link
Copy Markdown
Member Author

Important to sync with #10708 (or the other way around) because they touch the same mechanism

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.

Have a strictModuleType option to disable CJS-ESM interop

2 participants