@open-pioneer/vite-plugin-pioneer 6.0.0-dev-vite8.20260428104721 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Changelog @open-pioneer/vite-plugin-pioneer
2
2
 
3
- ## 6.0.0-dev-vite8.20260428104721
3
+ ## 6.0.0
4
4
 
5
5
  ### Major Changes
6
6
 
7
- - 90b34b1: Update to Vite 8 (support for Vite 7 is dropped).
7
+ - a13823e: Update to Vite 8 (support for Vite 7 is dropped).
8
8
 
9
9
  ### Minor Changes
10
10
 
@@ -19,15 +19,19 @@
19
19
  console.log(baseUrl);
20
20
  ```
21
21
 
22
+ - 18c9d75: Add codegen support for hot reloading of i18n message during development.
23
+ HMR of i18n messages requires the latest version of the runtime package.
22
24
  - 9dda91c: Support for package metadata version `1.1.0`.
23
25
 
24
26
  ### Patch Changes
25
27
 
28
+ - b49be74: Bump dependencies
26
29
  - 9dda91c: Improve error message when the plugin encounters an unsupported package metadata version.
30
+ - Updated dependencies [b49be74]
27
31
  - Updated dependencies [9dda91c]
28
32
  - Updated dependencies [9dda91c]
29
33
  - Updated dependencies [9dda91c]
30
- - @open-pioneer/build-common@4.0.0-dev-vite8.20260428104721
34
+ - @open-pioneer/build-common@4.0.0
31
35
 
32
36
  ## 5.1.2
33
37
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/codegenPlugin.ts
2
- import { RuntimeSupport } from "@open-pioneer/build-common";
2
+ import { RuntimeSupport as RuntimeSupport3 } from "@open-pioneer/build-common";
3
3
  import { readFile as readFile3 } from "node:fs/promises";
4
4
  import { dirname as dirname4 } from "node:path";
5
5
  import { cwd } from "node:process";
@@ -173,27 +173,53 @@ function findPackageJson(startDir, rootDir) {
173
173
  }
174
174
 
175
175
  // src/codegen/generateAppMetadata.ts
176
- function generateAppMetadata(packageDirectory, metadataModuleId) {
176
+ import { RuntimeSupport } from "@open-pioneer/build-common";
177
+ function generateAppMetadata(packageDirectory, metadataModuleId, runtimeMetadataVersion) {
177
178
  const packagesModule = serializeModuleId({ type: "app-packages", packageDirectory });
178
179
  const cssModule = serializeModuleId({ type: "app-css", packageDirectory }) + "&inline&lang.scss";
179
180
  const i18nModule = serializeModuleId({ type: "app-i18n-index", packageDirectory });
181
+ const features = RuntimeSupport.getRuntimeFeatures(runtimeMetadataVersion);
182
+ const boxMessages = features.supportsMessageBox;
180
183
  return `
181
184
  import { createBox } from ${JSON.stringify(metadataModuleId)};
182
185
  import packages from ${JSON.stringify(packagesModule)};
183
186
  import stylesString from ${JSON.stringify(cssModule)};
184
- import { locales, loadMessages } from ${JSON.stringify(i18nModule)};
187
+ import { locales, loadMessages as loadMessagesFn } from ${JSON.stringify(i18nModule)};
185
188
 
186
189
  const styles = createBox(stylesString);
190
+ const loadMessages = ${JSON.stringify(boxMessages)} ? createBox(loadMessagesFn) : loadMessagesFn ;
191
+
187
192
  if (import.meta.hot) {
188
193
  import.meta.hot.data.styles ??= styles;
194
+ import.meta.hot.data.loadMessages ??= loadMessages;
195
+
189
196
  import.meta.hot.accept((mod) => {
190
- if (mod && mod.packages === packages && mod.locales === locales && mod.loadMessages === loadMessages) {
191
- import.meta.hot.data.styles.setValue(mod.styles.value);
197
+ function arrayEq(a, b) {
198
+ if (a === b) {
199
+ return true;
200
+ }
201
+ if (!a || !b) {
202
+ return false;
203
+ }
204
+ return a.length === b.length && a.every((v, i) => v === b[i]);
205
+ }
206
+
207
+ // Update if
208
+ // - packages changed (no HMR)
209
+ // - locales changed (no HMR)
210
+ // - message boxing is not supported (runtime metadata version 1.0, no HMR)
211
+ if (!mod || mod.packages !== packages || !arrayEq(mod.locales, locales) || (${JSON.stringify(!boxMessages)} && mod.loadMessages !== loadMessagesFn)) {
212
+ // Cannot handle these changes, trigger reload:
213
+ import.meta.hot.invalidate();
192
214
  return;
193
215
  }
194
-
195
- // Cannot handle all other changes the moment; trigger reload.
196
- import.meta.hot.invalidate();
216
+
217
+ if (mod.styles.value !== styles.value) {
218
+ import.meta.hot.data.styles.setValue(mod.styles.value);
219
+ }
220
+ if (${JSON.stringify(boxMessages)} && mod.loadMessages.value !== loadMessages.value) {
221
+ import.meta.hot.data.loadMessages.setValue(mod.loadMessages.value);
222
+ }
197
223
  });
198
224
  }
199
225
 
@@ -201,7 +227,7 @@ export {
201
227
  packages,
202
228
  styles,
203
229
  locales,
204
- loadMessages
230
+ loadMessages,
205
231
  };
206
232
  `.trim();
207
233
  }
@@ -273,7 +299,7 @@ async function generateI18nMessages(options) {
273
299
  if (!filePath) {
274
300
  continue;
275
301
  }
276
- const { messages, overrides } = await loadI18n(filePath);
302
+ const { messages, overrides } = await loadI18n(pkg2, filePath);
277
303
  if (pkg2.name === appName) {
278
304
  packageOverrides = overrides;
279
305
  } else if (overrides) {
@@ -563,7 +589,7 @@ var DeploymentModule = class {
563
589
  };
564
590
 
565
591
  // src/metadata/MetadataRepository.ts
566
- import { BUILD_CONFIG_NAME as BUILD_CONFIG_NAME2 } from "@open-pioneer/build-common";
592
+ import { BUILD_CONFIG_NAME as BUILD_CONFIG_NAME2, RuntimeSupport as RuntimeSupport2 } from "@open-pioneer/build-common";
567
593
  import { realpath } from "fs/promises";
568
594
  import { basename as basename2, dirname as dirname2 } from "path";
569
595
  import { normalizePath as normalizePath3 } from "vite";
@@ -757,10 +783,6 @@ var PackageMetadataReader = class {
757
783
  throw new ReportableError(`Locale '${locale}' was defined twice in ${configPath}`);
758
784
  }
759
785
  const path = join2(packageDir, "i18n", `${locale}.yaml`);
760
- ctx.addWatchFile(path);
761
- if (!await fileExists(path)) {
762
- throw new ReportableError(`i18n file '${path}' does not exist.`);
763
- }
764
786
  i18nPaths.set(locale, normalizePath2(path));
765
787
  }
766
788
  return {
@@ -854,12 +876,17 @@ var PackageMetadataReader = class {
854
876
  let buildConfig;
855
877
  ctx.addWatchFile(normalizePath2(buildConfigPath));
856
878
  if (await fileExists(buildConfigPath)) {
879
+ ctx.addWatchFile(normalizePath2(buildConfigPath));
857
880
  try {
858
881
  buildConfig = await loadBuildConfig(buildConfigPath);
859
882
  } catch (e) {
860
- throw new ReportableError(`Failed to load build config ${buildConfigPath}`, {
861
- cause: e
862
- });
883
+ const cause = e instanceof Error ? e.cause : String(e);
884
+ throw new ReportableError(
885
+ `Failed to load build config ${buildConfigPath}. ${cause}`,
886
+ {
887
+ cause: e
888
+ }
889
+ );
863
890
  }
864
891
  } else if (!this.allowMissingBuildConfig) {
865
892
  throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);
@@ -1119,76 +1146,19 @@ var MetadataRepository = class {
1119
1146
  appPackageMetadata.dependencies,
1120
1147
  appPackageMetadata.packageJsonPath
1121
1148
  );
1149
+ const packages = Array.from(packageMetadataByName.values());
1150
+ const runtimeMetadataVersion = detectRuntimeMetadataVersion(packages);
1122
1151
  const appMetadata = {
1123
1152
  name: appPackageMetadata.name,
1124
1153
  directory: appPackageMetadata.directory,
1125
1154
  locales: appLocales,
1126
1155
  packageJsonPath: appPackageMetadata.packageJsonPath,
1127
1156
  appPackage: appPackageMetadata,
1128
- packages: Array.from(packageMetadataByName.values())
1157
+ packages,
1158
+ runtimeMetadataVersion
1129
1159
  };
1130
- await this.checkAppI18n(ctx, appMetadata);
1131
1160
  return appMetadata;
1132
1161
  }
1133
- async checkAppI18n(ctx, appMetadata) {
1134
- const appPackage = appMetadata.appPackage;
1135
- const appLocales = new Set(appMetadata.locales);
1136
- const appI18nFiles = await Promise.all(
1137
- Array.from(appLocales).map((locale) => {
1138
- const i18nPath = appPackage.i18nPaths.get(locale);
1139
- if (i18nPath == null) {
1140
- throw new Error(
1141
- `App package '${appPackage.name}' does not have an i18n file for locale '${locale}'.`
1142
- );
1143
- }
1144
- return this.getI18nFile(ctx, i18nPath);
1145
- })
1146
- );
1147
- const errors = [];
1148
- for (const pkg2 of appMetadata.packages) {
1149
- const pkgLocales = pkg2.locales;
1150
- if (pkgLocales.length === 0) {
1151
- continue;
1152
- }
1153
- if (pkg2.locales.some((locale) => appLocales.has(locale))) {
1154
- continue;
1155
- }
1156
- if (appI18nFiles.some((i18nFile) => {
1157
- var _a;
1158
- return (_a = i18nFile.overrides) == null ? void 0 : _a.get(pkg2.name);
1159
- })) {
1160
- continue;
1161
- }
1162
- errors.push(pkg2);
1163
- }
1164
- if (errors.length === 0) {
1165
- return;
1166
- }
1167
- errors.sort((p1, p2) => p1.name.localeCompare(p2.name, "en"));
1168
- const getPackageErrors = () => {
1169
- const MAX = 3;
1170
- const take = Math.min(errors.length, MAX);
1171
- const remaining = errors.length - take;
1172
- let buffer = "";
1173
- for (let i = 0; i < take; ++i) {
1174
- if (i > 0) {
1175
- buffer += ", ";
1176
- }
1177
- const pkg2 = errors[i];
1178
- buffer += `'${pkg2.name}' (${pkg2.locales.toSorted().join(", ")})`;
1179
- }
1180
- if (remaining > 0) {
1181
- buffer += ` (and ${remaining} more)`;
1182
- }
1183
- return buffer;
1184
- };
1185
- const formattedAppLocales = appMetadata.locales.join(", ") || "none";
1186
- const formattedPackageErrors = getPackageErrors();
1187
- throw new ReportableError(
1188
- `Invalid i18n configuration in application at ${appMetadata.directory}:
1189
- There is no match between the locales supported by the application (${formattedAppLocales}) and the locales supported by the packages ${formattedPackageErrors}.`
1190
- );
1191
- }
1192
1162
  /**
1193
1163
  * Returns package metadata associated with the given package.
1194
1164
  */
@@ -1311,6 +1281,33 @@ All packages must use a common version of '${metadata.name}'.
1311
1281
  return new Cache(provider);
1312
1282
  }
1313
1283
  };
1284
+ function detectRuntimeMetadataVersion(packages) {
1285
+ var _a;
1286
+ const runtimePackage = packages.find((p) => p.name === RuntimeSupport2.RUNTIME_PACKAGE_NAME);
1287
+ if (!runtimePackage) {
1288
+ return RuntimeSupport2.DEFAULT_METADATA_VERSION;
1289
+ }
1290
+ const metadataVersion = (_a = runtimePackage.config.runtimeMeta) == null ? void 0 : _a.metadataVersion;
1291
+ if (!metadataVersion) {
1292
+ return RuntimeSupport2.DEFAULT_METADATA_VERSION;
1293
+ }
1294
+ const versionResult = RuntimeSupport2.getSupportedRuntimeMetadataVersion(metadataVersion);
1295
+ if (typeof versionResult != "string" && "code" in versionResult) {
1296
+ switch (versionResult.code) {
1297
+ case "invalid-version":
1298
+ throw new ReportableError(`Invalid metadata version ${metadataVersion}`, {
1299
+ cause: versionResult.error
1300
+ });
1301
+ case "unsupported-version":
1302
+ throw new ReportableError(
1303
+ `Runtime metadata version ${metadataVersion} of ${runtimePackage.name} is not supported.
1304
+ This plugin supports versions ^${RuntimeSupport2.CURRENT_METADATA_MAJOR}.`
1305
+ );
1306
+ }
1307
+ }
1308
+ isDebug2 && debug3("Detected runtime version %s", versionResult);
1309
+ return versionResult;
1310
+ }
1314
1311
  function propagateWatchFiles(watchFiles, ctx) {
1315
1312
  for (const file of watchFiles) {
1316
1313
  ctx.addWatchFile(file);
@@ -1413,6 +1410,95 @@ function createDummyContext() {
1413
1410
  };
1414
1411
  }
1415
1412
 
1413
+ // src/metadata/validateI18nConfig.ts
1414
+ var isDebug4 = !!process.env.DEBUG;
1415
+ var debug5 = createDebugger("open-pioneer:validateI18nConfig");
1416
+ async function validateI18nConfig(ctx, repository, appMetadata) {
1417
+ const locales = appMetadata.locales;
1418
+ for (const pkg2 of appMetadata.packages) {
1419
+ isDebug4 && debug5("Checking i18n files of package %s", pkg2.name);
1420
+ await checkPackageI18nFiles(ctx, pkg2, locales);
1421
+ }
1422
+ await checkAppI18n(ctx, repository, appMetadata);
1423
+ }
1424
+ async function checkPackageI18nFiles(ctx, pkg2, locales) {
1425
+ for (const locale of locales) {
1426
+ const filePath = pkg2.i18nPaths.get(locale);
1427
+ if (!filePath) {
1428
+ isDebug4 && debug5("Package does not support locale '%s'", locale);
1429
+ continue;
1430
+ }
1431
+ isDebug4 && debug5("Checking i18n file %s", filePath);
1432
+ ctx.addWatchFile(filePath);
1433
+ if (!await fileExists(filePath)) {
1434
+ throw new ReportableError(
1435
+ `I18n file in package '${pkg2.name}' for locale '${locale}' does not exist: '${filePath}'.`
1436
+ );
1437
+ } else {
1438
+ isDebug4 && debug5("i18n file %s exists", filePath);
1439
+ }
1440
+ }
1441
+ }
1442
+ async function checkAppI18n(ctx, repository, appMetadata) {
1443
+ const appPackage = appMetadata.appPackage;
1444
+ const appLocales = new Set(appMetadata.locales);
1445
+ const appI18nFiles = await Promise.all(
1446
+ Array.from(appLocales).map((locale) => {
1447
+ const i18nPath = appPackage.i18nPaths.get(locale);
1448
+ if (i18nPath == null) {
1449
+ throw new Error(
1450
+ `App package '${appPackage.name}' does not have an i18n file for locale '${locale}'.`
1451
+ );
1452
+ }
1453
+ return repository.getI18nFile(ctx, i18nPath);
1454
+ })
1455
+ );
1456
+ const errors = [];
1457
+ for (const pkg2 of appMetadata.packages) {
1458
+ const pkgLocales = pkg2.locales;
1459
+ if (pkgLocales.length === 0) {
1460
+ continue;
1461
+ }
1462
+ if (pkg2.locales.some((locale) => appLocales.has(locale))) {
1463
+ continue;
1464
+ }
1465
+ if (appI18nFiles.some((i18nFile) => {
1466
+ var _a;
1467
+ return (_a = i18nFile.overrides) == null ? void 0 : _a.get(pkg2.name);
1468
+ })) {
1469
+ continue;
1470
+ }
1471
+ errors.push(pkg2);
1472
+ }
1473
+ if (errors.length === 0) {
1474
+ return;
1475
+ }
1476
+ errors.sort((p1, p2) => p1.name.localeCompare(p2.name, "en"));
1477
+ const getPackageErrors = () => {
1478
+ const MAX = 3;
1479
+ const take = Math.min(errors.length, MAX);
1480
+ const remaining = errors.length - take;
1481
+ let buffer = "";
1482
+ for (let i = 0; i < take; ++i) {
1483
+ if (i > 0) {
1484
+ buffer += ", ";
1485
+ }
1486
+ const pkg2 = errors[i];
1487
+ buffer += `'${pkg2.name}' (${pkg2.locales.toSorted().join(", ")})`;
1488
+ }
1489
+ if (remaining > 0) {
1490
+ buffer += ` (and ${remaining} more)`;
1491
+ }
1492
+ return buffer;
1493
+ };
1494
+ const formattedAppLocales = appMetadata.locales.join(", ") || "none";
1495
+ const formattedPackageErrors = getPackageErrors();
1496
+ throw new ReportableError(
1497
+ `Invalid i18n configuration in application at ${appMetadata.directory}:
1498
+ There is no match between the locales supported by the application (${formattedAppLocales}) and the locales supported by the packages ${formattedPackageErrors}.`
1499
+ );
1500
+ }
1501
+
1416
1502
  // src/metadata/Context.ts
1417
1503
  function createMetadataContextFromRolldown(ctx) {
1418
1504
  return {
@@ -1433,8 +1519,8 @@ function createMetadataContextFromRolldown(ctx) {
1433
1519
  }
1434
1520
 
1435
1521
  // src/codegenPlugin.ts
1436
- var isDebug4 = !!process.env.DEBUG;
1437
- var debug5 = createDebugger("open-pioneer:codegen");
1522
+ var isDebug5 = !!process.env.DEBUG;
1523
+ var debug6 = createDebugger("open-pioneer:codegen");
1438
1524
  function codegenPlugin() {
1439
1525
  let isDev;
1440
1526
  let rootDir;
@@ -1471,7 +1557,7 @@ function codegenPlugin() {
1471
1557
  }
1472
1558
  let virtualModule;
1473
1559
  try {
1474
- virtualModule = RuntimeSupport.parseVirtualModule(moduleId);
1560
+ virtualModule = RuntimeSupport3.parseVirtualModule(moduleId);
1475
1561
  } catch (e) {
1476
1562
  this.error({
1477
1563
  id: moduleId,
@@ -1512,46 +1598,37 @@ function codegenPlugin() {
1512
1598
  id: VIRTUAL_ID_FILTER
1513
1599
  },
1514
1600
  async handler(moduleId) {
1515
- var _a, _b;
1601
+ var _a;
1516
1602
  try {
1517
1603
  const mod = parseVirtualModuleId(moduleId);
1518
1604
  if (!mod) {
1519
1605
  return void 0;
1520
1606
  }
1521
- isDebug4 && debug5("Loading virtual module %O", mod);
1607
+ isDebug5 && debug6("Loading virtual module %O", mod);
1522
1608
  if (mod.type === "deployment") {
1523
- return deploymentModule.onLoadModule();
1524
- }
1525
- const packageJsonPath = (_a = await this.resolve(mod.packageDirectory + "/package.json")) == null ? void 0 : _a.id;
1526
- if (!packageJsonPath) {
1527
- throw new ReportableError(
1528
- `Failed to resolve package.json in ${mod.packageDirectory}`
1529
- );
1530
- }
1531
- if (mod.type === "source-info") {
1532
- const packageName = await getPackageName(this, packageJsonPath);
1533
- return RuntimeSupport.generateSourceInfo(packageName, mod.modulePath);
1609
+ return jsModule(deploymentModule.onLoadModule());
1534
1610
  }
1611
+ const packageJsonPath = await resolvePackageJson(this, mod);
1535
1612
  if (mod.type === "package-hooks") {
1536
1613
  const directory = mod.packageDirectory;
1537
- const packageJsonPath2 = (_b = await this.resolve(directory + "/package.json")) == null ? void 0 : _b.id;
1614
+ const packageJsonPath2 = (_a = await this.resolve(directory + "/package.json")) == null ? void 0 : _a.id;
1538
1615
  if (!packageJsonPath2) {
1539
1616
  throw new ReportableError(
1540
1617
  `Failed to resolve package.json in ${directory}`
1541
1618
  );
1542
1619
  }
1543
1620
  const packageName = await getPackageName(this, packageJsonPath2);
1544
- const generatedSourceCode = RuntimeSupport.generateReactHooks(
1621
+ const generatedSourceCode = RuntimeSupport3.generateReactHooks(
1545
1622
  packageName,
1546
- RuntimeSupport.REACT_INTEGRATION_MODULE_ID
1623
+ RuntimeSupport3.REACT_INTEGRATION_MODULE_ID
1547
1624
  );
1548
- isDebug4 && debug5("Generated hooks code: %O", generatedSourceCode);
1549
- return generatedSourceCode;
1625
+ isDebug5 && debug6("Generated hooks code: %O", generatedSourceCode);
1626
+ return jsModule(generatedSourceCode);
1550
1627
  }
1551
- if (mod.type === "app-meta") {
1552
- return generateAppMetadata(
1553
- mod.packageDirectory,
1554
- RuntimeSupport.METADATA_MODULE_ID
1628
+ if (mod.type === "source-info") {
1629
+ const packageName = await getPackageName(this, packageJsonPath);
1630
+ return jsModule(
1631
+ RuntimeSupport3.generateSourceInfo(packageName, mod.modulePath)
1555
1632
  );
1556
1633
  }
1557
1634
  const ctx = createMetadataContextFromRolldown(this);
@@ -1559,39 +1636,56 @@ function codegenPlugin() {
1559
1636
  ctx,
1560
1637
  dirname4(packageJsonPath)
1561
1638
  );
1639
+ if (mod.type === "app-meta") {
1640
+ const runtimeVersion = appMetadata.runtimeMetadataVersion;
1641
+ isDebug5 && debug6("Generating app metadata for runtime version %s", runtimeVersion);
1642
+ const generatedSourceCode = generateAppMetadata(
1643
+ mod.packageDirectory,
1644
+ RuntimeSupport3.METADATA_MODULE_ID,
1645
+ runtimeVersion
1646
+ );
1647
+ return jsModule(generatedSourceCode);
1648
+ }
1562
1649
  switch (mod.type) {
1563
1650
  case "app-packages": {
1564
1651
  const generatedSourceCode = generatePackagesMetadata({
1565
1652
  appName: appMetadata.name,
1566
1653
  packages: appMetadata.packages
1567
1654
  });
1568
- isDebug4 && debug5("Generated app metadata: %O", generatedSourceCode);
1569
- return generatedSourceCode;
1655
+ isDebug5 && debug6("Generated app metadata: %O", generatedSourceCode);
1656
+ return jsModule(generatedSourceCode);
1570
1657
  }
1571
1658
  case "app-css": {
1572
1659
  const generatedSourceCode = generateCombinedCss(appMetadata.packages);
1573
- isDebug4 && debug5("Generated app css: %O", generatedSourceCode);
1574
- return generatedSourceCode;
1660
+ isDebug5 && debug6("Generated app css: %O", generatedSourceCode);
1661
+ return jsModule(generatedSourceCode);
1575
1662
  }
1576
1663
  case "app-i18n-index": {
1664
+ await validateI18nConfig(ctx, repository, appMetadata);
1577
1665
  const generatedSourceCode = generateI18nIndex(
1578
1666
  mod.packageDirectory,
1579
1667
  appMetadata.locales
1580
1668
  );
1581
- isDebug4 && debug5("Generated i18n lookup: %O", generatedSourceCode);
1582
- return generatedSourceCode;
1669
+ isDebug5 && debug6("Generated i18n lookup: %O", generatedSourceCode);
1670
+ return jsModule(generatedSourceCode);
1583
1671
  }
1584
1672
  case "app-i18n": {
1585
1673
  const generatedSourceCode = await generateI18nMessages({
1586
1674
  locale: mod.locale,
1587
1675
  appName: appMetadata.name,
1588
1676
  packages: appMetadata.packages,
1589
- loadI18n: (path) => {
1590
- return repository.getI18nFile(ctx, path);
1677
+ loadI18n: async (pkg2, filePath) => {
1678
+ ctx.addWatchFile(filePath);
1679
+ if (!await fileExists(filePath)) {
1680
+ throw new ReportableError(
1681
+ `I18n file at ${filePath} does not exist.`
1682
+ );
1683
+ }
1684
+ return repository.getI18nFile(ctx, filePath);
1591
1685
  }
1592
1686
  });
1593
- isDebug4 && debug5("Generated i18n messages: %O", generatedSourceCode);
1594
- return generatedSourceCode;
1687
+ isDebug5 && debug6("Generated i18n messages: %O", generatedSourceCode);
1688
+ return jsModule(generatedSourceCode);
1595
1689
  }
1596
1690
  default:
1597
1691
  assertNever(mod.type);
@@ -1602,7 +1696,7 @@ function codegenPlugin() {
1602
1696
  }
1603
1697
  },
1604
1698
  watchChange(id, _change) {
1605
- isDebug4 && debug5("File %s changed", id);
1699
+ isDebug5 && debug6("File %s changed", id);
1606
1700
  repository.onFileChanged(id);
1607
1701
  },
1608
1702
  generateBundle(_options, bundle) {
@@ -1610,6 +1704,14 @@ function codegenPlugin() {
1610
1704
  }
1611
1705
  };
1612
1706
  }
1707
+ async function resolvePackageJson(ctx, mod) {
1708
+ var _a;
1709
+ const path = (_a = await ctx.resolve(mod.packageDirectory + "/package.json")) == null ? void 0 : _a.id;
1710
+ if (!path) {
1711
+ throw new ReportableError(`Failed to resolve package.json in ${mod.packageDirectory}`);
1712
+ }
1713
+ return path;
1714
+ }
1613
1715
  async function configureDevOptimizer(userConfig, rootDir) {
1614
1716
  const trailsModules = await getOptimizeDepsIncludes(rootDir);
1615
1717
  return {
@@ -1630,8 +1732,8 @@ async function getOptimizeDepsIncludes(rootDir) {
1630
1732
  const serviceModule = pkg2.servicesModuleId;
1631
1733
  return serviceModule ? [serviceModule] : [];
1632
1734
  });
1633
- trailsModules.push(`${RuntimeSupport.RUNTIME_PACKAGE_NAME}/**`);
1634
- isDebug4 && debug5("Optimizing additional modules %O", trailsModules);
1735
+ trailsModules.push(`${RuntimeSupport3.RUNTIME_PACKAGE_NAME}/**`);
1736
+ isDebug5 && debug6("Optimizing additional modules %O", trailsModules);
1635
1737
  return trailsModules;
1636
1738
  }
1637
1739
  function createOptimizeDepsRolldownPlugin() {
@@ -1689,6 +1791,12 @@ async function getPackageName(ctx, packageJsonPath) {
1689
1791
  }
1690
1792
  return name;
1691
1793
  }
1794
+ function jsModule(code) {
1795
+ return {
1796
+ code,
1797
+ moduleType: "js"
1798
+ };
1799
+ }
1692
1800
  function getCauseMessages(error) {
1693
1801
  const causes = [];
1694
1802
  while (1) {