@ecopages/core 0.2.0-alpha.44 → 0.2.0-alpha.46
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.46",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"directory": "packages/core"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ecopages/file-system": "0.2.0-alpha.
|
|
20
|
+
"@ecopages/file-system": "0.2.0-alpha.46",
|
|
21
21
|
"@ecopages/logger": "^0.2.3",
|
|
22
22
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
23
23
|
"@worker-tools/html-rewriter": "0.1.0-pre.19",
|
|
@@ -46,6 +46,54 @@ function resolveRuntimePackageRoot(specifier, resolvedPath, parentPath) {
|
|
|
46
46
|
const packageName = getPackageNameFromSpecifier(specifier);
|
|
47
47
|
return findInstalledPackageDir(packageName, parentPath) ?? findPackageRoot(resolvedPath);
|
|
48
48
|
}
|
|
49
|
+
function getNodeExternalSpecifier(specifier, resolvedPath, parentPath) {
|
|
50
|
+
const packageName = getPackageNameFromSpecifier(specifier);
|
|
51
|
+
if (specifier === packageName) {
|
|
52
|
+
return specifier;
|
|
53
|
+
}
|
|
54
|
+
if (path.extname(specifier)) {
|
|
55
|
+
return specifier;
|
|
56
|
+
}
|
|
57
|
+
for (const extension of [".js", ".mjs", ".cjs", ".json"]) {
|
|
58
|
+
const candidateSpecifier = `${specifier}${extension}`;
|
|
59
|
+
try {
|
|
60
|
+
const candidateResolvedPath = resolveSpecifier(candidateSpecifier, parentPath);
|
|
61
|
+
if (existsSync(candidateResolvedPath)) {
|
|
62
|
+
return candidateSpecifier;
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
for (const candidatePath of [
|
|
68
|
+
resolvedPath,
|
|
69
|
+
...[".js", ".mjs", ".cjs", ".json"].map((extension) => `${specifier}${extension}`)
|
|
70
|
+
]) {
|
|
71
|
+
const candidateResolvedPath = candidatePath === resolvedPath ? resolvedPath : (() => {
|
|
72
|
+
try {
|
|
73
|
+
return resolveSpecifier(candidatePath, parentPath);
|
|
74
|
+
} catch {
|
|
75
|
+
return void 0;
|
|
76
|
+
}
|
|
77
|
+
})();
|
|
78
|
+
if (!candidateResolvedPath) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (!existsSync(candidateResolvedPath)) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const resolvedExtension = path.extname(candidateResolvedPath);
|
|
85
|
+
if (![".js", ".mjs", ".cjs", ".json"].includes(resolvedExtension)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const packageRoot = resolveRuntimePackageRoot(specifier, candidateResolvedPath, parentPath);
|
|
89
|
+
const requestedSubpath = specifier.slice(packageName.length + 1);
|
|
90
|
+
const resolvedSubpath = path.relative(packageRoot, candidateResolvedPath);
|
|
91
|
+
if (resolvedSubpath === `${requestedSubpath}${resolvedExtension}`) {
|
|
92
|
+
return `${specifier}${resolvedExtension}`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return specifier;
|
|
96
|
+
}
|
|
49
97
|
function ensureRuntimePackageLink(nodeModulesDir, specifier, resolvedPath, parentPath) {
|
|
50
98
|
const packageName = getPackageNameFromSpecifier(specifier);
|
|
51
99
|
const packageRoot = resolveRuntimePackageRoot(specifier, resolvedPath, parentPath);
|
|
@@ -256,7 +304,7 @@ function resolveNodeBootstrapDependency(args, options) {
|
|
|
256
304
|
const resolvedPath = resolveSpecifier(args.path, resolveParent);
|
|
257
305
|
ensureRuntimePackageLink(options.runtimeNodeModulesDir, args.path, resolvedPath, resolveParent);
|
|
258
306
|
return {
|
|
259
|
-
path: args.path,
|
|
307
|
+
path: getNodeExternalSpecifier(args.path, resolvedPath, resolveParent),
|
|
260
308
|
external: true
|
|
261
309
|
};
|
|
262
310
|
}
|