@absolutejs/absolute 0.19.0-beta.727 → 0.19.0-beta.729

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/build.js CHANGED
@@ -49253,14 +49253,19 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49253
49253
  } catch {
49254
49254
  return false;
49255
49255
  }
49256
- }, isBareSpecifier = (spec) => !spec.startsWith(".") && !spec.startsWith("/") && !spec.startsWith("@src/"), isAbsolutePackageSpecifier = (spec) => spec === "@absolutejs/absolute" || spec.startsWith("@absolutejs/absolute/"), FRAMEWORK_SPECIFIERS, FRAMEWORK_NAMESPACE_PREFIXES, isFrameworkSpecifier = (spec) => FRAMEWORK_SPECIFIERS.has(spec) || FRAMEWORK_NAMESPACE_PREFIXES.some((prefix) => spec.startsWith(prefix)), FRAMEWORK_EXTERNALS, isSkippedFile = (file3) => file3.includes("node_modules") || file3.includes("/build/") || file3.includes("/dist/") || file3.includes("/indexes/"), isDepSpecifier = (path2) => isBareSpecifier(path2) && !isFrameworkSpecifier(path2) && !isAbsolutePackageSpecifier(path2), readFileSpecifiers = async (file3, transpiler4) => {
49257
- const empty = [];
49256
+ }, isBareSpecifier = (spec) => !spec.startsWith(".") && !spec.startsWith("/") && !spec.startsWith("@src/"), isAbsolutePackageSpecifier = (spec) => spec === "@absolutejs/absolute" || spec.startsWith("@absolutejs/absolute/"), FRAMEWORK_SPECIFIERS, FRAMEWORK_NAMESPACE_PREFIXES, isFrameworkSpecifier = (spec) => FRAMEWORK_SPECIFIERS.has(spec) || FRAMEWORK_NAMESPACE_PREFIXES.some((prefix) => spec.startsWith(prefix)), FRAMEWORK_EXTERNALS, isSkippedFile = (file3) => file3.includes("node_modules") || file3.includes("/build/") || file3.includes("/dist/") || file3.includes("/indexes/"), isDepSpecifier = (path2) => isBareSpecifier(path2) && !isFrameworkSpecifier(path2) && !isAbsolutePackageSpecifier(path2), isFrameworkRootCandidate = (path2) => isBareSpecifier(path2) && isFrameworkSpecifier(path2) && !isAbsolutePackageSpecifier(path2), readFileSpecifiers = async (file3, transpiler4) => {
49257
+ const dep = [];
49258
+ const framework = [];
49258
49259
  try {
49259
49260
  const content = await Bun.file(file3).text();
49260
- return transpiler4.scanImports(content).map((imp) => imp.path).filter(isDepSpecifier);
49261
- } catch {
49262
- return empty;
49263
- }
49261
+ for (const imp of transpiler4.scanImports(content)) {
49262
+ if (isDepSpecifier(imp.path))
49263
+ dep.push(imp.path);
49264
+ else if (isFrameworkRootCandidate(imp.path))
49265
+ framework.push(imp.path);
49266
+ }
49267
+ } catch {}
49268
+ return { dep, framework };
49264
49269
  }, scanDirFiles = async (dir) => {
49265
49270
  const empty = [];
49266
49271
  const glob = new Glob9("**/*.{ts,tsx,js,jsx}");
@@ -49270,17 +49275,24 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49270
49275
  } catch {
49271
49276
  return empty;
49272
49277
  }
49273
- }, collectDirSpecifiers = async (dir, transpiler4, specifiers) => {
49278
+ }, collectDirSpecifiers = async (dir, transpiler4, dep, framework) => {
49274
49279
  const files = await scanDirFiles(dir);
49275
49280
  const results = await Promise.all(files.map((file3) => readFileSpecifiers(file3, transpiler4)));
49276
- for (const spec of results.flat()) {
49277
- specifiers.add(spec);
49281
+ for (const result of results) {
49282
+ for (const spec of result.dep)
49283
+ dep.add(spec);
49284
+ for (const spec of result.framework)
49285
+ framework.add(spec);
49278
49286
  }
49279
49287
  }, scanBareImports = async (directories) => {
49280
- const specifiers = new Set;
49288
+ const dep = new Set;
49289
+ const framework = new Set;
49281
49290
  const transpiler4 = new Bun.Transpiler({ loader: "tsx" });
49282
- await Promise.all(directories.map((dir) => collectDirSpecifiers(dir, transpiler4, specifiers)));
49283
- return Array.from(specifiers).filter(isResolvable4);
49291
+ await Promise.all(directories.map((dir) => collectDirSpecifiers(dir, transpiler4, dep, framework)));
49292
+ return {
49293
+ dep: Array.from(dep).filter(isResolvable4),
49294
+ framework: Array.from(framework).filter(isResolvable4)
49295
+ };
49284
49296
  }, generateEntrySource2 = (specifier) => `export * from '${specifier}';
49285
49297
  `, rewriteVendorFiles = async (vendorDir) => {
49286
49298
  const { readdirSync: readdirSync2, readFileSync: readFileSync15, writeFileSync: writeFileSync8 } = await import("fs");
@@ -49299,11 +49311,14 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49299
49311
  if (rewritten !== original)
49300
49312
  writeFileSync8(filePath, rewritten);
49301
49313
  }
49302
- }, collectTransitiveImports = async (specs, alreadyVendored) => {
49314
+ }, collectTransitiveImports = async (specs, alreadyVendored, alreadyScanned) => {
49303
49315
  const { readFileSync: readFileSync15 } = await import("fs");
49304
49316
  const transpiler4 = new Bun.Transpiler({ loader: "js" });
49305
49317
  const newSpecs = new Set;
49306
49318
  for (const spec of specs) {
49319
+ if (alreadyScanned.has(spec))
49320
+ continue;
49321
+ alreadyScanned.add(spec);
49307
49322
  let resolved;
49308
49323
  try {
49309
49324
  resolved = Bun.resolveSync(spec, process.cwd());
@@ -49358,23 +49373,26 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49358
49373
  throw: false
49359
49374
  });
49360
49375
  }, MAX_VENDOR_DISCOVERY_PASSES = 5, buildDepVendor = async (buildDir, directories) => {
49361
- const initialSpecs = await scanBareImports(directories);
49362
- if (initialSpecs.length === 0)
49376
+ const { dep: initialSpecs, framework: frameworkRoots } = await scanBareImports(directories);
49377
+ if (initialSpecs.length === 0 && frameworkRoots.length === 0)
49363
49378
  return {};
49364
49379
  const vendorDir = join22(buildDir, "vendor");
49365
49380
  mkdirSync11(vendorDir, { recursive: true });
49366
49381
  const tmpDir = join22(buildDir, "_dep_vendor_tmp");
49367
49382
  mkdirSync11(tmpDir, { recursive: true });
49368
49383
  const allSpecs = new Set(initialSpecs);
49369
- let frontier = allSpecs;
49384
+ const alreadyScanned = new Set;
49385
+ let frontier = [...allSpecs, ...frameworkRoots];
49370
49386
  for (let pass = 0;pass < MAX_VENDOR_DISCOVERY_PASSES; pass++) {
49371
- const additional = await collectTransitiveImports(frontier, allSpecs);
49387
+ const additional = await collectTransitiveImports(frontier, allSpecs, alreadyScanned);
49372
49388
  if (additional.size === 0)
49373
49389
  break;
49374
49390
  for (const spec of additional)
49375
49391
  allSpecs.add(spec);
49376
49392
  frontier = additional;
49377
49393
  }
49394
+ if (allSpecs.size === 0)
49395
+ return {};
49378
49396
  const result = await buildDepVendorPass(Array.from(allSpecs), vendorDir, tmpDir);
49379
49397
  const success = result.success;
49380
49398
  if (!success) {
@@ -49389,11 +49407,12 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49389
49407
  }
49390
49408
  return paths;
49391
49409
  }, computeDepVendorPaths = async (directories) => {
49392
- const initialSpecs = await scanBareImports(directories);
49410
+ const { dep: initialSpecs, framework: frameworkRoots } = await scanBareImports(directories);
49393
49411
  const allSpecs = new Set(initialSpecs);
49394
- let frontier = allSpecs;
49412
+ const alreadyScanned = new Set;
49413
+ let frontier = [...allSpecs, ...frameworkRoots];
49395
49414
  for (let pass = 0;pass < MAX_VENDOR_DISCOVERY_PASSES; pass++) {
49396
- const additional = await collectTransitiveImports(frontier, allSpecs);
49415
+ const additional = await collectTransitiveImports(frontier, allSpecs, alreadyScanned);
49397
49416
  if (additional.size === 0)
49398
49417
  break;
49399
49418
  for (const spec of additional)
@@ -49771,5 +49790,5 @@ export {
49771
49790
  build
49772
49791
  };
49773
49792
 
49774
- //# debugId=84C23804BCC2DDCF64756E2164756E21
49793
+ //# debugId=6C0C1D8992C0647F64756E2164756E21
49775
49794
  //# sourceMappingURL=build.js.map