Commit 5b2c707
authored
fix(vitest): silence Vite native configLoader warnings (#1922)
* fix(vitest): silence Vite native configLoader warnings
Vite's configLoader: "native" (the future default) can't load config
files that use ESM syntax under CommonJS resolution or extensionless
relative imports. Fix both classes of warning:
- Rename root-level *.config.ts files (and
packages/design-token-ts-plugin/vitest.config.ts) to .mts, since the
nearest package.json has no "type" field and defaults to CommonJS.
- Add "type": "module" to packages/i18n/package.json, matching
packages/nimbus and packages/nimbus-mcp. It's an internal build tool
only ever invoked via tsx (unaffected by "type") or imported from
Vite config loaders, so this is safe.
- Add explicit .ts extensions to the now-flagged relative imports in
packages/nimbus's vite/vitest configs (allowImportingTsExtensions is
already enabled in tsconfig).
Verified pnpm test:dev, the unit/unit-isolated/ts-plugin/scripts
projects, and typecheck:dev all pass with the warnings gone.
* docs(testing): update root orchestrator filename to vitest.config.mts
Keeps the unit-testing guideline in sync with the rename in
a4c1efb (fix(vitest): silence Vite native configLoader warnings).
* fix(i18n): fix CI build breakage from prior commit
The previous commit added "type": "module" to packages/i18n/package.json
to silence a Vite native configLoader warning about ESM syntax loaded
as CommonJS. That broke this package's build pipeline: its tsx-invoked
scripts (build:split, build:compile-strings, build:dictionaries) use
CommonJS __dirname without an ESM fallback, and tsx treats a file as
ESM once the nearest package.json sets "type": "module". Every script
failed with `ReferenceError: __dirname is not defined`, no *.messages.ts
files got generated, and packages/nimbus's build then failed with
~36 "Cannot find module '*.messages'" errors.
Fix by reverting the package-wide "type": "module" and instead
renaming just the offending file to locales.mts (same approach already
used for the root-level vitest configs), which makes Vite's native
config loader treat it as ESM without touching how tsx resolves every
other file in the package. Updated the file's extensionless importers
(compile-component-messages.ts, extract-messages.ts,
generate-dictionaries.ts, split-by-component.ts) to the explicit
.mts extension, since tsx's CJS-mode resolver doesn't probe for .mts
on extensionless specifiers. Also updated the one cross-package import
in packages/nimbus/vite.config.ts and doc references
(packages/i18n/CLAUDE.md, packages/i18n/README.md).
Verified: pnpm --filter @commercetools/nimbus-i18n build succeeds,
pnpm --filter @commercetools/nimbus build succeeds (the exact command
that failed in CI), and the unit/unit-isolated/ts-plugin/nimbus-mcp/
scripts vitest projects all pass (2019 tests).1 parent cec7e2b commit 5b2c707
18 files changed
Lines changed: 23 additions & 23 deletions
File tree
- docs/file-type-guidelines
- packages
- design-token-ts-plugin
- i18n
- scripts
- nimbus
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
File renamed without changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments