@open-pioneer/vite-plugin-pioneer 2.0.1 → 3.0.1

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/dist/index.js CHANGED
@@ -1,57 +1,25 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- pioneer: () => pioneer
34
- });
35
- module.exports = __toCommonJS(src_exports);
36
-
37
1
  // src/codegenPlugin.ts
38
- var import_node_fs2 = require("node:fs");
39
- var import_node_path3 = require("node:path");
40
- var import_vite4 = require("vite");
2
+ import { existsSync as existsSync2 } from "node:fs";
3
+ import { dirname as dirname3, join as join2 } from "node:path";
4
+ import { normalizePath as normalizePath4 } from "vite";
41
5
 
42
6
  // src/utils/debug.ts
43
- var import_debug = require("debug");
7
+ import pkg from "debug";
8
+ var { debug } = pkg;
44
9
  function createDebugger(namespace) {
45
- const logger = (0, import_debug.debug)(namespace);
10
+ const logger = debug(namespace);
46
11
  return function debugFunction(...args) {
47
12
  logger(...args);
48
13
  };
49
14
  }
50
15
 
51
- // src/codegen/generatePackagesMetadata.ts
52
- var import_generator = __toESM(require("@babel/generator"));
53
- var import_template = __toESM(require("@babel/template"));
54
- var nodes = __toESM(require("@babel/types"));
16
+ // src/utils/babelDeps.ts
17
+ import generateModule from "@babel/generator";
18
+ import templateModule from "@babel/template";
19
+ import nodesModule from "@babel/types";
20
+ var generate = generateModule.default || generateModule;
21
+ var template = templateModule.default || templateModule;
22
+ var nodes = nodesModule;
55
23
 
56
24
  // src/ReportableError.ts
57
25
  var ReportableError = class extends Error {
@@ -81,10 +49,10 @@ function cleanName(input) {
81
49
  }
82
50
 
83
51
  // src/codegen/generatePackagesMetadata.ts
84
- var SERVICE_IMPORT = import_template.default.statement(`
52
+ var SERVICE_IMPORT = template.statement(`
85
53
  import { %%SERVICE_NAME%% as %%IMPORT_NAME%% } from %%IMPORT_SOURCE%%;
86
54
  `);
87
- var PKG_OBJECT = import_template.default.expression(`
55
+ var PKG_OBJECT = template.expression(`
88
56
  {
89
57
  name: %%PACKAGE_NAME%%,
90
58
  services: %%PACKAGE_SERVICES%%,
@@ -92,7 +60,7 @@ var PKG_OBJECT = import_template.default.expression(`
92
60
  properties: %%PROPERTIES%%
93
61
  }
94
62
  `);
95
- var SERVICE_OBJECT = import_template.default.expression(`
63
+ var SERVICE_OBJECT = template.expression(`
96
64
  {
97
65
  name: %%SERVICE_NAME%%,
98
66
  clazz: %%SERVICE_IMPORT%%,
@@ -100,25 +68,25 @@ var SERVICE_OBJECT = import_template.default.expression(`
100
68
  references: %%SERVICE_REFERENCES%%
101
69
  }
102
70
  `);
103
- var INTERFACE_OBJECT = import_template.default.expression(`
71
+ var INTERFACE_OBJECT = template.expression(`
104
72
  {
105
73
  name: %%INTERFACE_NAME%%,
106
74
  qualifier: %%QUALIFIER%%
107
75
  }
108
76
  `);
109
- var REFERENCE_OBJECT = import_template.default.expression(`
77
+ var REFERENCE_OBJECT = template.expression(`
110
78
  {
111
79
  name: %%INTERFACE_NAME%%,
112
80
  qualifier: %%QUALIFIER%%,
113
81
  all: %%ALL%%
114
82
  }
115
83
  `);
116
- var UI_OBJECT = import_template.default.expression(`
84
+ var UI_OBJECT = template.expression(`
117
85
  {
118
86
  references: %%UI_REFERENCES%%
119
87
  }
120
88
  `);
121
- var PROPERTY_OBJECT = import_template.default.expression(`
89
+ var PROPERTY_OBJECT = template.expression(`
122
90
  {
123
91
  value: %%VALUE%%,
124
92
  required: %%REQUIRED%%
@@ -129,18 +97,18 @@ function generatePackagesMetadata({ appName, packages }) {
129
97
  const packagesMetadata = nodes.objectExpression([]);
130
98
  const imports = [];
131
99
  let overrides;
132
- for (const pkg of packages) {
133
- if (pkg.name === appName) {
134
- overrides = pkg.config.overrides;
135
- } else if (pkg.config.overrides) {
100
+ for (const pkg2 of packages) {
101
+ if (pkg2.name === appName) {
102
+ overrides = pkg2.config.overrides;
103
+ } else if (pkg2.config.overrides) {
136
104
  throw new ReportableError(
137
- `Unexpected 'overrides' in package '${pkg.name}'. Overrides are only supported in the app.`
105
+ `Unexpected 'overrides' in package '${pkg2.name}'. Overrides are only supported in the app.`
138
106
  );
139
107
  }
140
108
  }
141
- for (const pkg of packages) {
142
- const packageOverrides = overrides == null ? void 0 : overrides.get(pkg.name);
143
- const packageMetadata = generatePackageMetadata(pkg, {
109
+ for (const pkg2 of packages) {
110
+ const packageOverrides = overrides == null ? void 0 : overrides.get(pkg2.name);
111
+ const packageMetadata = generatePackageMetadata(pkg2, {
144
112
  enableService(serviceName) {
145
113
  var _a, _b;
146
114
  return ((_b = (_a = packageOverrides == null ? void 0 : packageOverrides.services) == null ? void 0 : _a.get(serviceName)) == null ? void 0 : _b.enabled) ?? true;
@@ -157,28 +125,28 @@ function generatePackagesMetadata({ appName, packages }) {
157
125
  }
158
126
  });
159
127
  packagesMetadata.properties.push(
160
- nodes.objectProperty(nodes.stringLiteral(pkg.name), packageMetadata)
128
+ nodes.objectProperty(nodes.stringLiteral(pkg2.name), packageMetadata)
161
129
  );
162
130
  }
163
- const program2 = nodes.program([...imports, nodes.exportDefaultDeclaration(packagesMetadata)]);
164
- return (0, import_generator.default)(program2).code;
131
+ const program = nodes.program([...imports, nodes.exportDefaultDeclaration(packagesMetadata)]);
132
+ return generate(program).code;
165
133
  }
166
- function generatePackageMetadata(pkg, options) {
134
+ function generatePackageMetadata(pkg2, options) {
167
135
  const servicesObject = nodes.objectExpression([]);
168
- for (const service of pkg.config.services.values()) {
136
+ for (const service of pkg2.config.services.values()) {
169
137
  if (!options.enableService(service.serviceName)) {
170
138
  continue;
171
139
  }
172
- if (!pkg.servicesModulePath) {
140
+ if (!pkg2.servicesModulePath) {
173
141
  throw new ReportableError(
174
- `Package '${pkg.name}' must have a valid services module (typically 'services.ts' or 'services.js').
142
+ `Package '${pkg2.name}' must have a valid services module (typically 'services.ts' or 'services.js').
175
143
  The entry point can be configured by setting the 'servicesModule' property in the build.config.mjs.`
176
144
  );
177
145
  }
178
146
  const importName = options.importServiceClass(
179
- pkg.name + "_" + service.serviceName,
147
+ pkg2.name + "_" + service.serviceName,
180
148
  service.serviceName,
181
- pkg.servicesModulePath
149
+ pkg2.servicesModulePath
182
150
  );
183
151
  const serviceObject = SERVICE_OBJECT({
184
152
  SERVICE_NAME: nodes.stringLiteral(service.serviceName),
@@ -205,10 +173,10 @@ The entry point can be configured by setting the 'servicesModule' property in th
205
173
  );
206
174
  }
207
175
  const uiObject = UI_OBJECT({
208
- UI_REFERENCES: nodes.arrayExpression(pkg.config.uiReferences.map((r) => referenceObject(r)))
176
+ UI_REFERENCES: nodes.arrayExpression(pkg2.config.uiReferences.map((r) => referenceObject(r)))
209
177
  });
210
178
  const propertiesObject = nodes.objectExpression(
211
- Array.from(pkg.config.properties.values()).map(
179
+ Array.from(pkg2.config.properties.values()).map(
212
180
  (prop) => nodes.objectProperty(
213
181
  nodes.stringLiteral(prop.propertyName),
214
182
  PROPERTY_OBJECT({
@@ -219,7 +187,7 @@ The entry point can be configured by setting the 'servicesModule' property in th
219
187
  )
220
188
  );
221
189
  const pkgObject = PKG_OBJECT({
222
- PACKAGE_NAME: nodes.stringLiteral(pkg.name),
190
+ PACKAGE_NAME: nodes.stringLiteral(pkg2.name),
223
191
  PACKAGE_SERVICES: servicesObject,
224
192
  PACKAGE_UI: uiObject,
225
193
  PROPERTIES: propertiesObject
@@ -264,9 +232,11 @@ function undefinedNode() {
264
232
  }
265
233
 
266
234
  // src/metadata/MetadataRepository.ts
267
- var import_promises3 = require("fs/promises");
268
- var import_path = require("path");
269
- var import_vite2 = require("vite");
235
+ import { BUILD_CONFIG_NAME as BUILD_CONFIG_NAME2 } from "@open-pioneer/build-common";
236
+ import { realpath } from "fs/promises";
237
+ import { basename, dirname } from "path";
238
+ import { normalizePath as normalizePath2 } from "vite";
239
+ import { findDepPkgJsonPath } from "vitefu";
270
240
 
271
241
  // src/utils/Cache.ts
272
242
  var Cache = class {
@@ -333,111 +303,38 @@ var Cache = class {
333
303
  }
334
304
  };
335
305
 
336
- // src/metadata/parseI18nYaml.ts
337
- var import_promises = require("fs/promises");
338
- var import_js_yaml = require("js-yaml");
339
- var import_zod = require("zod");
340
- var import_zod_validation_error = require("zod-validation-error");
341
- var MESSAGES_SCHEMA = import_zod.z.lazy(
342
- () => import_zod.z.record(import_zod.z.union([import_zod.z.string(), MESSAGES_SCHEMA])).nullish()
343
- );
344
- var I18N_SCHEMA = import_zod.z.strictObject({
345
- messages: MESSAGES_SCHEMA.nullish().optional(),
346
- overrides: import_zod.z.record(MESSAGES_SCHEMA).nullish().optional()
347
- }).nullish();
348
- async function loadI18nFile(path) {
349
- let content;
350
- try {
351
- content = await (0, import_promises.readFile)(path, "utf-8");
352
- } catch (e) {
353
- throw new ReportableError(`Failed to read ${path}`, { cause: e });
354
- }
355
- try {
356
- return parseI18nYaml(content);
357
- } catch (e) {
358
- throw new ReportableError(`Failed to parse ${path}`, { cause: e });
359
- }
360
- }
361
- function parseI18nYaml(yaml) {
362
- const data = (0, import_js_yaml.load)(yaml);
363
- return parseI18nFile(data);
364
- }
365
- function parseI18nFile(data) {
366
- const result = I18N_SCHEMA.safeParse(data);
367
- if (!result.success) {
368
- throw (0, import_zod_validation_error.fromZodError)(result.error);
369
- }
370
- const rawI18n = result.data;
371
- const messages = gatherMessages((rawI18n == null ? void 0 : rawI18n.messages) ?? void 0);
372
- let overrides;
373
- if (typeof (rawI18n == null ? void 0 : rawI18n.overrides) === "object") {
374
- overrides = gatherOverrides((rawI18n == null ? void 0 : rawI18n.overrides) ?? void 0);
375
- }
376
- return { messages, overrides };
377
- }
378
- function gatherMessages(data) {
379
- const messages = /* @__PURE__ */ new Map();
380
- const prefix = [];
381
- const visitChildren = (record) => {
382
- for (const [key, value] of Object.entries(record)) {
383
- if (typeof value === "string") {
384
- visitMessage(key, value);
385
- } else if (value) {
386
- prefix.push(key);
387
- visitChildren(value);
388
- prefix.pop();
389
- }
390
- }
391
- };
392
- const visitMessage = (key, message) => {
393
- const id = [...prefix, key].join(".");
394
- if (messages.has(id)) {
395
- throw new Error(`Message '${id}' was already defined.`);
396
- }
397
- messages.set(id, message);
398
- };
399
- if (data) {
400
- visitChildren(data);
401
- }
402
- return messages;
403
- }
404
- function gatherOverrides(data) {
405
- const overrides = /* @__PURE__ */ new Map();
406
- if (data) {
407
- for (const [key, value] of Object.entries(data)) {
408
- const messages = gatherMessages(value ?? void 0);
409
- overrides.set(key, messages);
410
- }
411
- }
412
- return overrides;
413
- }
414
-
415
306
  // src/metadata/loadPackageMetadata.ts
416
- var import_promises2 = require("node:fs/promises");
307
+ import { readFile } from "node:fs/promises";
417
308
 
418
309
  // src/utils/fileUtils.ts
419
- var fs = __toESM(require("node:fs"));
420
- var import_node_path = require("node:path");
310
+ import * as fs from "node:fs";
311
+ import { isAbsolute, relative } from "node:path";
421
312
  function fileExists(file) {
422
313
  return fs.promises.access(file, fs.constants.F_OK).then(() => true).catch(() => false);
423
314
  }
424
315
  function isInDirectory(candidate, directory) {
425
- const rel = (0, import_node_path.relative)(directory, candidate);
426
- const isChild = rel && !rel.startsWith("..") && !(0, import_node_path.isAbsolute)(rel);
316
+ const rel = relative(directory, candidate);
317
+ const isChild = rel && !rel.startsWith("..") && !isAbsolute(rel);
427
318
  return !!isChild;
428
319
  }
429
320
 
430
321
  // src/metadata/loadPackageMetadata.ts
431
- var import_build_common = require("@open-pioneer/build-common");
432
- var import_vite = require("vite");
433
- var import_node_path2 = require("node:path");
322
+ import {
323
+ BUILD_CONFIG_NAME,
324
+ PackageMetadataV1,
325
+ createPackageConfigFromBuildConfig,
326
+ createPackageConfigFromPackageMetadata,
327
+ loadBuildConfig
328
+ } from "@open-pioneer/build-common";
329
+ import { normalizePath } from "vite";
330
+ import { join } from "node:path";
434
331
 
435
332
  // src/utils/package.ts
436
333
  var PACKAGE_NAME = "@open-pioneer/vite-plugin-pioneer";
437
334
 
438
335
  // src/metadata/loadPackageMetadata.ts
439
- var import_node_fs = require("node:fs");
440
- var import_posix = __toESM(require("node:path/posix"));
336
+ import { existsSync } from "node:fs";
337
+ import posix from "node:path/posix";
441
338
  var isDebug = !!process.env.DEBUG;
442
339
  var debug2 = createDebugger("open-pioneer:metadata");
443
340
  async function loadPackageMetadata(ctx, packageDir, sourceRoot, importedFrom) {
@@ -458,7 +355,7 @@ var PackageMetadataReader = class {
458
355
  this.ctx = ctx;
459
356
  this.packageDir = packageDir;
460
357
  this.sourceRoot = sourceRoot;
461
- this.packageJsonPath = (0, import_node_path2.join)(packageDir, "package.json");
358
+ this.packageJsonPath = join(packageDir, "package.json");
462
359
  this.importedFrom = importedFrom;
463
360
  }
464
361
  /**
@@ -516,12 +413,12 @@ var PackageMetadataReader = class {
516
413
  if (i18nPaths.has(locale)) {
517
414
  throw new ReportableError(`Locale '${locale}' was defined twice in ${configPath}`);
518
415
  }
519
- const path = (0, import_node_path2.join)(packageDir, "i18n", `${locale}.yaml`);
416
+ const path = join(packageDir, "i18n", `${locale}.yaml`);
520
417
  ctx.addWatchFile(path);
521
418
  if (!await fileExists(path)) {
522
419
  throw new ReportableError(`i18n file '${path}' does not exist.`);
523
420
  }
524
- i18nPaths.set(locale, (0, import_vite.normalizePath)(path));
421
+ i18nPaths.set(locale, normalizePath(path));
525
422
  }
526
423
  return {
527
424
  type: "pioneer-package",
@@ -549,16 +446,16 @@ var PackageMetadataReader = class {
549
446
  return this.parsePackageConfigFromMetadata(packageName, frameworkMetadata);
550
447
  }
551
448
  case "local": {
552
- const buildConfigPath = (0, import_node_path2.join)(packageDir, import_build_common.BUILD_CONFIG_NAME);
553
- const buildConfigExists = (0, import_node_fs.existsSync)(buildConfigPath);
449
+ const buildConfigPath = join(packageDir, BUILD_CONFIG_NAME);
450
+ const buildConfigExists = existsSync(buildConfigPath);
554
451
  if (buildConfigExists && frameworkMetadata) {
555
452
  throw new Error(
556
- `Package '${packageName}' at ${packageDir} contains both framework metadata in its package.json and a ${import_build_common.BUILD_CONFIG_NAME}. Mixing both formats is not supported. Metadata in package.json files is only intended for distributed packages.`
453
+ `Package '${packageName}' at ${packageDir} contains both framework metadata in its package.json and a ${BUILD_CONFIG_NAME}. Mixing both formats is not supported. Metadata in package.json files is only intended for distributed packages.`
557
454
  );
558
455
  }
559
456
  if (frameworkMetadata) {
560
457
  ctx.warn(
561
- `Using framework metadata from package.json instead of ${import_build_common.BUILD_CONFIG_NAME} in ${packageDir}, make sure that this intended.`
458
+ `Using framework metadata from package.json instead of ${BUILD_CONFIG_NAME} in ${packageDir}, make sure that this intended.`
562
459
  );
563
460
  return this.parsePackageConfigFromMetadata(packageName, frameworkMetadata);
564
461
  }
@@ -573,18 +470,18 @@ var PackageMetadataReader = class {
573
470
  const localServicesModule = config.servicesModule ?? "./services";
574
471
  const importedFrom = this.importedFrom;
575
472
  if (mode === "external" && importedFrom) {
576
- return import_posix.default.join(packageName, localServicesModule);
473
+ return posix.join(packageName, localServicesModule);
577
474
  } else {
578
475
  return await resolveLocalFile(this.ctx, this.packageDir, localServicesModule);
579
476
  }
580
477
  }
581
478
  /**
582
479
  * Attempts to read the package configuration from the package.json's metadata value.
583
- * Note that the value may not be present at this point if the package does not use open pioneer metadata.
480
+ * Note that the value may not be present at this point if the package does not use Open Pioneer Trails metadata.
584
481
  */
585
482
  async parsePackageConfigFromMetadata(packageName, frameworkMetadata) {
586
483
  const { packageDir, packageJsonPath } = this;
587
- const metadataResult = import_build_common.PackageMetadataV1.parsePackageMetadata(frameworkMetadata);
484
+ const metadataResult = PackageMetadataV1.parsePackageMetadata(frameworkMetadata);
588
485
  if (metadataResult.type === "error") {
589
486
  if (metadataResult.code === "unsupported-version") {
590
487
  throw new ReportableError(
@@ -601,27 +498,27 @@ var PackageMetadataReader = class {
601
498
  }
602
499
  return {
603
500
  configPath: packageJsonPath,
604
- config: (0, import_build_common.createPackageConfigFromPackageMetadata)(metadataResult.value)
501
+ config: createPackageConfigFromPackageMetadata(metadataResult.value)
605
502
  };
606
503
  }
607
504
  async parsePackageConfigFromBuildConfig(buildConfigPath) {
608
505
  const { ctx, packageDir } = this;
609
506
  let buildConfig;
610
- ctx.addWatchFile((0, import_vite.normalizePath)(buildConfigPath));
507
+ ctx.addWatchFile(normalizePath(buildConfigPath));
611
508
  if (await fileExists(buildConfigPath)) {
612
509
  try {
613
- buildConfig = await (0, import_build_common.loadBuildConfig)(buildConfigPath);
510
+ buildConfig = await loadBuildConfig(buildConfigPath);
614
511
  } catch (e) {
615
512
  throw new ReportableError(`Failed to load build config ${buildConfigPath}`, {
616
513
  cause: e
617
514
  });
618
515
  }
619
516
  } else {
620
- throw new ReportableError(`Expected a ${import_build_common.BUILD_CONFIG_NAME} in ${packageDir}`);
517
+ throw new ReportableError(`Expected a ${BUILD_CONFIG_NAME} in ${packageDir}`);
621
518
  }
622
519
  return {
623
520
  configPath: buildConfigPath,
624
- config: (0, import_build_common.createPackageConfigFromBuildConfig)(buildConfig)
521
+ config: createPackageConfigFromBuildConfig(buildConfig)
625
522
  };
626
523
  }
627
524
  };
@@ -632,7 +529,7 @@ async function parsePackageJson(packageJsonPath) {
632
529
  }
633
530
  let packageJsonContent;
634
531
  try {
635
- packageJsonContent = JSON.parse(await (0, import_promises2.readFile)(packageJsonPath, "utf-8"));
532
+ packageJsonContent = JSON.parse(await readFile(packageJsonPath, "utf-8"));
636
533
  } catch (e) {
637
534
  throw new ReportableError(`Failed to read ${packageJsonPath}`, { cause: e });
638
535
  }
@@ -682,7 +579,7 @@ async function parsePackageJson(packageJsonPath) {
682
579
  for (const depName of Object.keys(optionalDependencies)) {
683
580
  addDep(depName, true);
684
581
  }
685
- const frameworkMetadata = packageJsonContent[import_build_common.PackageMetadataV1.PACKAGE_JSON_KEY] ?? void 0;
582
+ const frameworkMetadata = packageJsonContent[PackageMetadataV1.PACKAGE_JSON_KEY] ?? void 0;
686
583
  return {
687
584
  name: packageName,
688
585
  version: version ?? void 0,
@@ -704,8 +601,86 @@ function isLocalPackage(file, sourceDir) {
704
601
  return isInDirectory(file, sourceDir) && !NODE_MODULES_RE.test(file);
705
602
  }
706
603
 
604
+ // src/metadata/parseI18nYaml.ts
605
+ import { readFile as readFile2 } from "fs/promises";
606
+ import { load as loadYaml } from "js-yaml";
607
+ import { z } from "zod";
608
+ import { fromZodError } from "zod-validation-error";
609
+ var MESSAGES_SCHEMA = z.lazy(
610
+ () => z.record(z.union([z.string(), MESSAGES_SCHEMA])).nullish()
611
+ );
612
+ var I18N_SCHEMA = z.strictObject({
613
+ messages: MESSAGES_SCHEMA.nullish().optional(),
614
+ overrides: z.record(MESSAGES_SCHEMA).nullish().optional()
615
+ }).nullish();
616
+ async function loadI18nFile(path) {
617
+ let content;
618
+ try {
619
+ content = await readFile2(path, "utf-8");
620
+ } catch (e) {
621
+ throw new ReportableError(`Failed to read ${path}`, { cause: e });
622
+ }
623
+ try {
624
+ return parseI18nYaml(content);
625
+ } catch (e) {
626
+ throw new ReportableError(`Failed to parse ${path}`, { cause: e });
627
+ }
628
+ }
629
+ function parseI18nYaml(yaml) {
630
+ const data = loadYaml(yaml);
631
+ return parseI18nFile(data);
632
+ }
633
+ function parseI18nFile(data) {
634
+ const result = I18N_SCHEMA.safeParse(data);
635
+ if (!result.success) {
636
+ throw fromZodError(result.error);
637
+ }
638
+ const rawI18n = result.data;
639
+ const messages = gatherMessages((rawI18n == null ? void 0 : rawI18n.messages) ?? void 0);
640
+ let overrides;
641
+ if (typeof (rawI18n == null ? void 0 : rawI18n.overrides) === "object") {
642
+ overrides = gatherOverrides((rawI18n == null ? void 0 : rawI18n.overrides) ?? void 0);
643
+ }
644
+ return { messages, overrides };
645
+ }
646
+ function gatherMessages(data) {
647
+ const messages = /* @__PURE__ */ new Map();
648
+ const prefix = [];
649
+ const visitChildren = (record) => {
650
+ for (const [key, value] of Object.entries(record)) {
651
+ if (typeof value === "string") {
652
+ visitMessage(key, value);
653
+ } else if (value) {
654
+ prefix.push(key);
655
+ visitChildren(value);
656
+ prefix.pop();
657
+ }
658
+ }
659
+ };
660
+ const visitMessage = (key, message) => {
661
+ const id = [...prefix, key].join(".");
662
+ if (messages.has(id)) {
663
+ throw new Error(`Message '${id}' was already defined.`);
664
+ }
665
+ messages.set(id, message);
666
+ };
667
+ if (data) {
668
+ visitChildren(data);
669
+ }
670
+ return messages;
671
+ }
672
+ function gatherOverrides(data) {
673
+ const overrides = /* @__PURE__ */ new Map();
674
+ if (data) {
675
+ for (const [key, value] of Object.entries(data)) {
676
+ const messages = gatherMessages(value ?? void 0);
677
+ overrides.set(key, messages);
678
+ }
679
+ }
680
+ return overrides;
681
+ }
682
+
707
683
  // src/metadata/MetadataRepository.ts
708
- var import_build_common2 = require("@open-pioneer/build-common");
709
684
  var isDebug2 = !!process.env.DEBUG;
710
685
  var debug3 = createDebugger("open-pioneer:metadata");
711
686
  var MetadataRepository = class {
@@ -715,8 +690,6 @@ var MetadataRepository = class {
715
690
  // Cache for the contents of i18n files.
716
691
  // Key: path on disk.
717
692
  i18nCache;
718
- // Cache for package locations & package.json contents
719
- packageDataCache = /* @__PURE__ */ new Map();
720
693
  /**
721
694
  * @param sourceRoot Source folder on disk, needed to detect 'local' packages
722
695
  */
@@ -728,7 +701,6 @@ var MetadataRepository = class {
728
701
  reset() {
729
702
  this.packageMetadataCache = this.createPackageMetadataCache();
730
703
  this.i18nCache = this.createI18nCache();
731
- this.packageDataCache.clear();
732
704
  }
733
705
  /**
734
706
  * Called by the plugin when a file has been changed.
@@ -736,7 +708,7 @@ var MetadataRepository = class {
736
708
  */
737
709
  onFileChanged(path) {
738
710
  if (isPackageJson(path) || isBuildConfig(path)) {
739
- this.packageMetadataCache.invalidate((0, import_path.dirname)(path));
711
+ this.packageMetadataCache.invalidate(dirname(path));
740
712
  }
741
713
  this.i18nCache.invalidate(path);
742
714
  }
@@ -829,17 +801,11 @@ var MetadataRepository = class {
829
801
  }
830
802
  async resolvePackageLocation(loc) {
831
803
  if (loc.type === "absolute") {
832
- return await (0, import_promises3.realpath)(loc.directory);
804
+ return await realpath(loc.directory);
833
805
  }
834
806
  const { packageName, optional } = loc.dependency;
835
- const { resolvePackageData } = await import("vite");
836
- const packageData = await resolvePackageData(
837
- packageName,
838
- loc.importedFrom,
839
- false,
840
- this.packageDataCache
841
- );
842
- if (!packageData) {
807
+ const packagePath = await findDepPkgJsonPath(packageName, loc.importedFrom);
808
+ if (!packagePath) {
843
809
  if (optional) {
844
810
  isDebug2 && debug3(`Optional package '${packageName}' was not found.`);
845
811
  return void 0;
@@ -848,14 +814,14 @@ var MetadataRepository = class {
848
814
  `Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`
849
815
  );
850
816
  }
851
- const packageDir = await (0, import_promises3.realpath)(packageData.dir);
817
+ const packageDir = dirname(await realpath(packagePath));
852
818
  isDebug2 && debug3(`Found package '${packageName}' at ${packageDir}`);
853
819
  return packageDir;
854
820
  }
855
821
  createI18nCache() {
856
822
  return new Cache({
857
823
  getId(path) {
858
- return (0, import_vite2.normalizePath)(path);
824
+ return normalizePath2(path);
859
825
  },
860
826
  async getValue(path, ctx) {
861
827
  isDebug2 && debug3(`Loading i18n file ${path}`);
@@ -879,7 +845,7 @@ var MetadataRepository = class {
879
845
  const provider = {
880
846
  _byName: /* @__PURE__ */ new Map(),
881
847
  getId(directory) {
882
- return (0, import_vite2.normalizePath)(directory);
848
+ return normalizePath2(directory);
883
849
  },
884
850
  async getValue(directory, ctx, importedFrom) {
885
851
  isDebug2 && debug3(
@@ -903,9 +869,9 @@ var MetadataRepository = class {
903
869
  isDebug2 && debug3(`Metadata for '${metadata.name}': %O`, metadata);
904
870
  if (metadata.type === "pioneer-package") {
905
871
  const existingMetadata = this._byName.get(metadata.name);
906
- if (existingMetadata && (0, import_vite2.normalizePath)(existingMetadata.directory) !== (0, import_vite2.normalizePath)(metadata.directory)) {
872
+ if (existingMetadata && normalizePath2(existingMetadata.directory) !== normalizePath2(metadata.directory)) {
907
873
  const message = `Encountered the package '${metadata.name}' at two different locations.
908
- Pioneer packages cannot be used more than once in the same application.
874
+ Trails packages cannot be used more than once in the same application.
909
875
  All packages must use a common version of '${metadata.name}'.
910
876
 
911
877
  1. ${formatPackage(existingMetadata)}
@@ -954,7 +920,7 @@ function isPackageJson(file) {
954
920
  return PACKAGE_JSON_RE.test(file);
955
921
  }
956
922
  function isBuildConfig(file) {
957
- return (0, import_path.basename)(file) === import_build_common2.BUILD_CONFIG_NAME;
923
+ return basename(file) === BUILD_CONFIG_NAME2;
958
924
  }
959
925
  function formatPackage(packageMetadata) {
960
926
  let str = `${packageMetadata.name}`;
@@ -968,12 +934,12 @@ function formatPackage(packageMetadata) {
968
934
  // src/codegen/generateCombinedCss.ts
969
935
  function generateCombinedCss(packages) {
970
936
  const cssImport = (file) => `@import ${JSON.stringify(file)};`;
971
- return packages.filter((pkg) => !!pkg.cssFilePath).map((pkg) => cssImport(pkg.cssFilePath)).join("\n");
937
+ return packages.filter((pkg2) => !!pkg2.cssFilePath).map((pkg2) => cssImport(pkg2.cssFilePath)).join("\n");
972
938
  }
973
939
 
974
940
  // src/codegen/shared.ts
975
- var import_posix2 = require("node:path/posix");
976
- var import_vite3 = require("vite");
941
+ import { dirname as dirname2, basename as basename2 } from "node:path/posix";
942
+ import { normalizePath as normalizePath3 } from "vite";
977
943
  var APP_MODULE = "@@open-pioneer-app";
978
944
  var APP_META_QUERY = "open-pioneer-app";
979
945
  var APP_META_RE = /[?&]open-pioneer-app(?:$|&)/;
@@ -989,7 +955,7 @@ var APP_I18N_LOCALE_RE = /[?&]locale=(?<locale>.*?)(?:$|&)/;
989
955
  var PACKAGE_HOOKS_MODULE = "@@open-pioneer-react-hooks";
990
956
  var SOURCE_FILE_RE = /^(.*?)(?:\?|$)/;
991
957
  function parseVirtualModuleId(inputModuleId) {
992
- const moduleId = (0, import_vite3.normalizePath)(inputModuleId);
958
+ const moduleId = normalizePath3(inputModuleId);
993
959
  if (!moduleId || moduleId.includes("\\0")) {
994
960
  return void 0;
995
961
  }
@@ -997,11 +963,11 @@ function parseVirtualModuleId(inputModuleId) {
997
963
  if (!sourceFile) {
998
964
  return void 0;
999
965
  }
1000
- const base = (0, import_posix2.basename)(sourceFile);
966
+ const base = basename2(sourceFile);
1001
967
  if (base === PACKAGE_HOOKS_MODULE) {
1002
968
  return {
1003
969
  type: "package-hooks",
1004
- packageDirectory: (0, import_posix2.dirname)(sourceFile)
970
+ packageDirectory: dirname2(sourceFile)
1005
971
  };
1006
972
  }
1007
973
  if (base === APP_MODULE) {
@@ -1011,7 +977,7 @@ function parseVirtualModuleId(inputModuleId) {
1011
977
  }
1012
978
  function parseAppModuleId(sourceFile, moduleId) {
1013
979
  var _a, _b;
1014
- const packageDirectory = (0, import_posix2.dirname)(sourceFile);
980
+ const packageDirectory = dirname2(sourceFile);
1015
981
  if (moduleId.match(APP_META_RE)) {
1016
982
  const type = "app-meta";
1017
983
  return { type, packageDirectory };
@@ -1097,13 +1063,10 @@ export {
1097
1063
  }
1098
1064
 
1099
1065
  // src/codegenPlugin.ts
1100
- var import_promises4 = require("node:fs/promises");
1066
+ import { readFile as readFile3 } from "node:fs/promises";
1101
1067
 
1102
1068
  // src/codegen/generateI18n.ts
1103
- var nodes2 = __toESM(require("@babel/types"));
1104
- var import_template2 = __toESM(require("@babel/template"));
1105
- var import_generator2 = __toESM(require("@babel/generator"));
1106
- var INDEX_TEMPLATE = import_template2.default.program(`
1069
+ var INDEX_TEMPLATE = template.program(`
1107
1070
  export const locales = %%LOCALES_ARRAY%%;
1108
1071
 
1109
1072
  export function loadMessages(locale) {
@@ -1111,19 +1074,19 @@ var INDEX_TEMPLATE = import_template2.default.program(`
1111
1074
  throw new Error(\`Unsupported locale: '\${locale}'\`);
1112
1075
  }
1113
1076
  `);
1114
- var IMPORT_TEMPLATE = import_template2.default.statement(`
1077
+ var IMPORT_TEMPLATE = template.statement(`
1115
1078
  return import(%%MODULE_ID%%).then(mod => mod.default);
1116
1079
  `);
1117
- var MESSAGES_TEMPLATE = import_template2.default.program(`
1080
+ var MESSAGES_TEMPLATE = template.program(`
1118
1081
  const messages = JSON.parse(%%SERIALIZED%%);
1119
1082
  export default messages;
1120
1083
  `);
1121
1084
  function generateI18nIndex(packageDirectory, locales) {
1122
- const localesArray = nodes2.arrayExpression(
1123
- locales.map((locale) => nodes2.stringLiteral(locale))
1085
+ const localesArray = nodes.arrayExpression(
1086
+ locales.map((locale) => nodes.stringLiteral(locale))
1124
1087
  );
1125
- const switchStmt = nodes2.switchStatement(
1126
- nodes2.identifier("locale"),
1088
+ const switchStmt = nodes.switchStatement(
1089
+ nodes.identifier("locale"),
1127
1090
  locales.map((locale) => {
1128
1091
  const localeModuleId = serializeModuleId({
1129
1092
  type: "app-i18n",
@@ -1131,39 +1094,39 @@ function generateI18nIndex(packageDirectory, locales) {
1131
1094
  locale
1132
1095
  });
1133
1096
  const importStatement = IMPORT_TEMPLATE({
1134
- MODULE_ID: nodes2.stringLiteral(localeModuleId)
1097
+ MODULE_ID: nodes.stringLiteral(localeModuleId)
1135
1098
  });
1136
- return nodes2.switchCase(nodes2.stringLiteral(locale), [importStatement]);
1099
+ return nodes.switchCase(nodes.stringLiteral(locale), [importStatement]);
1137
1100
  })
1138
1101
  );
1139
- const program2 = INDEX_TEMPLATE({
1102
+ const program = INDEX_TEMPLATE({
1140
1103
  LOCALES_ARRAY: localesArray,
1141
1104
  LOCALE_SWITCH: switchStmt
1142
1105
  });
1143
- return (0, import_generator2.default)(program2).code;
1106
+ return generate(program).code;
1144
1107
  }
1145
1108
  async function generateI18nMessages(options) {
1146
1109
  const { locale, appName, packages, loadI18n } = options;
1147
1110
  const packageMessages = /* @__PURE__ */ new Map();
1148
1111
  const packagesNeedingMessages = /* @__PURE__ */ new Set();
1149
1112
  let packageOverrides;
1150
- for (const pkg of packages) {
1151
- if (pkg.i18nPaths.size !== 0) {
1152
- packagesNeedingMessages.add(pkg.name);
1113
+ for (const pkg2 of packages) {
1114
+ if (pkg2.i18nPaths.size !== 0) {
1115
+ packagesNeedingMessages.add(pkg2.name);
1153
1116
  }
1154
- const filePath = pkg.i18nPaths.get(locale);
1117
+ const filePath = pkg2.i18nPaths.get(locale);
1155
1118
  if (!filePath) {
1156
1119
  continue;
1157
1120
  }
1158
1121
  const { messages, overrides } = await loadI18n(filePath);
1159
- if (pkg.name === appName) {
1122
+ if (pkg2.name === appName) {
1160
1123
  packageOverrides = overrides;
1161
1124
  } else if (overrides) {
1162
1125
  throw new ReportableError(
1163
1126
  `Unexpected 'overrides' block in '${filePath}'. Overrides are only supported in the app.`
1164
1127
  );
1165
1128
  }
1166
- packageMessages.set(pkg.name, messages);
1129
+ packageMessages.set(pkg2.name, messages);
1167
1130
  }
1168
1131
  if (packageOverrides) {
1169
1132
  for (const [packageName, messages] of packageOverrides.entries()) {
@@ -1189,14 +1152,14 @@ async function generateI18nMessages(options) {
1189
1152
  allMessages[packageName] = Object.fromEntries(messages.entries());
1190
1153
  }
1191
1154
  const serialized = JSON.stringify(allMessages);
1192
- const program2 = MESSAGES_TEMPLATE({
1193
- SERIALIZED: nodes2.stringLiteral(serialized)
1155
+ const program = MESSAGES_TEMPLATE({
1156
+ SERIALIZED: nodes.stringLiteral(serialized)
1194
1157
  });
1195
- return (0, import_generator2.default)(program2).code;
1158
+ return generate(program).code;
1196
1159
  }
1197
1160
 
1198
1161
  // src/codegenPlugin.ts
1199
- var import_build_common3 = require("@open-pioneer/build-common");
1162
+ import { RuntimeSupport } from "@open-pioneer/build-common";
1200
1163
  var isDebug3 = !!process.env.DEBUG;
1201
1164
  var debug4 = createDebugger("open-pioneer:codegen");
1202
1165
  function codegenPlugin() {
@@ -1218,7 +1181,7 @@ function codegenPlugin() {
1218
1181
  configureServer(server) {
1219
1182
  devServer = server;
1220
1183
  server.watcher.on("all", (_, path) => {
1221
- const moduleIds = manualDeps.get((0, import_vite4.normalizePath)(path));
1184
+ const moduleIds = manualDeps.get(normalizePath4(path));
1222
1185
  if (!moduleIds) {
1223
1186
  return;
1224
1187
  }
@@ -1244,18 +1207,18 @@ function codegenPlugin() {
1244
1207
  return moduleId;
1245
1208
  }
1246
1209
  const getPackageDirectory = () => {
1247
- const packageJsonPath = findPackageJson((0, import_node_path3.dirname)(importer), config.root);
1210
+ const packageJsonPath = findPackageJson(dirname3(importer), config.root);
1248
1211
  if (!packageJsonPath) {
1249
1212
  throw new ReportableError(
1250
1213
  `Failed to find package.json for package from '${importer}'.`
1251
1214
  );
1252
1215
  }
1253
- const packageDir = (0, import_node_path3.dirname)(packageJsonPath);
1254
- return (0, import_vite4.normalizePath)(packageDir);
1216
+ const packageDir = dirname3(packageJsonPath);
1217
+ return normalizePath4(packageDir);
1255
1218
  };
1256
1219
  let virtualModule;
1257
1220
  try {
1258
- virtualModule = import_build_common3.RuntimeSupport.parseVirtualModule(moduleId);
1221
+ virtualModule = RuntimeSupport.parseVirtualModule(moduleId);
1259
1222
  } catch (e) {
1260
1223
  this.error({
1261
1224
  id: moduleId,
@@ -1300,9 +1263,9 @@ function codegenPlugin() {
1300
1263
  throw new ReportableError(`Failed to resolve package.json in ${directory}`);
1301
1264
  }
1302
1265
  const packageName = await getPackageName(this, packageJsonPath2);
1303
- const generatedSourceCode = import_build_common3.RuntimeSupport.generateReactHooks(
1266
+ const generatedSourceCode = RuntimeSupport.generateReactHooks(
1304
1267
  packageName,
1305
- import_build_common3.RuntimeSupport.REACT_INTEGRATION_MODULE_ID
1268
+ RuntimeSupport.REACT_INTEGRATION_MODULE_ID
1306
1269
  );
1307
1270
  isDebug3 && debug4("Generated hooks code: %O", generatedSourceCode);
1308
1271
  return generatedSourceCode;
@@ -1310,13 +1273,13 @@ function codegenPlugin() {
1310
1273
  if (mod.type === "app-meta") {
1311
1274
  return generateAppMetadata(
1312
1275
  mod.packageDirectory,
1313
- import_build_common3.RuntimeSupport.METADATA_MODULE_ID
1276
+ RuntimeSupport.METADATA_MODULE_ID
1314
1277
  );
1315
1278
  }
1316
1279
  const context = buildMetadataContext(this, moduleId, devServer, manualDeps);
1317
1280
  const appMetadata = await repository.getAppMetadata(
1318
1281
  context,
1319
- (0, import_node_path3.dirname)(packageJsonPath)
1282
+ dirname3(packageJsonPath)
1320
1283
  );
1321
1284
  switch (mod.type) {
1322
1285
  case "app-packages": {
@@ -1395,7 +1358,7 @@ function reportError(ctx, error, isDev) {
1395
1358
  });
1396
1359
  }
1397
1360
  function addManualDep(manualDeps, file, moduleId) {
1398
- const normalizedPath = (0, import_vite4.normalizePath)(file);
1361
+ const normalizedPath = normalizePath4(file);
1399
1362
  let moduleIds = manualDeps.get(normalizedPath);
1400
1363
  if (!moduleIds) {
1401
1364
  moduleIds = /* @__PURE__ */ new Set();
@@ -1406,14 +1369,14 @@ function addManualDep(manualDeps, file, moduleId) {
1406
1369
  function findPackageJson(startDir, rootDir) {
1407
1370
  let dir = startDir;
1408
1371
  while (dir) {
1409
- const candidate = (0, import_node_path3.join)(dir, "package.json");
1410
- if ((0, import_node_fs2.existsSync)(candidate)) {
1372
+ const candidate = join2(dir, "package.json");
1373
+ if (existsSync2(candidate)) {
1411
1374
  return candidate;
1412
1375
  }
1413
- if ((0, import_vite4.normalizePath)(dir) == (0, import_vite4.normalizePath)(rootDir)) {
1376
+ if (normalizePath4(dir) == normalizePath4(rootDir)) {
1414
1377
  return void 0;
1415
1378
  }
1416
- const parent = (0, import_node_path3.dirname)(dir);
1379
+ const parent = dirname3(dir);
1417
1380
  dir = parent === dir || parent === "." ? "" : parent;
1418
1381
  }
1419
1382
  return void 0;
@@ -1421,7 +1384,7 @@ function findPackageJson(startDir, rootDir) {
1421
1384
  async function getPackageName(ctx, packageJsonPath) {
1422
1385
  let name;
1423
1386
  try {
1424
- const content = await (0, import_promises4.readFile)(packageJsonPath, "utf-8");
1387
+ const content = await readFile3(packageJsonPath, "utf-8");
1425
1388
  name = JSON.parse(content).name;
1426
1389
  } catch (e) {
1427
1390
  throw new ReportableError(`Failed to read package.json file`, { cause: e });
@@ -1449,10 +1412,10 @@ function getCauseMessages(error) {
1449
1412
  }
1450
1413
 
1451
1414
  // src/mpaPlugin.ts
1452
- var import_node_fs3 = require("node:fs");
1453
- var import_node_path4 = require("node:path");
1454
- var import_node_path5 = require("node:path");
1455
- var import_node_process = require("node:process");
1415
+ import { existsSync as existsSync3 } from "node:fs";
1416
+ import { resolve } from "node:path";
1417
+ import { posix as posix2 } from "node:path";
1418
+ import { cwd } from "node:process";
1456
1419
  function mpaPlugin(options) {
1457
1420
  const rootSite = (options == null ? void 0 : options.rootSite) ?? false;
1458
1421
  const apps = (options == null ? void 0 : options.apps) || [];
@@ -1461,7 +1424,7 @@ function mpaPlugin(options) {
1461
1424
  return {
1462
1425
  name: "pioneer:mpa",
1463
1426
  config(config) {
1464
- const sourceRoot = config.root ?? (0, import_node_process.cwd)();
1427
+ const sourceRoot = config.root ?? cwd();
1465
1428
  const { entryPoints, appNames } = gatherEntryPoints({
1466
1429
  apps,
1467
1430
  sites,
@@ -1475,10 +1438,10 @@ function mpaPlugin(options) {
1475
1438
  if (appNames.includes(chunk.name)) {
1476
1439
  return "[name].js";
1477
1440
  }
1478
- return import_node_path5.posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
1441
+ return posix2.join(resolvedConfig.build.assetsDir, "[hash:12].js");
1479
1442
  },
1480
1443
  chunkFileNames(chunk) {
1481
- return import_node_path5.posix.join(resolvedConfig.build.assetsDir, "[hash:12].js");
1444
+ return posix2.join(resolvedConfig.build.assetsDir, "[hash:12].js");
1482
1445
  }
1483
1446
  }
1484
1447
  };
@@ -1497,7 +1460,7 @@ function gatherEntryPoints(options) {
1497
1460
  let apps;
1498
1461
  if (Array.isArray(options.apps)) {
1499
1462
  apps = options.apps.map((appName) => {
1500
- const prefix = (0, import_node_path4.resolve)(options.sourceRoot, "apps", appName, "app");
1463
+ const prefix = resolve(options.sourceRoot, "apps", appName, "app");
1501
1464
  const path = findMatchingEntryPointFile(appName, prefix);
1502
1465
  return {
1503
1466
  name: appName,
@@ -1506,8 +1469,8 @@ function gatherEntryPoints(options) {
1506
1469
  });
1507
1470
  } else {
1508
1471
  apps = Object.entries(options.apps).map(([name, appPath]) => {
1509
- const path = (0, import_node_path4.resolve)(options.sourceRoot, appPath);
1510
- if (!(0, import_node_fs3.existsSync)(path)) {
1472
+ const path = resolve(options.sourceRoot, appPath);
1473
+ if (!existsSync3(path)) {
1511
1474
  throw new Error(
1512
1475
  `Failed to find app '${name}' at ${path}. Ensure that the path is spelled correctly.`
1513
1476
  );
@@ -1516,8 +1479,8 @@ function gatherEntryPoints(options) {
1516
1479
  });
1517
1480
  }
1518
1481
  const sites = options.sites.map((sitePath) => {
1519
- const path = (0, import_node_path4.resolve)(options.sourceRoot, sitePath, "index.html");
1520
- if (!(0, import_node_fs3.existsSync)(path)) {
1482
+ const path = resolve(options.sourceRoot, sitePath, "index.html");
1483
+ if (!existsSync3(path)) {
1521
1484
  throw new Error(
1522
1485
  `Failed to find site at ${path}. Ensure that the site name in your vite configuration is spelled correctly.`
1523
1486
  );
@@ -1528,8 +1491,8 @@ function gatherEntryPoints(options) {
1528
1491
  };
1529
1492
  });
1530
1493
  if (options.rootSite) {
1531
- const path = (0, import_node_path4.resolve)(options.sourceRoot, "index.html");
1532
- if (!(0, import_node_fs3.existsSync)(path)) {
1494
+ const path = resolve(options.sourceRoot, "index.html");
1495
+ if (!existsSync3(path)) {
1533
1496
  throw new Error(
1534
1497
  `Failed to find root site at ${path}. Create the missing file or set 'rootSite' to false.`
1535
1498
  );
@@ -1566,7 +1529,7 @@ var EXTENSIONS = [".ts", ".tsx", ".js", ".jsx"];
1566
1529
  function findMatchingEntryPointFile(appName, prefix) {
1567
1530
  for (const ext of EXTENSIONS) {
1568
1531
  const candidate = prefix + ext;
1569
- if ((0, import_node_fs3.existsSync)(candidate)) {
1532
+ if (existsSync3(candidate)) {
1570
1533
  return candidate;
1571
1534
  }
1572
1535
  }
@@ -1580,8 +1543,7 @@ function findMatchingEntryPointFile(appName, prefix) {
1580
1543
  function pioneer(options) {
1581
1544
  return [mpaPlugin(options), codegenPlugin()];
1582
1545
  }
1583
- // Annotate the CommonJS export names for ESM import in node:
1584
- 0 && (module.exports = {
1546
+ export {
1585
1547
  pioneer
1586
- });
1548
+ };
1587
1549
  //# sourceMappingURL=index.js.map