@absolutejs/absolute 0.19.0-beta.713 → 0.19.0-beta.715

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
@@ -49291,14 +49291,46 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49291
49291
  if (rewritten !== original)
49292
49292
  writeFileSync8(filePath, rewritten);
49293
49293
  }
49294
- }, buildDepVendor = async (buildDir, directories) => {
49295
- const specifiers = await scanBareImports(directories);
49296
- if (specifiers.length === 0)
49297
- return {};
49298
- const vendorDir = join22(buildDir, "vendor");
49299
- mkdirSync11(vendorDir, { recursive: true });
49300
- const tmpDir = join22(buildDir, "_dep_vendor_tmp");
49301
- mkdirSync11(tmpDir, { recursive: true });
49294
+ }, collectTransitiveImports = async (specs, alreadyVendored) => {
49295
+ const { readFileSync: readFileSync15 } = await import("fs");
49296
+ const transpiler4 = new Bun.Transpiler({ loader: "js" });
49297
+ const newSpecs = new Set;
49298
+ for (const spec of specs) {
49299
+ let resolved;
49300
+ try {
49301
+ resolved = Bun.resolveSync(spec, process.cwd());
49302
+ } catch {
49303
+ continue;
49304
+ }
49305
+ let content;
49306
+ try {
49307
+ content = readFileSync15(resolved, "utf-8");
49308
+ } catch {
49309
+ continue;
49310
+ }
49311
+ let imports;
49312
+ try {
49313
+ imports = transpiler4.scanImports(content);
49314
+ } catch {
49315
+ continue;
49316
+ }
49317
+ for (const imp of imports) {
49318
+ const child = imp.path;
49319
+ if (!isBareSpecifier(child))
49320
+ continue;
49321
+ if (isFrameworkSpecifier(child))
49322
+ continue;
49323
+ if (isAbsolutePackageSpecifier(child))
49324
+ continue;
49325
+ if (alreadyVendored.has(child))
49326
+ continue;
49327
+ if (!isResolvable4(child))
49328
+ continue;
49329
+ newSpecs.add(child);
49330
+ }
49331
+ }
49332
+ return newSpecs;
49333
+ }, buildDepVendorPass = async (specifiers, vendorDir, tmpDir) => {
49302
49334
  const entrypoints = await Promise.all(specifiers.map(async (specifier) => {
49303
49335
  const safeName = toSafeFileName5(specifier);
49304
49336
  const entryPath = join22(tmpDir, `${safeName}.ts`);
@@ -49306,7 +49338,7 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49306
49338
  await Bun.write(entryPath, source);
49307
49339
  return entryPath;
49308
49340
  }));
49309
- const result = await bunBuild8({
49341
+ return bunBuild8({
49310
49342
  entrypoints,
49311
49343
  external: FRAMEWORK_EXTERNALS,
49312
49344
  format: "esm",
@@ -49317,14 +49349,34 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
49317
49349
  target: "browser",
49318
49350
  throw: false
49319
49351
  });
49320
- await rm9(tmpDir, { force: true, recursive: true });
49321
- if (!result.success) {
49352
+ }, MAX_VENDOR_DISCOVERY_PASSES = 5, buildDepVendor = async (buildDir, directories) => {
49353
+ const initialSpecs = await scanBareImports(directories);
49354
+ if (initialSpecs.length === 0)
49355
+ return {};
49356
+ const vendorDir = join22(buildDir, "vendor");
49357
+ mkdirSync11(vendorDir, { recursive: true });
49358
+ const tmpDir = join22(buildDir, "_dep_vendor_tmp");
49359
+ mkdirSync11(tmpDir, { recursive: true });
49360
+ const allSpecs = new Set(initialSpecs);
49361
+ let frontier = allSpecs;
49362
+ for (let pass = 0;pass < MAX_VENDOR_DISCOVERY_PASSES; pass++) {
49363
+ const additional = await collectTransitiveImports(frontier, allSpecs);
49364
+ if (additional.size === 0)
49365
+ break;
49366
+ for (const spec of additional)
49367
+ allSpecs.add(spec);
49368
+ frontier = additional;
49369
+ }
49370
+ const result = await buildDepVendorPass(Array.from(allSpecs), vendorDir, tmpDir);
49371
+ const success = result.success;
49372
+ if (!success) {
49322
49373
  console.warn("\u26A0\uFE0F Dependency vendor build had errors:", result.logs);
49323
49374
  }
49324
- if (result.success)
49375
+ await rm9(tmpDir, { force: true, recursive: true });
49376
+ if (success)
49325
49377
  await rewriteVendorFiles(vendorDir);
49326
49378
  const paths = {};
49327
- for (const specifier of specifiers) {
49379
+ for (const specifier of allSpecs) {
49328
49380
  paths[specifier] = `/vendor/${toSafeFileName5(specifier)}.js`;
49329
49381
  }
49330
49382
  return paths;
@@ -49701,5 +49753,5 @@ export {
49701
49753
  build
49702
49754
  };
49703
49755
 
49704
- //# debugId=CB93EE6A1744026C64756E2164756E21
49756
+ //# debugId=3B3195FA2C1847A964756E2164756E21
49705
49757
  //# sourceMappingURL=build.js.map