Skip to content

fix(vitest): silence Vite native configLoader warnings - #1922

Merged
ByronDWall merged 3 commits into
mainfrom
fix-vitest-native-configloader-warnings
Aug 18, 2026
Merged

fix(vitest): silence Vite native configLoader warnings#1922
ByronDWall merged 3 commits into
mainfrom
fix-vitest-native-configloader-warnings

Conversation

@ByronDWall

Copy link
Copy Markdown
Contributor

Summary

Silences the Vite configLoader: 'native' deprecation warnings that surfaced when running pnpm test / pnpm test:dev:

(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`, ...
  - ESM syntax in a file loaded as CommonJS (vitest.config.ts:1:1). Use a `.mjs` extension or set `"type": "module"` in the closest package.json

No behavior change — purely config/tooling cleanup.

Changes

  • Renamed 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 Node/Vite resolve .ts as CommonJS by default:
    • vitest.config.mts
    • vitest.dev.config.mts
    • vitest.scripts.config.mts
    • packages/design-token-ts-plugin/vitest.config.mts
    • Updated all references: package.json test:dev/test:storybook:dev scripts, projects arrays, and comments.
  • Added "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 a Vite config loader, so this is safe.
  • Added explicit .ts extensions to the now-flagged relative imports in packages/nimbus's vite/vitest configs (allowImportingTsExtensions is already enabled in tsconfig.json).
  • Updated docs/file-type-guidelines/unit-testing.md to reference the renamed root orchestrator file.

Verification

  • pnpm test:dev and the unit/unit-isolated/ts-plugin/nimbus-mcp/scripts projects all pass (1690+ tests), with no configLoader: 'native' warnings.
  • pnpm --filter @commercetools/nimbus typecheck:dev passes.

Not in scope

  • plans/full-mcp-ui-workflow/ssr/SSR_IMPLEMENTATION.md still references the pre-rename vitest.config.ts filename — it's a standalone planning doc, not a maintained guideline, so left untouched.
  • docs/file-type-guidelines/unit-testing.md's root-orchestrator example only lists 2 of the now 6 projects — pre-existing drift unrelated to this change, not fixed here.

@ByronDWall
ByronDWall requested a review from a team as a code owner August 13, 2026 14:26
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nimbus-documentation Ready Ready Preview Aug 18, 2026 6:41pm
nimbus-storybook Ready Ready Preview Aug 18, 2026 6:41pm

Request Review

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8c66968

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Report

Last updated: 2026-08-18 18:41:03 UTC

Package Format Current Baseline Delta Status
@commercetools/nimbus dist 18950.9 KB 18950.9 KB +0.0% ✅ ok
@commercetools/nimbus-icons dist 4787.6 KB 4787.6 KB +0.0% ✅ ok
@commercetools/nimbus-tokens dist 408.9 KB 408.9 KB +0.0% ✅ ok

Baseline source: comment-chain

@chromatic-com

chromatic-com Bot commented Aug 13, 2026

Copy link
Copy Markdown

Tip

All tests passed and all changes approved!

🟢 UI Tests: 1207 tests unchanged
🟢 UI Review: 1207 stories published -- no changes
Storybook icon Storybook Publish: 1207 stories published

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.
Keeps the unit-testing guideline in sync with the rename in
a4c1efb (fix(vitest): silence Vite native configLoader warnings).
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).
@ByronDWall
ByronDWall force-pushed the fix-vitest-native-configloader-warnings branch from aeeac00 to 8c66968 Compare August 18, 2026 18:38
@ByronDWall
ByronDWall enabled auto-merge (squash) August 18, 2026 18:39
@ByronDWall
ByronDWall merged commit 5b2c707 into main Aug 18, 2026
13 checks passed
@ByronDWall
ByronDWall deleted the fix-vitest-native-configloader-warnings branch August 18, 2026 18:47
@github-actions github-actions Bot added the bundle-sizes Housekeeping for merged PRs - allows the fetch sizes script to find the latest bundle check comment. label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bundle-sizes Housekeeping for merged PRs - allows the fetch sizes script to find the latest bundle check comment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants