@absolutejs/absolute 0.19.0-beta.775 → 0.19.0-beta.777

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 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/dist/index.js CHANGED
@@ -5520,12 +5520,9 @@ var compilerCache, cachedTailwindCompile = null, loadTailwindCompile = async ()
5520
5520
  for (const source of sources) {
5521
5521
  if (source.negated)
5522
5522
  continue;
5523
- const root = resolve2(source.base);
5524
- if (!absFile.startsWith(`${root}/`) && absFile !== root)
5525
- continue;
5526
- const relative2 = absFile.slice(root.length + 1) || "";
5527
- const glob = new Bun.Glob(source.pattern);
5528
- if (glob.match(relative2) || glob.match(absFile))
5523
+ const absolutePattern = resolve2(source.base, source.pattern);
5524
+ const glob = new Bun.Glob(absolutePattern);
5525
+ if (glob.match(absFile))
5529
5526
  return true;
5530
5527
  }
5531
5528
  return false;
@@ -5549,12 +5546,25 @@ var compilerCache, cachedTailwindCompile = null, loadTailwindCompile = async ()
5549
5546
  entry.perFileCandidates.set(file, freshCandidates);
5550
5547
  for (const candidate of freshCandidates)
5551
5548
  incrementCandidateCount(entry, candidate);
5549
+ }, splitGlobAtFirstMeta = (absolutePattern) => {
5550
+ const firstMetaIndex = absolutePattern.search(/[*?{[]/);
5551
+ if (firstMetaIndex === -1) {
5552
+ return { glob: "", root: absolutePattern };
5553
+ }
5554
+ const lastSlashBeforeMeta = absolutePattern.lastIndexOf("/", firstMetaIndex);
5555
+ return {
5556
+ glob: absolutePattern.slice(lastSlashBeforeMeta + 1),
5557
+ root: absolutePattern.slice(0, lastSlashBeforeMeta) || "/"
5558
+ };
5552
5559
  }, collectFilesForSources = async (sources) => {
5553
5560
  const seen = new Set;
5554
5561
  const collected = [];
5555
5562
  const scans = sources.filter((source) => !source.negated).map(async (source) => {
5556
- const root = resolve2(source.base);
5557
- const glob = new Bun.Glob(source.pattern);
5563
+ const absolutePattern = resolve2(source.base, source.pattern);
5564
+ const { glob: relativePattern, root } = splitGlobAtFirstMeta(absolutePattern);
5565
+ if (!relativePattern)
5566
+ return [];
5567
+ const glob = new Bun.Glob(relativePattern);
5558
5568
  const matches = [];
5559
5569
  for await (const relative2 of glob.scan({
5560
5570
  absolute: false,
@@ -26393,5 +26403,5 @@ export {
26393
26403
  ANGULAR_INIT_TIMEOUT_MS
26394
26404
  };
26395
26405
 
26396
- //# debugId=52CC4E293EDAC09064756E2164756E21
26406
+ //# debugId=F5298FBD548286E764756E2164756E21
26397
26407
  //# sourceMappingURL=index.js.map