fix(js): remove redundant vite.config.ts generation for vitest projects#34603
fix(js): remove redundant vite.config.ts generation for vitest projects#34603
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 52d6c01
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Important
At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.
Nx Cloud has identified a possible root cause for your failed CI:
We've classified these failures as environment_state because the failing plugin:test task is in a project not touched by this PR (which only modifies the js package), and the error indicates a Jest infrastructure issue with native bindings rather than application logic. The PR's changes to remove redundant vite.config.ts generation have no logical connection to plugin package tests or Jest's native binding loading.
No code changes were suggested for this issue.
Trigger a rerun:
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
🎓 Learn more about Self-Healing CI on nx.dev
## Current Behavior When generating a library with vitest as the test runner and a non-vite bundler (e.g. tsc), the js library generator creates two config files: - `vitest.config.mts` (from the vitest configurationGenerator) with `root: __dirname` - `vite.config.ts` (from a second createOrEditViteConfig call) with `root: import.meta.dirname` The redundant `vite.config.ts` uses ESM-only `import.meta.dirname` syntax, which causes TS1470 when the project targets CommonJS output. ## Expected Behavior Only `vitest.config.mts` should be generated since the vitest configurationGenerator already handles creating the correct config file. ## Related Issue(s) Fixes #34399
…ts (#34603) ## Current Behavior When generating a library with vitest as the test runner and a non-vite bundler (e.g. `tsc`), the js library generator creates two config files: - `vitest.config.mts` (from the vitest `configurationGenerator`) with `root: __dirname` - `vite.config.ts` (from a second `createOrEditViteConfig` call) with `root: import.meta.dirname` The redundant `vite.config.ts` uses ESM-only `import.meta.dirname` syntax, which causes TS1470 when the project targets CommonJS output: ``` vite.config.ts:5:9 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. 5 root: import.meta.dirname, ~~~~~~~~~~~ ``` ## Expected Behavior Only `vitest.config.mts` should be generated. The vitest `configurationGenerator` already handles creating the correct config file with `root: __dirname`. The second `createOrEditViteConfig` call from `@nx/vite` was redundant and produced the conflicting file. ## Related Issue(s) Fixes #34399 (cherry picked from commit 1e3f8e0)
…ts (#34603) ## Current Behavior When generating a library with vitest as the test runner and a non-vite bundler (e.g. `tsc`), the js library generator creates two config files: - `vitest.config.mts` (from the vitest `configurationGenerator`) with `root: __dirname` - `vite.config.ts` (from a second `createOrEditViteConfig` call) with `root: import.meta.dirname` The redundant `vite.config.ts` uses ESM-only `import.meta.dirname` syntax, which causes TS1470 when the project targets CommonJS output: ``` vite.config.ts:5:9 - error TS1470: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. 5 root: import.meta.dirname, ~~~~~~~~~~~ ``` ## Expected Behavior Only `vitest.config.mts` should be generated. The vitest `configurationGenerator` already handles creating the correct config file with `root: __dirname`. The second `createOrEditViteConfig` call from `@nx/vite` was redundant and produced the conflicting file. ## Related Issue(s) Fixes #34399 (cherry picked from commit 1e3f8e0)
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
When generating a library with vitest as the test runner and a non-vite bundler (e.g.
tsc), the js library generator creates two config files:vitest.config.mts(from the vitestconfigurationGenerator) withroot: __dirnamevite.config.ts(from a secondcreateOrEditViteConfigcall) withroot: import.meta.dirnameThe redundant
vite.config.tsuses ESM-onlyimport.meta.dirnamesyntax, which causes TS1470 when the project targets CommonJS output:Expected Behavior
Only
vitest.config.mtsshould be generated. The vitestconfigurationGeneratoralready handles creating the correct config file withroot: __dirname. The secondcreateOrEditViteConfigcall from@nx/vitewas redundant and produced the conflicting file.Related Issue(s)
Fixes #34399