@absolutejs/absolute 0.19.0-beta.776 → 0.19.0-beta.778

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,6 +893,7 @@ import {
893
893
  readdirSync as readdirSync2,
894
894
  readFileSync as readFileSync9,
895
895
  rmSync as rmSync2,
896
+ statSync,
896
897
  unlinkSync as unlinkSync2,
897
898
  writeFileSync as writeFileSync3
898
899
  } from "fs";
@@ -1024,6 +1025,16 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1024
1025
  for (const specifier of roots) {
1025
1026
  copyPackageToBuild(specifier, outdir, seen);
1026
1027
  }
1028
+ }, copyFrameworkRuntimePackages = (buildConfig, outdir) => {
1029
+ const seen = new Set;
1030
+ if (buildConfig.svelteDirectory) {
1031
+ copyPackageToBuild("svelte", outdir, seen);
1032
+ }
1033
+ if (buildConfig.vueDirectory) {
1034
+ copyPackageToBuild("vue", outdir, seen);
1035
+ copyPackageToBuild("@vue/server-renderer", outdir, seen);
1036
+ }
1037
+ copyAngularRuntimePackages(buildConfig, outdir);
1027
1038
  }, collectRuntimePackageSpecifiers = (distDir) => {
1028
1039
  const nodeModulesDir = join6(distDir, "node_modules");
1029
1040
  if (!existsSync9(nodeModulesDir))
@@ -1046,9 +1057,21 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1046
1057
  specifiers.push(entry.name);
1047
1058
  }
1048
1059
  return specifiers.sort((a, b) => b.length - a.length);
1049
- }, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ensureRelativeModuleSpecifier = (fromFile, toFile) => {
1060
+ }, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
1050
1061
  const rel = relative(dirname2(fromFile), toFile).replace(/\\/g, "/");
1051
1062
  return rel.startsWith(".") ? rel : `./${rel}`;
1063
+ }, pickExportEntry = (value) => {
1064
+ if (typeof value === "string")
1065
+ return value;
1066
+ if (!value || typeof value !== "object")
1067
+ return;
1068
+ const record = value;
1069
+ for (const key of ["bun", "node", "import", "module", "default"]) {
1070
+ const entry = pickExportEntry(record[key]);
1071
+ if (entry)
1072
+ return entry;
1073
+ }
1074
+ return;
1052
1075
  }, resolvePackageEntryFile = (distDir, packageSpecifiers, specifier) => {
1053
1076
  const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
1054
1077
  if (!packageSpecifier)
@@ -1063,26 +1086,78 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
1063
1086
  const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
1064
1087
  const exportKey = resolvedPackageDir === subPackageDir ? "." : subpath ? `.${subpath}` : ".";
1065
1088
  const rootExport = pkg.exports?.[exportKey];
1066
- const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
1089
+ const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
1067
1090
  return join6(resolvedPackageDir, entry);
1068
- }, rewriteRuntimeModuleSpecifiers = (distDir) => {
1091
+ }, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
1092
+ try {
1093
+ return statSync(filePath).isFile();
1094
+ } catch {
1095
+ return false;
1096
+ }
1097
+ }, resolveRuntimeJsFile = (candidate) => {
1098
+ if (!candidate)
1099
+ return null;
1100
+ const candidates = [
1101
+ candidate,
1102
+ ...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
1103
+ ...RUNTIME_JS_EXTENSIONS.map((extension) => join6(candidate, `index${extension}`))
1104
+ ];
1105
+ return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
1106
+ }, findContainingRuntimePackageDir = (filePath) => {
1107
+ let dir = dirname2(filePath);
1108
+ while (dir !== dirname2(dir)) {
1109
+ if (isNodeModulesPath(dir) && existsSync9(join6(dir, "package.json"))) {
1110
+ return dir;
1111
+ }
1112
+ dir = dirname2(dir);
1113
+ }
1114
+ return null;
1115
+ }, resolvePackageImportEntryFile = (fromFile, specifier) => {
1116
+ if (!specifier.startsWith("#"))
1117
+ return null;
1118
+ const packageDir = findContainingRuntimePackageDir(fromFile);
1119
+ if (!packageDir)
1120
+ return null;
1121
+ const pkg = tryReadNodePackageJson(packageDir);
1122
+ const entry = pickExportEntry(pkg?.imports?.[specifier]);
1123
+ if (!entry)
1124
+ return null;
1125
+ return join6(packageDir, entry);
1126
+ }, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), rewriteRuntimeModuleSpecifiers = (distDir) => {
1069
1127
  const packageSpecifiers = collectRuntimePackageSpecifiers(distDir);
1070
1128
  if (packageSpecifiers.length === 0)
1071
1129
  return;
1072
- for (const filePath of collectFiles2(distDir)) {
1073
- if (!/\.(cjs|js|mjs)$/.test(filePath))
1130
+ const pending = collectRuntimeRewriteRoots(distDir);
1131
+ const seen = new Set;
1132
+ const enqueue = (filePath) => {
1133
+ if (!filePath || seen.has(filePath) || !isRuntimeJsFile(filePath))
1134
+ return;
1135
+ if (!isFile(filePath))
1136
+ return;
1137
+ pending.push(filePath);
1138
+ };
1139
+ for (let index = 0;index < pending.length; index += 1) {
1140
+ const filePath = pending[index];
1141
+ if (!filePath || seen.has(filePath))
1074
1142
  continue;
1143
+ seen.add(filePath);
1075
1144
  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
- }
1145
+ const rewritten = source.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
1146
+ if (typeof specifier === "string" && specifier.startsWith(".")) {
1147
+ enqueue(resolveRuntimeJsFile(resolve8(dirname2(filePath), specifier)));
1148
+ return match;
1149
+ }
1150
+ const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
1151
+ if (packageImportTarget) {
1152
+ enqueue(packageImportTarget);
1153
+ return `${prefix}${quote}${ensureRelativeModuleSpecifier(filePath, packageImportTarget)}${quote}`;
1154
+ }
1155
+ const target = resolveRuntimeJsFile(resolvePackageEntryFile(distDir, packageSpecifiers, specifier) ?? "");
1156
+ if (!target)
1157
+ return match;
1158
+ enqueue(target);
1159
+ return `${prefix}${quote}${ensureRelativeModuleSpecifier(filePath, target)}${quote}`;
1160
+ });
1086
1161
  if (rewritten !== source) {
1087
1162
  writeFileSync3(filePath, rewritten);
1088
1163
  }
@@ -1525,7 +1600,7 @@ console.log(\`
1525
1600
  });
1526
1601
  const prerenderMap = prerenderResult.routes;
1527
1602
  console.log(` \x1B[2m(${prerenderMap.size} pages, ${getDurationString(performance.now() - prerenderStart)})\x1B[0m`);
1528
- copyAngularRuntimePackages(buildConfig, resolvedOutdir);
1603
+ copyFrameworkRuntimePackages(buildConfig, resolvedOutdir);
1529
1604
  rewriteRuntimeModuleSpecifiers(resolvedOutdir);
1530
1605
  const compileStart = performance.now();
1531
1606
  process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
@@ -1575,6 +1650,8 @@ var init_compile = __esm(() => {
1575
1650
  init_telemetryEvent();
1576
1651
  init_utils();
1577
1652
  jsxDevRuntimeCompatPath2 = resolveJsxDevRuntimeCompatPath2();
1653
+ RUNTIME_JS_EXTENSIONS = [".js", ".mjs", ".cjs"];
1654
+ MODULE_SPECIFIER_RE = /(from\s*|import\s*|import\(\s*|require\(\s*)(["'])([^"']+)\2/g;
1578
1655
  FRAMEWORK_EXTERNALS = [
1579
1656
  "react",
1580
1657
  "react/jsx-runtime",
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