@open-pioneer/vite-plugin-pioneer 6.0.2 → 6.0.3
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 +9 -0
- package/client.d.ts +1 -0
- package/dist/index.js +193 -189
- package/dist/index.js.map +4 -4
- package/package.json +19 -19
- package/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog @open-pioneer/vite-plugin-pioneer
|
|
2
2
|
|
|
3
|
+
## 6.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3b1f9cf: Migrate from eslint to oxlint and from prettier to oxfmt
|
|
8
|
+
- Updated dependencies [3b1f9cf]
|
|
9
|
+
- @open-pioneer/build-common@4.0.3
|
|
10
|
+
|
|
3
11
|
## 6.0.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -122,6 +130,7 @@
|
|
|
122
130
|
- f12e73f: Emit better errors when an application's i18n configuration does not match the supported locales of its dependencies.
|
|
123
131
|
|
|
124
132
|
This can happen if:
|
|
133
|
+
|
|
125
134
|
- An application does not list the `i18n` option in its `build.config.mjs` at all, or if
|
|
126
135
|
- there is no overlap between the application's locales and the locales supported by one of its dependencies.
|
|
127
136
|
|
package/client.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// src/codegenPlugin.ts
|
|
2
|
-
import { RuntimeSupport as RuntimeSupport3 } from "@open-pioneer/build-common";
|
|
3
2
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
4
3
|
import { dirname as dirname4 } from "node:path";
|
|
5
4
|
import { cwd } from "node:process";
|
|
5
|
+
import { RuntimeSupport as RuntimeSupport3 } from "@open-pioneer/build-common";
|
|
6
6
|
import { normalizePath as normalizePath5 } from "vite";
|
|
7
7
|
|
|
8
|
-
// src/
|
|
9
|
-
|
|
10
|
-
};
|
|
8
|
+
// src/codegen/generateAppMetadata.ts
|
|
9
|
+
import { RuntimeSupport } from "@open-pioneer/build-common";
|
|
11
10
|
|
|
12
11
|
// src/codegen/shared.ts
|
|
13
12
|
import { existsSync } from "fs";
|
|
@@ -173,7 +172,6 @@ function findPackageJson(startDir, rootDir) {
|
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
// src/codegen/generateAppMetadata.ts
|
|
176
|
-
import { RuntimeSupport } from "@open-pioneer/build-common";
|
|
177
175
|
function generateAppMetadata(packageDirectory, metadataModuleId, runtimeMetadataVersion) {
|
|
178
176
|
const packagesModule = serializeModuleId({ type: "app-packages", packageDirectory });
|
|
179
177
|
const cssModule = serializeModuleId({ type: "app-css", packageDirectory }) + "&inline&lang.scss";
|
|
@@ -238,6 +236,10 @@ function generateCombinedCss(packages) {
|
|
|
238
236
|
return packages.filter((pkg2) => !!pkg2.cssFilePath).map((pkg2) => cssImport(pkg2.cssFilePath)).join("\n");
|
|
239
237
|
}
|
|
240
238
|
|
|
239
|
+
// src/ReportableError.ts
|
|
240
|
+
var ReportableError = class extends Error {
|
|
241
|
+
};
|
|
242
|
+
|
|
241
243
|
// src/utils/babelDeps.ts
|
|
242
244
|
import generateModule from "@babel/generator";
|
|
243
245
|
import templateModule from "@babel/template";
|
|
@@ -588,77 +590,31 @@ var DeploymentModule = class {
|
|
|
588
590
|
}
|
|
589
591
|
};
|
|
590
592
|
|
|
591
|
-
// src/metadata/
|
|
592
|
-
|
|
593
|
+
// src/metadata/Context.ts
|
|
594
|
+
function createMetadataContextFromRolldown(ctx) {
|
|
595
|
+
return {
|
|
596
|
+
addWatchFile: (id) => {
|
|
597
|
+
ctx.addWatchFile(id);
|
|
598
|
+
},
|
|
599
|
+
resolveLocalFile: async (moduleId, _packageName, packageDirectory) => {
|
|
600
|
+
const importer = `${packageDirectory}/package.json`;
|
|
601
|
+
const result = await ctx.resolve(moduleId, importer, {
|
|
602
|
+
skipSelf: true
|
|
603
|
+
});
|
|
604
|
+
return result == null ? void 0 : result.id;
|
|
605
|
+
},
|
|
606
|
+
warn: (message) => {
|
|
607
|
+
ctx.warn(message);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// src/metadata/findTrailsPackages.ts
|
|
593
613
|
import { realpath } from "fs/promises";
|
|
594
|
-
import {
|
|
614
|
+
import { dirname as dirname2, posix as posix3 } from "path";
|
|
615
|
+
import { ResolverFactory } from "oxc-resolver";
|
|
616
|
+
import { glob } from "tinyglobby";
|
|
595
617
|
import { normalizePath as normalizePath3 } from "vite";
|
|
596
|
-
import { findDepPkgJsonPath } from "vitefu";
|
|
597
|
-
|
|
598
|
-
// src/utils/Cache.ts
|
|
599
|
-
var Cache = class {
|
|
600
|
-
#values = /* @__PURE__ */ new Map();
|
|
601
|
-
#jobs = /* @__PURE__ */ new Map();
|
|
602
|
-
#provider;
|
|
603
|
-
constructor(provider) {
|
|
604
|
-
this.#provider = provider;
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Removes an entry associated with the given key.
|
|
608
|
-
*/
|
|
609
|
-
invalidate(key) {
|
|
610
|
-
var _a, _b;
|
|
611
|
-
const id = this.#provider.getId(key);
|
|
612
|
-
const oldValue = this.#values.get(id);
|
|
613
|
-
this.#values.delete(id);
|
|
614
|
-
this.#jobs.delete(id);
|
|
615
|
-
if (oldValue) {
|
|
616
|
-
(_b = (_a = this.#provider).onInvalidate) == null ? void 0 : _b.call(_a, key, oldValue);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Retrieves the value associated with `key`.
|
|
621
|
-
* A cached result will be used if present, otherwise the
|
|
622
|
-
* cache provider will be called.
|
|
623
|
-
*
|
|
624
|
-
* Note: computations may throw errors.
|
|
625
|
-
* Errors will not be cached.
|
|
626
|
-
*
|
|
627
|
-
* @param key the lookup key
|
|
628
|
-
* @param context an arbitrary set of values that will be forwarded to the provider
|
|
629
|
-
* should be provider be called.
|
|
630
|
-
* @returns the value associated with `key`
|
|
631
|
-
*/
|
|
632
|
-
async get(key, ...context) {
|
|
633
|
-
var _a;
|
|
634
|
-
const provider = this.#provider;
|
|
635
|
-
const id = provider.getId(key);
|
|
636
|
-
const values = this.#values;
|
|
637
|
-
const existingValue = values.get(id);
|
|
638
|
-
if (existingValue) {
|
|
639
|
-
(_a = provider.onCachedReturn) == null ? void 0 : _a.call(provider, key, existingValue);
|
|
640
|
-
return Promise.resolve(existingValue);
|
|
641
|
-
}
|
|
642
|
-
const jobs = this.#jobs;
|
|
643
|
-
const existingJob = jobs.get(id);
|
|
644
|
-
if (existingJob) {
|
|
645
|
-
return existingJob;
|
|
646
|
-
}
|
|
647
|
-
const job = provider.getValue(key, ...context);
|
|
648
|
-
jobs.set(id, job);
|
|
649
|
-
try {
|
|
650
|
-
const value = await job;
|
|
651
|
-
if (jobs.get(id) === job) {
|
|
652
|
-
values.set(id, value);
|
|
653
|
-
}
|
|
654
|
-
return value;
|
|
655
|
-
} finally {
|
|
656
|
-
if (jobs.get(id) === job) {
|
|
657
|
-
jobs.delete(id);
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
618
|
|
|
663
619
|
// src/utils/debug.ts
|
|
664
620
|
import pkg from "debug";
|
|
@@ -671,6 +627,10 @@ function createDebugger(namespace) {
|
|
|
671
627
|
}
|
|
672
628
|
|
|
673
629
|
// src/metadata/loadPackageMetadata.ts
|
|
630
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
631
|
+
import { readFile } from "node:fs/promises";
|
|
632
|
+
import { join as join2 } from "node:path";
|
|
633
|
+
import posix2 from "node:path/posix";
|
|
674
634
|
import {
|
|
675
635
|
BUILD_CONFIG_NAME,
|
|
676
636
|
PackageMetadataV1,
|
|
@@ -678,10 +638,6 @@ import {
|
|
|
678
638
|
createPackageConfigFromPackageMetadata,
|
|
679
639
|
loadBuildConfig
|
|
680
640
|
} from "@open-pioneer/build-common";
|
|
681
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
682
|
-
import { readFile } from "node:fs/promises";
|
|
683
|
-
import { join as join2 } from "node:path";
|
|
684
|
-
import posix2 from "node:path/posix";
|
|
685
641
|
import { normalizePath as normalizePath2 } from "vite";
|
|
686
642
|
|
|
687
643
|
// src/utils/fileUtils.ts
|
|
@@ -981,6 +937,141 @@ function isLocalPackage(file, sourceDir) {
|
|
|
981
937
|
return isInDirectory(file, sourceDir) && !NODE_MODULES_RE.test(file);
|
|
982
938
|
}
|
|
983
939
|
|
|
940
|
+
// src/metadata/findTrailsPackages.ts
|
|
941
|
+
var isDebug2 = !!process.env.DEBUG;
|
|
942
|
+
var debug3 = createDebugger("open-pioneer:metadata");
|
|
943
|
+
async function findTrailsPackages(sourceRoot) {
|
|
944
|
+
const ctx = createDummyContext();
|
|
945
|
+
const packageResolver = ResolverFactory.default();
|
|
946
|
+
const localPackageJsonFiles = await glob("**/package.json", {
|
|
947
|
+
cwd: sourceRoot,
|
|
948
|
+
absolute: true,
|
|
949
|
+
ignore: ["**/node_modules/**"]
|
|
950
|
+
});
|
|
951
|
+
const seen = /* @__PURE__ */ new Set();
|
|
952
|
+
const workQueue = [];
|
|
953
|
+
const visit = (packageDirectory) => {
|
|
954
|
+
const normalizedPath = normalizePath3(packageDirectory);
|
|
955
|
+
if (seen.has(normalizedPath)) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
seen.add(normalizedPath);
|
|
959
|
+
workQueue.push(normalizedPath);
|
|
960
|
+
};
|
|
961
|
+
for (const file of localPackageJsonFiles) {
|
|
962
|
+
visit(dirname2(file));
|
|
963
|
+
}
|
|
964
|
+
const trailsPackages = [];
|
|
965
|
+
while (workQueue.length) {
|
|
966
|
+
const packageDirectory = workQueue.pop();
|
|
967
|
+
const pkg2 = await loadPackageMetadata(ctx, packageDirectory, {
|
|
968
|
+
sourceRoot,
|
|
969
|
+
importedFrom: void 0,
|
|
970
|
+
allowMissingBuildConfigInLocalPackage: true
|
|
971
|
+
});
|
|
972
|
+
if (pkg2.type === "plain") {
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
trailsPackages.push(pkg2);
|
|
976
|
+
for (const dependency of pkg2.dependencies) {
|
|
977
|
+
const depResult = await packageResolver.async(
|
|
978
|
+
packageDirectory,
|
|
979
|
+
dependency.packageName + "/package.json"
|
|
980
|
+
);
|
|
981
|
+
if (depResult.path) {
|
|
982
|
+
const depPath = await realpath(dirname2(depResult.path));
|
|
983
|
+
visit(depPath);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
trailsPackages.sort((p1, p2) => p1.name.localeCompare(p2.name, "en"));
|
|
988
|
+
return trailsPackages;
|
|
989
|
+
}
|
|
990
|
+
function createDummyContext() {
|
|
991
|
+
return {
|
|
992
|
+
addWatchFile(_file) {
|
|
993
|
+
},
|
|
994
|
+
async resolveLocalFile(moduleId, _packageDir, packageName) {
|
|
995
|
+
return posix3.join(packageName, moduleId);
|
|
996
|
+
},
|
|
997
|
+
warn(message) {
|
|
998
|
+
isDebug2 && debug3("Problem during trails package discovery: %s", message);
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// src/metadata/MetadataRepository.ts
|
|
1004
|
+
import { realpath as realpath2 } from "fs/promises";
|
|
1005
|
+
import { basename as basename2, dirname as dirname3 } from "path";
|
|
1006
|
+
import { BUILD_CONFIG_NAME as BUILD_CONFIG_NAME2, RuntimeSupport as RuntimeSupport2 } from "@open-pioneer/build-common";
|
|
1007
|
+
import { normalizePath as normalizePath4 } from "vite";
|
|
1008
|
+
import { findDepPkgJsonPath } from "vitefu";
|
|
1009
|
+
|
|
1010
|
+
// src/utils/Cache.ts
|
|
1011
|
+
var Cache = class {
|
|
1012
|
+
#values = /* @__PURE__ */ new Map();
|
|
1013
|
+
#jobs = /* @__PURE__ */ new Map();
|
|
1014
|
+
#provider;
|
|
1015
|
+
constructor(provider) {
|
|
1016
|
+
this.#provider = provider;
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Removes an entry associated with the given key.
|
|
1020
|
+
*/
|
|
1021
|
+
invalidate(key) {
|
|
1022
|
+
var _a, _b;
|
|
1023
|
+
const id = this.#provider.getId(key);
|
|
1024
|
+
const oldValue = this.#values.get(id);
|
|
1025
|
+
this.#values.delete(id);
|
|
1026
|
+
this.#jobs.delete(id);
|
|
1027
|
+
if (oldValue) {
|
|
1028
|
+
(_b = (_a = this.#provider).onInvalidate) == null ? void 0 : _b.call(_a, key, oldValue);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Retrieves the value associated with `key`.
|
|
1033
|
+
* A cached result will be used if present, otherwise the
|
|
1034
|
+
* cache provider will be called.
|
|
1035
|
+
*
|
|
1036
|
+
* Note: computations may throw errors.
|
|
1037
|
+
* Errors will not be cached.
|
|
1038
|
+
*
|
|
1039
|
+
* @param key the lookup key
|
|
1040
|
+
* @param context an arbitrary set of values that will be forwarded to the provider
|
|
1041
|
+
* should be provider be called.
|
|
1042
|
+
* @returns the value associated with `key`
|
|
1043
|
+
*/
|
|
1044
|
+
async get(key, ...context) {
|
|
1045
|
+
var _a;
|
|
1046
|
+
const provider = this.#provider;
|
|
1047
|
+
const id = provider.getId(key);
|
|
1048
|
+
const values = this.#values;
|
|
1049
|
+
const existingValue = values.get(id);
|
|
1050
|
+
if (existingValue) {
|
|
1051
|
+
(_a = provider.onCachedReturn) == null ? void 0 : _a.call(provider, key, existingValue);
|
|
1052
|
+
return Promise.resolve(existingValue);
|
|
1053
|
+
}
|
|
1054
|
+
const jobs = this.#jobs;
|
|
1055
|
+
const existingJob = jobs.get(id);
|
|
1056
|
+
if (existingJob) {
|
|
1057
|
+
return existingJob;
|
|
1058
|
+
}
|
|
1059
|
+
const job = provider.getValue(key, ...context);
|
|
1060
|
+
jobs.set(id, job);
|
|
1061
|
+
try {
|
|
1062
|
+
const value = await job;
|
|
1063
|
+
if (jobs.get(id) === job) {
|
|
1064
|
+
values.set(id, value);
|
|
1065
|
+
}
|
|
1066
|
+
return value;
|
|
1067
|
+
} finally {
|
|
1068
|
+
if (jobs.get(id) === job) {
|
|
1069
|
+
jobs.delete(id);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
|
|
984
1075
|
// src/metadata/parseI18nYaml.ts
|
|
985
1076
|
import { readFile as readFile2 } from "fs/promises";
|
|
986
1077
|
import { load as loadYaml } from "js-yaml";
|
|
@@ -1072,8 +1163,8 @@ function gatherOverrides(data) {
|
|
|
1072
1163
|
}
|
|
1073
1164
|
|
|
1074
1165
|
// src/metadata/MetadataRepository.ts
|
|
1075
|
-
var
|
|
1076
|
-
var
|
|
1166
|
+
var isDebug3 = !!process.env.DEBUG;
|
|
1167
|
+
var debug4 = createDebugger("open-pioneer:metadata");
|
|
1077
1168
|
var MetadataRepository = class {
|
|
1078
1169
|
#sourceRoot;
|
|
1079
1170
|
// Key: package directory on disk, value: existing metadata
|
|
@@ -1099,7 +1190,7 @@ var MetadataRepository = class {
|
|
|
1099
1190
|
*/
|
|
1100
1191
|
onFileChanged(path) {
|
|
1101
1192
|
if (isPackageJson(path) || isBuildConfig(path)) {
|
|
1102
|
-
this.#packageMetadataCache.invalidate(
|
|
1193
|
+
this.#packageMetadataCache.invalidate(dirname3(path));
|
|
1103
1194
|
}
|
|
1104
1195
|
this.#i18nCache.invalidate(path);
|
|
1105
1196
|
}
|
|
@@ -1111,7 +1202,7 @@ var MetadataRepository = class {
|
|
|
1111
1202
|
* will be returned here.
|
|
1112
1203
|
*/
|
|
1113
1204
|
async getAppMetadata(ctx, appDirectory) {
|
|
1114
|
-
|
|
1205
|
+
isDebug3 && debug4(`Request for app metadata of ${appDirectory}`);
|
|
1115
1206
|
const appPackageMetadata = await this.#getPackageMetadata(ctx, {
|
|
1116
1207
|
type: "absolute",
|
|
1117
1208
|
directory: appDirectory
|
|
@@ -1146,7 +1237,7 @@ var MetadataRepository = class {
|
|
|
1146
1237
|
packageMetadata.packageJsonPath
|
|
1147
1238
|
);
|
|
1148
1239
|
} else {
|
|
1149
|
-
|
|
1240
|
+
isDebug3 && debug4(`Skipping already visited package at %s`, packageMetadata.directory);
|
|
1150
1241
|
}
|
|
1151
1242
|
});
|
|
1152
1243
|
return await Promise.all(jobs);
|
|
@@ -1172,7 +1263,7 @@ var MetadataRepository = class {
|
|
|
1172
1263
|
* Returns package metadata associated with the given package.
|
|
1173
1264
|
*/
|
|
1174
1265
|
async #getPackageMetadata(ctx, loc) {
|
|
1175
|
-
|
|
1266
|
+
isDebug3 && debug4(`Request for package metadata of ${formatPackageLocation(loc)}`);
|
|
1176
1267
|
const packageDir = await this.#resolvePackageLocation(loc);
|
|
1177
1268
|
if (!packageDir) {
|
|
1178
1269
|
return void 0;
|
|
@@ -1181,7 +1272,7 @@ var MetadataRepository = class {
|
|
|
1181
1272
|
const entry = await this.#packageMetadataCache.get(packageDir, ctx, importedFrom);
|
|
1182
1273
|
propagateWatchFiles(entry.watchFiles, ctx);
|
|
1183
1274
|
if (entry.metadata.type === "plain") {
|
|
1184
|
-
|
|
1275
|
+
isDebug3 && debug4(`Skipping package '${packageDir}'.`);
|
|
1185
1276
|
return void 0;
|
|
1186
1277
|
}
|
|
1187
1278
|
return entry.metadata;
|
|
@@ -1196,30 +1287,30 @@ var MetadataRepository = class {
|
|
|
1196
1287
|
}
|
|
1197
1288
|
async #resolvePackageLocation(loc) {
|
|
1198
1289
|
if (loc.type === "absolute") {
|
|
1199
|
-
return await
|
|
1290
|
+
return await realpath2(loc.directory);
|
|
1200
1291
|
}
|
|
1201
1292
|
const { packageName, optional } = loc.dependency;
|
|
1202
1293
|
const packagePath = await findDepPkgJsonPath(packageName, loc.importedFrom);
|
|
1203
1294
|
if (!packagePath) {
|
|
1204
1295
|
if (optional) {
|
|
1205
|
-
|
|
1296
|
+
isDebug3 && debug4(`Optional package '${packageName}' was not found.`);
|
|
1206
1297
|
return void 0;
|
|
1207
1298
|
}
|
|
1208
1299
|
throw new ReportableError(
|
|
1209
1300
|
`Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`
|
|
1210
1301
|
);
|
|
1211
1302
|
}
|
|
1212
|
-
const packageDir =
|
|
1213
|
-
|
|
1303
|
+
const packageDir = dirname3(await realpath2(packagePath));
|
|
1304
|
+
isDebug3 && debug4(`Found package '${packageName}' at ${packageDir}`);
|
|
1214
1305
|
return packageDir;
|
|
1215
1306
|
}
|
|
1216
1307
|
#createI18nCache() {
|
|
1217
1308
|
return new Cache({
|
|
1218
1309
|
getId(path) {
|
|
1219
|
-
return
|
|
1310
|
+
return normalizePath4(path);
|
|
1220
1311
|
},
|
|
1221
1312
|
async getValue(path, ctx) {
|
|
1222
|
-
|
|
1313
|
+
isDebug3 && debug4(`Loading i18n file ${path}`);
|
|
1223
1314
|
ctx.addWatchFile(path);
|
|
1224
1315
|
const entry = {
|
|
1225
1316
|
i18n: await loadI18nFile(path),
|
|
@@ -1228,10 +1319,10 @@ var MetadataRepository = class {
|
|
|
1228
1319
|
return entry;
|
|
1229
1320
|
},
|
|
1230
1321
|
onInvalidate(path) {
|
|
1231
|
-
|
|
1322
|
+
isDebug3 && debug4(`Removed cache entry for i18n file ${path}`);
|
|
1232
1323
|
},
|
|
1233
1324
|
onCachedReturn(path) {
|
|
1234
|
-
|
|
1325
|
+
isDebug3 && debug4(`Returning cached entry for i18n file ${path}`);
|
|
1235
1326
|
}
|
|
1236
1327
|
});
|
|
1237
1328
|
}
|
|
@@ -1240,10 +1331,10 @@ var MetadataRepository = class {
|
|
|
1240
1331
|
const provider = {
|
|
1241
1332
|
_byName: /* @__PURE__ */ new Map(),
|
|
1242
1333
|
getId(directory) {
|
|
1243
|
-
return
|
|
1334
|
+
return normalizePath4(directory);
|
|
1244
1335
|
},
|
|
1245
1336
|
async getValue(directory, ctx, importedFrom) {
|
|
1246
|
-
|
|
1337
|
+
isDebug3 && debug4(
|
|
1247
1338
|
`Loading metadata for package at ${directory} (imported from ${importedFrom ?? "N/A"})`
|
|
1248
1339
|
);
|
|
1249
1340
|
const watchFiles = /* @__PURE__ */ new Set();
|
|
@@ -1259,10 +1350,10 @@ var MetadataRepository = class {
|
|
|
1259
1350
|
sourceRoot,
|
|
1260
1351
|
importedFrom
|
|
1261
1352
|
});
|
|
1262
|
-
|
|
1353
|
+
isDebug3 && debug4(`Metadata for '${metadata.name}': %O`, metadata);
|
|
1263
1354
|
if (metadata.type === "pioneer-package") {
|
|
1264
1355
|
const existingMetadata = this._byName.get(metadata.name);
|
|
1265
|
-
if (existingMetadata &&
|
|
1356
|
+
if (existingMetadata && normalizePath4(existingMetadata.directory) !== normalizePath4(metadata.directory)) {
|
|
1266
1357
|
const message = `Encountered the package '${metadata.name}' at two different locations.
|
|
1267
1358
|
Trails packages cannot be used more than once in the same application.
|
|
1268
1359
|
All packages must use a common version of '${metadata.name}'.
|
|
@@ -1280,11 +1371,11 @@ All packages must use a common version of '${metadata.name}'.
|
|
|
1280
1371
|
};
|
|
1281
1372
|
},
|
|
1282
1373
|
onInvalidate(directory, entry) {
|
|
1283
|
-
|
|
1374
|
+
isDebug3 && debug4(`Removed cache entry for '${entry.metadata.name}'`);
|
|
1284
1375
|
this._byName.delete(entry.metadata.name);
|
|
1285
1376
|
},
|
|
1286
1377
|
onCachedReturn(directory, entry) {
|
|
1287
|
-
|
|
1378
|
+
isDebug3 && debug4(`Returning cached metadata for '${entry.metadata.name}'`);
|
|
1288
1379
|
}
|
|
1289
1380
|
};
|
|
1290
1381
|
return new Cache(provider);
|
|
@@ -1314,7 +1405,7 @@ function detectRuntimeMetadataVersion(packages) {
|
|
|
1314
1405
|
);
|
|
1315
1406
|
}
|
|
1316
1407
|
}
|
|
1317
|
-
|
|
1408
|
+
isDebug3 && debug4("Detected runtime version %s", versionResult);
|
|
1318
1409
|
return versionResult;
|
|
1319
1410
|
}
|
|
1320
1411
|
function propagateWatchFiles(watchFiles, ctx) {
|
|
@@ -1351,74 +1442,6 @@ function formatPackage(packageMetadata) {
|
|
|
1351
1442
|
return str;
|
|
1352
1443
|
}
|
|
1353
1444
|
|
|
1354
|
-
// src/metadata/findTrailsPackages.ts
|
|
1355
|
-
import { realpath as realpath2 } from "fs/promises";
|
|
1356
|
-
import { ResolverFactory } from "oxc-resolver";
|
|
1357
|
-
import { dirname as dirname3, posix as posix3 } from "path";
|
|
1358
|
-
import { glob } from "tinyglobby";
|
|
1359
|
-
import { normalizePath as normalizePath4 } from "vite";
|
|
1360
|
-
var isDebug3 = !!process.env.DEBUG;
|
|
1361
|
-
var debug4 = createDebugger("open-pioneer:metadata");
|
|
1362
|
-
async function findTrailsPackages(sourceRoot) {
|
|
1363
|
-
const ctx = createDummyContext();
|
|
1364
|
-
const packageResolver = ResolverFactory.default();
|
|
1365
|
-
const localPackageJsonFiles = await glob("**/package.json", {
|
|
1366
|
-
cwd: sourceRoot,
|
|
1367
|
-
absolute: true,
|
|
1368
|
-
ignore: ["**/node_modules/**"]
|
|
1369
|
-
});
|
|
1370
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1371
|
-
const workQueue = [];
|
|
1372
|
-
const visit = (packageDirectory) => {
|
|
1373
|
-
const normalizedPath = normalizePath4(packageDirectory);
|
|
1374
|
-
if (seen.has(normalizedPath)) {
|
|
1375
|
-
return;
|
|
1376
|
-
}
|
|
1377
|
-
seen.add(normalizedPath);
|
|
1378
|
-
workQueue.push(normalizedPath);
|
|
1379
|
-
};
|
|
1380
|
-
for (const file of localPackageJsonFiles) {
|
|
1381
|
-
visit(dirname3(file));
|
|
1382
|
-
}
|
|
1383
|
-
const trailsPackages = [];
|
|
1384
|
-
while (workQueue.length) {
|
|
1385
|
-
const packageDirectory = workQueue.pop();
|
|
1386
|
-
const pkg2 = await loadPackageMetadata(ctx, packageDirectory, {
|
|
1387
|
-
sourceRoot,
|
|
1388
|
-
importedFrom: void 0,
|
|
1389
|
-
allowMissingBuildConfigInLocalPackage: true
|
|
1390
|
-
});
|
|
1391
|
-
if (pkg2.type === "plain") {
|
|
1392
|
-
continue;
|
|
1393
|
-
}
|
|
1394
|
-
trailsPackages.push(pkg2);
|
|
1395
|
-
for (const dependency of pkg2.dependencies) {
|
|
1396
|
-
const depResult = await packageResolver.async(
|
|
1397
|
-
packageDirectory,
|
|
1398
|
-
dependency.packageName + "/package.json"
|
|
1399
|
-
);
|
|
1400
|
-
if (depResult.path) {
|
|
1401
|
-
const depPath = await realpath2(dirname3(depResult.path));
|
|
1402
|
-
visit(depPath);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
trailsPackages.sort((p1, p2) => p1.name.localeCompare(p2.name, "en"));
|
|
1407
|
-
return trailsPackages;
|
|
1408
|
-
}
|
|
1409
|
-
function createDummyContext() {
|
|
1410
|
-
return {
|
|
1411
|
-
addWatchFile(_file) {
|
|
1412
|
-
},
|
|
1413
|
-
async resolveLocalFile(moduleId, _packageDir, packageName) {
|
|
1414
|
-
return posix3.join(packageName, moduleId);
|
|
1415
|
-
},
|
|
1416
|
-
warn(message) {
|
|
1417
|
-
isDebug3 && debug4("Problem during trails package discovery: %s", message);
|
|
1418
|
-
}
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
1445
|
// src/metadata/validateI18nConfig.ts
|
|
1423
1446
|
var isDebug4 = !!process.env.DEBUG;
|
|
1424
1447
|
var debug5 = createDebugger("open-pioneer:validateI18nConfig");
|
|
@@ -1508,25 +1531,6 @@ There is no match between the locales supported by the application (${formattedA
|
|
|
1508
1531
|
);
|
|
1509
1532
|
}
|
|
1510
1533
|
|
|
1511
|
-
// src/metadata/Context.ts
|
|
1512
|
-
function createMetadataContextFromRolldown(ctx) {
|
|
1513
|
-
return {
|
|
1514
|
-
addWatchFile: (id) => {
|
|
1515
|
-
ctx.addWatchFile(id);
|
|
1516
|
-
},
|
|
1517
|
-
resolveLocalFile: async (moduleId, _packageName, packageDirectory) => {
|
|
1518
|
-
const importer = `${packageDirectory}/package.json`;
|
|
1519
|
-
const result = await ctx.resolve(moduleId, importer, {
|
|
1520
|
-
skipSelf: true
|
|
1521
|
-
});
|
|
1522
|
-
return result == null ? void 0 : result.id;
|
|
1523
|
-
},
|
|
1524
|
-
warn: (message) => {
|
|
1525
|
-
ctx.warn(message);
|
|
1526
|
-
}
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
1534
|
// src/codegenPlugin.ts
|
|
1531
1535
|
var isDebug5 = !!process.env.DEBUG;
|
|
1532
1536
|
var debug6 = createDebugger("open-pioneer:codegen");
|
|
@@ -1770,9 +1774,9 @@ function reportError(ctx, error, isDev) {
|
|
|
1770
1774
|
}
|
|
1771
1775
|
ctx.error({
|
|
1772
1776
|
message,
|
|
1773
|
-
//
|
|
1777
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1774
1778
|
cause: error.cause,
|
|
1775
|
-
//
|
|
1779
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1776
1780
|
stack: error.stack
|
|
1777
1781
|
});
|
|
1778
1782
|
}
|