Commit ea2c772
fix(js): remove redundant vite.config.ts generation for vitest projects (#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)1 parent 63d6652 commit ea2c772
3 files changed
Lines changed: 9 additions & 17 deletions
File tree
- packages
- js/src/generators/library
- plugin/src/generators/plugin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1773 | 1773 | | |
1774 | 1774 | | |
1775 | 1775 | | |
1776 | | - | |
| 1776 | + | |
1777 | 1777 | | |
1778 | 1778 | | |
1779 | 1779 | | |
1780 | 1780 | | |
1781 | 1781 | | |
1782 | 1782 | | |
1783 | 1783 | | |
1784 | | - | |
| 1784 | + | |
| 1785 | + | |
1785 | 1786 | | |
1786 | 1787 | | |
1787 | 1788 | | |
1788 | 1789 | | |
1789 | | - | |
| 1790 | + | |
1790 | 1791 | | |
1791 | 1792 | | |
1792 | 1793 | | |
1793 | 1794 | | |
1794 | 1795 | | |
1795 | 1796 | | |
1796 | 1797 | | |
1797 | | - | |
| 1798 | + | |
| 1799 | + | |
1798 | 1800 | | |
1799 | 1801 | | |
1800 | 1802 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | 176 | | |
178 | 177 | | |
179 | 178 | | |
| |||
188 | 187 | | |
189 | 188 | | |
190 | 189 | | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 190 | | |
202 | 191 | | |
203 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
| 249 | + | |
249 | 250 | | |
250 | 251 | | |
251 | 252 | | |
| |||
0 commit comments