Skip to content

Commit 8c66968

Browse files
committed
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 8a5c29b commit 8c66968

9 files changed

Lines changed: 10 additions & 11 deletions

File tree

packages/i18n/CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ packages/i18n/
6868
│ ├── split-by-component.ts
6969
│ ├── compile-component-messages.ts
7070
│ ├── generate-dictionaries.ts
71-
│ └── locales.ts
71+
│ └── locales.mts
7272
├── .temp/ # Temporary build artifacts (gitignored)
7373
│ └── by-component/ # Messages grouped by component
7474
├── package.json
@@ -286,7 +286,7 @@ from the generated `*.messages.ts` files.
286286
287287
## Supported Locales
288288
289-
Available locales (defined in `scripts/locales.ts`):
289+
Available locales (defined in `scripts/locales.mts`):
290290
291291
- `en` - English
292292
- `de` - German
@@ -300,7 +300,7 @@ English for unsupported locales.
300300
301301
To add a new locale:
302302
303-
1. Add locale code to `scripts/locales.ts`
303+
1. Add locale code to `scripts/locales.mts`
304304
2. Create `data/[locale].json` file with Transifex translations
305305
3. Update Vite config's `optimize-locales-plugin` to include new locale
306306
4. Run build to compile: `pnpm --filter @commercetools/nimbus-i18n build`

packages/i18n/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This is an **internal build tool package** that:
3333
### Locale Configuration
3434

3535
**Single Source of Truth:** All supported locales are defined in
36-
`packages/i18n/scripts/locales.ts` and shared between the build scripts and the
36+
`packages/i18n/scripts/locales.mts` and shared between the build scripts and the
3737
Vite config (`optimize-locales-plugin`).
3838

3939
### Build Pipeline

packages/i18n/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"keywords": ["typescript", "design-system", "react", "nimbus"],
1313
"license": "MIT",
1414
"private": true,
15-
"type": "module",
1615
"sideEffects": false,
1716
"files": ["data"],
1817
"scripts": {

packages/i18n/scripts/compile-component-messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { compileStrings } from "@internationalized/string-compiler";
3232
import fs from "fs/promises";
3333
import path from "path";
3434
import { format } from "prettier";
35-
import { LOCALE_CODES } from "./locales";
35+
import { LOCALE_CODES } from "./locales.mts";
3636

3737
const LOCALES = LOCALE_CODES;
3838

packages/i18n/scripts/extract-messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { glob } from "glob";
99
import * as fs from "fs";
1010
import * as path from "path";
11-
import { LOCALE_CODES } from "./locales";
11+
import { LOCALE_CODES } from "./locales.mts";
1212

1313
// Type definitions for message descriptors in .i18n.ts files
1414
type MessageDescriptor = {

packages/i18n/scripts/generate-dictionaries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import fs from "fs/promises";
3838
import path from "path";
3939
import { format, resolveConfig } from "prettier";
40-
import { SUPPORTED_LOCALES } from "./locales";
40+
import { SUPPORTED_LOCALES } from "./locales.mts";
4141

4242
const LOCALES = SUPPORTED_LOCALES;
4343

packages/i18n/scripts/split-by-component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
import fs from "fs/promises";
4444
import path from "path";
45-
import { LOCALE_CODES } from "./locales";
45+
import { LOCALE_CODES } from "./locales.mts";
4646

4747
const LOCALES = LOCALE_CODES;
4848

packages/nimbus/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { LibraryFormats, PluginOption, Rollup } from "vite";
66
import react from "@vitejs/plugin-react";
77
import dts from "vite-plugin-dts";
88
import { analyzer } from "vite-bundle-analyzer";
9-
import { LOCALE_BCP47_CODES } from "../i18n/scripts/locales.ts";
9+
import { LOCALE_BCP47_CODES } from "../i18n/scripts/locales.mts";
1010

1111
/**
1212
* Builds the entry map for the library build.
@@ -156,7 +156,7 @@ export default defineConfig(async () => {
156156
plugins: [
157157
react(),
158158
// Only package locale strings for locales we internationalize in our products
159-
// Locales are defined in packages/i18n/scripts/locales.ts (single source of truth)
159+
// Locales are defined in packages/i18n/scripts/locales.mts (single source of truth)
160160
// https://github.com/commercetools/merchant-center-application-kit/blob/main/packages/i18n/README.md#supported-locales
161161
// https://react-spectrum.adobe.com/react-aria/internationalization.html#vite
162162
optimizeLocales.vite({

0 commit comments

Comments
 (0)