@open-pioneer/vite-plugin-pioneer 6.0.1 → 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 +19 -0
- package/client.d.ts +1 -0
- package/dist/index.js +197 -190
- package/dist/index.js.map +4 -4
- package/package.json +22 -22
- package/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
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
|
+
|
|
11
|
+
## 6.0.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 1a78924: Bump dependencies
|
|
16
|
+
- 82b4559: Fix parsing of `qualifier` for services defined by dependencies in `node_modules`.
|
|
17
|
+
- Updated dependencies [1a78924]
|
|
18
|
+
- Updated dependencies [82b4559]
|
|
19
|
+
- @open-pioneer/build-common@4.0.2
|
|
20
|
+
|
|
3
21
|
## 6.0.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -112,6 +130,7 @@
|
|
|
112
130
|
- f12e73f: Emit better errors when an application's i18n configuration does not match the supported locales of its dependencies.
|
|
113
131
|
|
|
114
132
|
This can happen if:
|
|
133
|
+
|
|
115
134
|
- An application does not list the `i18n` option in its `build.config.mjs` at all, or if
|
|
116
135
|
- there is no overlap between the application's locales and the locales supported by one of its dependencies.
|
|
117
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";
|
|
@@ -1012,7 +1103,10 @@ async function loadI18nFile(path) {
|
|
|
1012
1103
|
}
|
|
1013
1104
|
}
|
|
1014
1105
|
function parseI18nYaml(yaml) {
|
|
1015
|
-
|
|
1106
|
+
let data = void 0;
|
|
1107
|
+
if (yaml.trim()) {
|
|
1108
|
+
data = loadYaml(yaml);
|
|
1109
|
+
}
|
|
1016
1110
|
return parseI18nFile(data);
|
|
1017
1111
|
}
|
|
1018
1112
|
var ERROR_MAP = createErrorMap();
|
|
@@ -1069,8 +1163,8 @@ function gatherOverrides(data) {
|
|
|
1069
1163
|
}
|
|
1070
1164
|
|
|
1071
1165
|
// src/metadata/MetadataRepository.ts
|
|
1072
|
-
var
|
|
1073
|
-
var
|
|
1166
|
+
var isDebug3 = !!process.env.DEBUG;
|
|
1167
|
+
var debug4 = createDebugger("open-pioneer:metadata");
|
|
1074
1168
|
var MetadataRepository = class {
|
|
1075
1169
|
#sourceRoot;
|
|
1076
1170
|
// Key: package directory on disk, value: existing metadata
|
|
@@ -1096,7 +1190,7 @@ var MetadataRepository = class {
|
|
|
1096
1190
|
*/
|
|
1097
1191
|
onFileChanged(path) {
|
|
1098
1192
|
if (isPackageJson(path) || isBuildConfig(path)) {
|
|
1099
|
-
this.#packageMetadataCache.invalidate(
|
|
1193
|
+
this.#packageMetadataCache.invalidate(dirname3(path));
|
|
1100
1194
|
}
|
|
1101
1195
|
this.#i18nCache.invalidate(path);
|
|
1102
1196
|
}
|
|
@@ -1108,7 +1202,7 @@ var MetadataRepository = class {
|
|
|
1108
1202
|
* will be returned here.
|
|
1109
1203
|
*/
|
|
1110
1204
|
async getAppMetadata(ctx, appDirectory) {
|
|
1111
|
-
|
|
1205
|
+
isDebug3 && debug4(`Request for app metadata of ${appDirectory}`);
|
|
1112
1206
|
const appPackageMetadata = await this.#getPackageMetadata(ctx, {
|
|
1113
1207
|
type: "absolute",
|
|
1114
1208
|
directory: appDirectory
|
|
@@ -1143,7 +1237,7 @@ var MetadataRepository = class {
|
|
|
1143
1237
|
packageMetadata.packageJsonPath
|
|
1144
1238
|
);
|
|
1145
1239
|
} else {
|
|
1146
|
-
|
|
1240
|
+
isDebug3 && debug4(`Skipping already visited package at %s`, packageMetadata.directory);
|
|
1147
1241
|
}
|
|
1148
1242
|
});
|
|
1149
1243
|
return await Promise.all(jobs);
|
|
@@ -1169,7 +1263,7 @@ var MetadataRepository = class {
|
|
|
1169
1263
|
* Returns package metadata associated with the given package.
|
|
1170
1264
|
*/
|
|
1171
1265
|
async #getPackageMetadata(ctx, loc) {
|
|
1172
|
-
|
|
1266
|
+
isDebug3 && debug4(`Request for package metadata of ${formatPackageLocation(loc)}`);
|
|
1173
1267
|
const packageDir = await this.#resolvePackageLocation(loc);
|
|
1174
1268
|
if (!packageDir) {
|
|
1175
1269
|
return void 0;
|
|
@@ -1178,7 +1272,7 @@ var MetadataRepository = class {
|
|
|
1178
1272
|
const entry = await this.#packageMetadataCache.get(packageDir, ctx, importedFrom);
|
|
1179
1273
|
propagateWatchFiles(entry.watchFiles, ctx);
|
|
1180
1274
|
if (entry.metadata.type === "plain") {
|
|
1181
|
-
|
|
1275
|
+
isDebug3 && debug4(`Skipping package '${packageDir}'.`);
|
|
1182
1276
|
return void 0;
|
|
1183
1277
|
}
|
|
1184
1278
|
return entry.metadata;
|
|
@@ -1193,30 +1287,30 @@ var MetadataRepository = class {
|
|
|
1193
1287
|
}
|
|
1194
1288
|
async #resolvePackageLocation(loc) {
|
|
1195
1289
|
if (loc.type === "absolute") {
|
|
1196
|
-
return await
|
|
1290
|
+
return await realpath2(loc.directory);
|
|
1197
1291
|
}
|
|
1198
1292
|
const { packageName, optional } = loc.dependency;
|
|
1199
1293
|
const packagePath = await findDepPkgJsonPath(packageName, loc.importedFrom);
|
|
1200
1294
|
if (!packagePath) {
|
|
1201
1295
|
if (optional) {
|
|
1202
|
-
|
|
1296
|
+
isDebug3 && debug4(`Optional package '${packageName}' was not found.`);
|
|
1203
1297
|
return void 0;
|
|
1204
1298
|
}
|
|
1205
1299
|
throw new ReportableError(
|
|
1206
1300
|
`Failed to find package '${packageName}' (from '${loc.importedFrom}'), is the dependency installed correctly?`
|
|
1207
1301
|
);
|
|
1208
1302
|
}
|
|
1209
|
-
const packageDir =
|
|
1210
|
-
|
|
1303
|
+
const packageDir = dirname3(await realpath2(packagePath));
|
|
1304
|
+
isDebug3 && debug4(`Found package '${packageName}' at ${packageDir}`);
|
|
1211
1305
|
return packageDir;
|
|
1212
1306
|
}
|
|
1213
1307
|
#createI18nCache() {
|
|
1214
1308
|
return new Cache({
|
|
1215
1309
|
getId(path) {
|
|
1216
|
-
return
|
|
1310
|
+
return normalizePath4(path);
|
|
1217
1311
|
},
|
|
1218
1312
|
async getValue(path, ctx) {
|
|
1219
|
-
|
|
1313
|
+
isDebug3 && debug4(`Loading i18n file ${path}`);
|
|
1220
1314
|
ctx.addWatchFile(path);
|
|
1221
1315
|
const entry = {
|
|
1222
1316
|
i18n: await loadI18nFile(path),
|
|
@@ -1225,10 +1319,10 @@ var MetadataRepository = class {
|
|
|
1225
1319
|
return entry;
|
|
1226
1320
|
},
|
|
1227
1321
|
onInvalidate(path) {
|
|
1228
|
-
|
|
1322
|
+
isDebug3 && debug4(`Removed cache entry for i18n file ${path}`);
|
|
1229
1323
|
},
|
|
1230
1324
|
onCachedReturn(path) {
|
|
1231
|
-
|
|
1325
|
+
isDebug3 && debug4(`Returning cached entry for i18n file ${path}`);
|
|
1232
1326
|
}
|
|
1233
1327
|
});
|
|
1234
1328
|
}
|
|
@@ -1237,10 +1331,10 @@ var MetadataRepository = class {
|
|
|
1237
1331
|
const provider = {
|
|
1238
1332
|
_byName: /* @__PURE__ */ new Map(),
|
|
1239
1333
|
getId(directory) {
|
|
1240
|
-
return
|
|
1334
|
+
return normalizePath4(directory);
|
|
1241
1335
|
},
|
|
1242
1336
|
async getValue(directory, ctx, importedFrom) {
|
|
1243
|
-
|
|
1337
|
+
isDebug3 && debug4(
|
|
1244
1338
|
`Loading metadata for package at ${directory} (imported from ${importedFrom ?? "N/A"})`
|
|
1245
1339
|
);
|
|
1246
1340
|
const watchFiles = /* @__PURE__ */ new Set();
|
|
@@ -1256,10 +1350,10 @@ var MetadataRepository = class {
|
|
|
1256
1350
|
sourceRoot,
|
|
1257
1351
|
importedFrom
|
|
1258
1352
|
});
|
|
1259
|
-
|
|
1353
|
+
isDebug3 && debug4(`Metadata for '${metadata.name}': %O`, metadata);
|
|
1260
1354
|
if (metadata.type === "pioneer-package") {
|
|
1261
1355
|
const existingMetadata = this._byName.get(metadata.name);
|
|
1262
|
-
if (existingMetadata &&
|
|
1356
|
+
if (existingMetadata && normalizePath4(existingMetadata.directory) !== normalizePath4(metadata.directory)) {
|
|
1263
1357
|
const message = `Encountered the package '${metadata.name}' at two different locations.
|
|
1264
1358
|
Trails packages cannot be used more than once in the same application.
|
|
1265
1359
|
All packages must use a common version of '${metadata.name}'.
|
|
@@ -1277,11 +1371,11 @@ All packages must use a common version of '${metadata.name}'.
|
|
|
1277
1371
|
};
|
|
1278
1372
|
},
|
|
1279
1373
|
onInvalidate(directory, entry) {
|
|
1280
|
-
|
|
1374
|
+
isDebug3 && debug4(`Removed cache entry for '${entry.metadata.name}'`);
|
|
1281
1375
|
this._byName.delete(entry.metadata.name);
|
|
1282
1376
|
},
|
|
1283
1377
|
onCachedReturn(directory, entry) {
|
|
1284
|
-
|
|
1378
|
+
isDebug3 && debug4(`Returning cached metadata for '${entry.metadata.name}'`);
|
|
1285
1379
|
}
|
|
1286
1380
|
};
|
|
1287
1381
|
return new Cache(provider);
|
|
@@ -1311,7 +1405,7 @@ function detectRuntimeMetadataVersion(packages) {
|
|
|
1311
1405
|
);
|
|
1312
1406
|
}
|
|
1313
1407
|
}
|
|
1314
|
-
|
|
1408
|
+
isDebug3 && debug4("Detected runtime version %s", versionResult);
|
|
1315
1409
|
return versionResult;
|
|
1316
1410
|
}
|
|
1317
1411
|
function propagateWatchFiles(watchFiles, ctx) {
|
|
@@ -1348,74 +1442,6 @@ function formatPackage(packageMetadata) {
|
|
|
1348
1442
|
return str;
|
|
1349
1443
|
}
|
|
1350
1444
|
|
|
1351
|
-
// src/metadata/findTrailsPackages.ts
|
|
1352
|
-
import { realpath as realpath2 } from "fs/promises";
|
|
1353
|
-
import { ResolverFactory } from "oxc-resolver";
|
|
1354
|
-
import { dirname as dirname3, posix as posix3 } from "path";
|
|
1355
|
-
import { glob } from "tinyglobby";
|
|
1356
|
-
import { normalizePath as normalizePath4 } from "vite";
|
|
1357
|
-
var isDebug3 = !!process.env.DEBUG;
|
|
1358
|
-
var debug4 = createDebugger("open-pioneer:metadata");
|
|
1359
|
-
async function findTrailsPackages(sourceRoot) {
|
|
1360
|
-
const ctx = createDummyContext();
|
|
1361
|
-
const packageResolver = ResolverFactory.default();
|
|
1362
|
-
const localPackageJsonFiles = await glob("**/package.json", {
|
|
1363
|
-
cwd: sourceRoot,
|
|
1364
|
-
absolute: true,
|
|
1365
|
-
ignore: ["**/node_modules/**"]
|
|
1366
|
-
});
|
|
1367
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1368
|
-
const workQueue = [];
|
|
1369
|
-
const visit = (packageDirectory) => {
|
|
1370
|
-
const normalizedPath = normalizePath4(packageDirectory);
|
|
1371
|
-
if (seen.has(normalizedPath)) {
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
seen.add(normalizedPath);
|
|
1375
|
-
workQueue.push(normalizedPath);
|
|
1376
|
-
};
|
|
1377
|
-
for (const file of localPackageJsonFiles) {
|
|
1378
|
-
visit(dirname3(file));
|
|
1379
|
-
}
|
|
1380
|
-
const trailsPackages = [];
|
|
1381
|
-
while (workQueue.length) {
|
|
1382
|
-
const packageDirectory = workQueue.pop();
|
|
1383
|
-
const pkg2 = await loadPackageMetadata(ctx, packageDirectory, {
|
|
1384
|
-
sourceRoot,
|
|
1385
|
-
importedFrom: void 0,
|
|
1386
|
-
allowMissingBuildConfigInLocalPackage: true
|
|
1387
|
-
});
|
|
1388
|
-
if (pkg2.type === "plain") {
|
|
1389
|
-
continue;
|
|
1390
|
-
}
|
|
1391
|
-
trailsPackages.push(pkg2);
|
|
1392
|
-
for (const dependency of pkg2.dependencies) {
|
|
1393
|
-
const depResult = await packageResolver.async(
|
|
1394
|
-
packageDirectory,
|
|
1395
|
-
dependency.packageName + "/package.json"
|
|
1396
|
-
);
|
|
1397
|
-
if (depResult.path) {
|
|
1398
|
-
const depPath = await realpath2(dirname3(depResult.path));
|
|
1399
|
-
visit(depPath);
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
trailsPackages.sort((p1, p2) => p1.name.localeCompare(p2.name, "en"));
|
|
1404
|
-
return trailsPackages;
|
|
1405
|
-
}
|
|
1406
|
-
function createDummyContext() {
|
|
1407
|
-
return {
|
|
1408
|
-
addWatchFile(_file) {
|
|
1409
|
-
},
|
|
1410
|
-
async resolveLocalFile(moduleId, _packageDir, packageName) {
|
|
1411
|
-
return posix3.join(packageName, moduleId);
|
|
1412
|
-
},
|
|
1413
|
-
warn(message) {
|
|
1414
|
-
isDebug3 && debug4("Problem during trails package discovery: %s", message);
|
|
1415
|
-
}
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
1445
|
// src/metadata/validateI18nConfig.ts
|
|
1420
1446
|
var isDebug4 = !!process.env.DEBUG;
|
|
1421
1447
|
var debug5 = createDebugger("open-pioneer:validateI18nConfig");
|
|
@@ -1505,25 +1531,6 @@ There is no match between the locales supported by the application (${formattedA
|
|
|
1505
1531
|
);
|
|
1506
1532
|
}
|
|
1507
1533
|
|
|
1508
|
-
// src/metadata/Context.ts
|
|
1509
|
-
function createMetadataContextFromRolldown(ctx) {
|
|
1510
|
-
return {
|
|
1511
|
-
addWatchFile: (id) => {
|
|
1512
|
-
ctx.addWatchFile(id);
|
|
1513
|
-
},
|
|
1514
|
-
resolveLocalFile: async (moduleId, _packageName, packageDirectory) => {
|
|
1515
|
-
const importer = `${packageDirectory}/package.json`;
|
|
1516
|
-
const result = await ctx.resolve(moduleId, importer, {
|
|
1517
|
-
skipSelf: true
|
|
1518
|
-
});
|
|
1519
|
-
return result == null ? void 0 : result.id;
|
|
1520
|
-
},
|
|
1521
|
-
warn: (message) => {
|
|
1522
|
-
ctx.warn(message);
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
1534
|
// src/codegenPlugin.ts
|
|
1528
1535
|
var isDebug5 = !!process.env.DEBUG;
|
|
1529
1536
|
var debug6 = createDebugger("open-pioneer:codegen");
|
|
@@ -1767,9 +1774,9 @@ function reportError(ctx, error, isDev) {
|
|
|
1767
1774
|
}
|
|
1768
1775
|
ctx.error({
|
|
1769
1776
|
message,
|
|
1770
|
-
//
|
|
1777
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1771
1778
|
cause: error.cause,
|
|
1772
|
-
//
|
|
1779
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1773
1780
|
stack: error.stack
|
|
1774
1781
|
});
|
|
1775
1782
|
}
|