@absolutejs/absolute 0.19.0-beta.775 → 0.19.0-beta.776
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/cli/index.js +45 -61
- package/package.json +7 -7
package/dist/cli/index.js
CHANGED
|
@@ -893,9 +893,10 @@ import {
|
|
|
893
893
|
readdirSync as readdirSync2,
|
|
894
894
|
readFileSync as readFileSync9,
|
|
895
895
|
rmSync as rmSync2,
|
|
896
|
-
unlinkSync as unlinkSync2
|
|
896
|
+
unlinkSync as unlinkSync2,
|
|
897
|
+
writeFileSync as writeFileSync3
|
|
897
898
|
} from "fs";
|
|
898
|
-
import { basename as basename2, join as join6, relative, resolve as resolve8 } from "path";
|
|
899
|
+
import { basename as basename2, dirname as dirname2, join as join6, relative, resolve as resolve8 } from "path";
|
|
899
900
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
900
901
|
const resolvedVersion = version2 || "unknown";
|
|
901
902
|
console.log("");
|
|
@@ -1045,6 +1046,47 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1045
1046
|
specifiers.push(entry.name);
|
|
1046
1047
|
}
|
|
1047
1048
|
return specifiers.sort((a, b) => b.length - a.length);
|
|
1049
|
+
}, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
1050
|
+
const rel = relative(dirname2(fromFile), toFile).replace(/\\/g, "/");
|
|
1051
|
+
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
1052
|
+
}, resolvePackageEntryFile = (distDir, packageSpecifiers, specifier) => {
|
|
1053
|
+
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
1054
|
+
if (!packageSpecifier)
|
|
1055
|
+
return null;
|
|
1056
|
+
const packageDir = join6(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
1057
|
+
const subpath = specifier.slice(packageSpecifier.length);
|
|
1058
|
+
const subPackageDir = subpath ? join6(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
1059
|
+
const resolvedPackageDir = subPackageDir && existsSync9(join6(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
1060
|
+
const packageJsonPath = join6(resolvedPackageDir, "package.json");
|
|
1061
|
+
if (!existsSync9(packageJsonPath))
|
|
1062
|
+
return null;
|
|
1063
|
+
const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
|
|
1064
|
+
const exportKey = resolvedPackageDir === subPackageDir ? "." : subpath ? `.${subpath}` : ".";
|
|
1065
|
+
const rootExport = pkg.exports?.[exportKey];
|
|
1066
|
+
const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
1067
|
+
return join6(resolvedPackageDir, entry);
|
|
1068
|
+
}, rewriteRuntimeModuleSpecifiers = (distDir) => {
|
|
1069
|
+
const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
|
|
1070
|
+
if (packageSpecifiers.length === 0)
|
|
1071
|
+
return;
|
|
1072
|
+
for (const filePath of collectFiles2(distDir)) {
|
|
1073
|
+
if (!/\.(cjs|js|mjs)$/.test(filePath))
|
|
1074
|
+
continue;
|
|
1075
|
+
const source = readFileSync9(filePath, "utf-8");
|
|
1076
|
+
let rewritten = source;
|
|
1077
|
+
for (const specifier of packageSpecifiers) {
|
|
1078
|
+
const pattern = new RegExp(`(from\\s*|import\\s*|import\\(\\s*|require\\(\\s*)(["'])(${escapeRegExp(specifier)}(?:/[^"']+)?)\\2`, "g");
|
|
1079
|
+
rewritten = rewritten.replace(pattern, (match, prefix, quote, fullSpecifier) => {
|
|
1080
|
+
const target = resolvePackageEntryFile(distDir, packageSpecifiers, fullSpecifier);
|
|
1081
|
+
if (!target)
|
|
1082
|
+
return match;
|
|
1083
|
+
return `${prefix}${quote}${ensureRelativeModuleSpecifier(filePath, target)}${quote}`;
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
if (rewritten !== source) {
|
|
1087
|
+
writeFileSync3(filePath, rewritten);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1048
1090
|
}, generateEntrypoint = (distDir, serverEntry, prerenderMap, version2, buildConfig) => {
|
|
1049
1091
|
const allFiles = collectFiles2(distDir);
|
|
1050
1092
|
const serverBundleName = `${basename2(serverEntry).replace(/\.[^.]+$/, "")}.js`;
|
|
@@ -1094,7 +1136,6 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
1094
1136
|
});
|
|
1095
1137
|
const routeEntries = Array.from(pageVarMap.entries()).map(([route, varName]) => ` "${route}": ${varName},`).join(`
|
|
1096
1138
|
`);
|
|
1097
|
-
const runtimePackageSpecifiers = collectRuntimePackageSpecifiers(distDir);
|
|
1098
1139
|
const runtimeBuildId = `${version2}-${Date.now().toString(36)}`;
|
|
1099
1140
|
const runtimeConfigSource = JSON.stringify(buildConfig, (_key, value) => typeof value === "function" || typeof value === "symbol" ? undefined : value, 2);
|
|
1100
1141
|
return `// Auto-generated compile entrypoint
|
|
@@ -1115,7 +1156,6 @@ const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
|
1115
1156
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
1116
1157
|
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve8(distDir))};
|
|
1117
1158
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
1118
|
-
const RUNTIME_PACKAGE_SPECIFIERS = ${JSON.stringify(runtimePackageSpecifiers)};
|
|
1119
1159
|
|
|
1120
1160
|
// \u2500\u2500 Asset URL \u2192 embedded path map \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1121
1161
|
const ASSETS: Record<string, string> = {
|
|
@@ -1199,7 +1239,6 @@ const materializeRuntimeFiles = async () => {
|
|
|
1199
1239
|
);
|
|
1200
1240
|
rewriteRuntimeJsonPaths(runtimeDir, "manifest.json");
|
|
1201
1241
|
rewriteRuntimeJsonPaths(runtimeDir, "conventions.json");
|
|
1202
|
-
rewriteRuntimeModuleSpecifiers(runtimeDir);
|
|
1203
1242
|
writeFileSync(marker, String(Date.now()));
|
|
1204
1243
|
|
|
1205
1244
|
return { configPath, runtimeDir };
|
|
@@ -1237,62 +1276,6 @@ const rewriteRuntimeJsonPaths = (runtimeDir: string, fileName: string) => {
|
|
|
1237
1276
|
writeFileSync(filePath, JSON.stringify(rewritten, null, "\\t"));
|
|
1238
1277
|
};
|
|
1239
1278
|
|
|
1240
|
-
const escapeRegExp = (value: string) =>
|
|
1241
|
-
value.replace(/[.*+?^${"{}"}()|[\\]\\\\]/g, "\\\\$&");
|
|
1242
|
-
|
|
1243
|
-
const resolveRuntimePackageEntry = (runtimeDir: string, specifier: string) => {
|
|
1244
|
-
const packageSpecifier = RUNTIME_PACKAGE_SPECIFIERS.find(
|
|
1245
|
-
(root) => specifier === root || specifier.startsWith(root + "/")
|
|
1246
|
-
);
|
|
1247
|
-
if (!packageSpecifier) return specifier;
|
|
1248
|
-
|
|
1249
|
-
const packageDir = join(runtimeDir, "node_modules", ...packageSpecifier.split("/"));
|
|
1250
|
-
const subpath = specifier.slice(packageSpecifier.length);
|
|
1251
|
-
const subPackageDir = subpath ? join(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
1252
|
-
const resolvedPackageDir =
|
|
1253
|
-
subPackageDir && existsSync(join(subPackageDir, "package.json"))
|
|
1254
|
-
? subPackageDir
|
|
1255
|
-
: packageDir;
|
|
1256
|
-
const packageJsonPath = join(resolvedPackageDir, "package.json");
|
|
1257
|
-
if (!existsSync(packageJsonPath)) return pathToFileURL(packageDir).href;
|
|
1258
|
-
|
|
1259
|
-
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
1260
|
-
const exportKey = resolvedPackageDir === subPackageDir ? "." : subpath ? "." + subpath : ".";
|
|
1261
|
-
const rootExport = pkg.exports?.[exportKey];
|
|
1262
|
-
const entry =
|
|
1263
|
-
(typeof rootExport === "string" ? rootExport : rootExport?.default) ??
|
|
1264
|
-
(resolvedPackageDir === subPackageDir || !subpath
|
|
1265
|
-
? (pkg.module ?? pkg.main ?? "index.js")
|
|
1266
|
-
: "." + subpath);
|
|
1267
|
-
|
|
1268
|
-
return pathToFileURL(join(resolvedPackageDir, entry)).href;
|
|
1269
|
-
};
|
|
1270
|
-
|
|
1271
|
-
const rewriteRuntimeModuleSpecifiers = (runtimeDir: string) => {
|
|
1272
|
-
if (RUNTIME_PACKAGE_SPECIFIERS.length === 0) return;
|
|
1273
|
-
|
|
1274
|
-
for (const [rel] of EMBEDDED_FILES) {
|
|
1275
|
-
if (!/\\.(cjs|js|mjs)$/.test(rel)) continue;
|
|
1276
|
-
const filePath = join(runtimeDir, rel);
|
|
1277
|
-
if (!existsSync(filePath)) continue;
|
|
1278
|
-
|
|
1279
|
-
let source = readFileSync(filePath, "utf-8");
|
|
1280
|
-
let rewritten = source;
|
|
1281
|
-
for (const specifier of RUNTIME_PACKAGE_SPECIFIERS) {
|
|
1282
|
-
const pattern = new RegExp(
|
|
1283
|
-
\`(from\\\\s*|import\\\\s*|import\\\\(\\\\s*|require\\\\(\\\\s*)(["'])(\${escapeRegExp(specifier)}(?:/[^"']+)?)\\\\2\`,
|
|
1284
|
-
"g"
|
|
1285
|
-
);
|
|
1286
|
-
rewritten = rewritten.replace(
|
|
1287
|
-
pattern,
|
|
1288
|
-
(_match, prefix, quote, fullSpecifier) =>
|
|
1289
|
-
\`\${prefix}\${quote}\${resolveRuntimePackageEntry(runtimeDir, fullSpecifier)}\${quote}\`
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
if (rewritten !== source) writeFileSync(filePath, rewritten);
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
1279
|
const resolveRuntimeFetch = async () => {
|
|
1297
1280
|
const { configPath, runtimeDir } = await materializeRuntimeFiles();
|
|
1298
1281
|
process.env.ABSOLUTE_BUILD_DIR = runtimeDir;
|
|
@@ -1543,6 +1526,7 @@ console.log(\`
|
|
|
1543
1526
|
const prerenderMap = prerenderResult.routes;
|
|
1544
1527
|
console.log(` \x1B[2m(${prerenderMap.size} pages, ${getDurationString(performance.now() - prerenderStart)})\x1B[0m`);
|
|
1545
1528
|
copyAngularRuntimePackages(buildConfig, resolvedOutdir);
|
|
1529
|
+
rewriteRuntimeModuleSpecifiers(resolvedOutdir);
|
|
1546
1530
|
const compileStart = performance.now();
|
|
1547
1531
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
1548
1532
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
package/package.json
CHANGED
|
@@ -186,12 +186,12 @@
|
|
|
186
186
|
"main": "./dist/index.js",
|
|
187
187
|
"name": "@absolutejs/absolute",
|
|
188
188
|
"optionalDependencies": {
|
|
189
|
-
"@absolutejs/native-darwin-arm64": "0.19.0-beta.
|
|
190
|
-
"@absolutejs/native-darwin-x64": "0.19.0-beta.
|
|
191
|
-
"@absolutejs/native-linux-arm64": "0.19.0-beta.
|
|
192
|
-
"@absolutejs/native-linux-x64": "0.19.0-beta.
|
|
193
|
-
"@absolutejs/native-windows-arm64": "0.19.0-beta.
|
|
194
|
-
"@absolutejs/native-windows-x64": "0.19.0-beta.
|
|
189
|
+
"@absolutejs/native-darwin-arm64": "0.19.0-beta.776",
|
|
190
|
+
"@absolutejs/native-darwin-x64": "0.19.0-beta.776",
|
|
191
|
+
"@absolutejs/native-linux-arm64": "0.19.0-beta.776",
|
|
192
|
+
"@absolutejs/native-linux-x64": "0.19.0-beta.776",
|
|
193
|
+
"@absolutejs/native-windows-arm64": "0.19.0-beta.776",
|
|
194
|
+
"@absolutejs/native-windows-x64": "0.19.0-beta.776"
|
|
195
195
|
},
|
|
196
196
|
"overrides": {
|
|
197
197
|
"@typescript-eslint/utils": "8.56.1"
|
|
@@ -344,5 +344,5 @@
|
|
|
344
344
|
]
|
|
345
345
|
}
|
|
346
346
|
},
|
|
347
|
-
"version": "0.19.0-beta.
|
|
347
|
+
"version": "0.19.0-beta.776"
|
|
348
348
|
}
|