@absolutejs/absolute 0.20.0-beta.76 → 0.20.0-beta.78

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/index.js CHANGED
@@ -28804,6 +28804,7 @@ __export(exports_moduleServer, {
28804
28804
  SRC_URL_PREFIX: () => SRC_URL_PREFIX2,
28805
28805
  createDevPageWarmer: () => createDevPageWarmer,
28806
28806
  createModuleServer: () => createModuleServer,
28807
+ importedBindingNames: () => importedBindingNames,
28807
28808
  invalidateModule: () => invalidateModule,
28808
28809
  isReactFastRefreshSupported: () => isReactFastRefreshSupported,
28809
28810
  runOnDemandPageBuild: () => runOnDemandPageBuild,
@@ -28847,6 +28848,12 @@ ${stubs}
28847
28848
  } catch {
28848
28849
  return null;
28849
28850
  }
28851
+ }, importedBindingNames = (clause) => {
28852
+ const braces = /\{([^}]*)\}/u.exec(clause);
28853
+ const inner = braces?.[1];
28854
+ if (inner === undefined)
28855
+ return [];
28856
+ return inner.split(",").map((part) => part.trim()).filter((part) => part.length > 0).map((part) => part.replace(/^type\s+/u, "").split(/\s+as\s+/u)[0] ?? "").map((name) => name.trim()).filter((name) => /^[A-Za-z_$][\w$]*$/u.test(name));
28850
28857
  }, buildImportRewriter = (vendorPaths) => {
28851
28858
  const entries = Object.entries(vendorPaths).sort(([a], [b2]) => b2.length - a.length);
28852
28859
  if (entries.length === 0)
@@ -28936,7 +28943,9 @@ ${stubs}
28936
28943
  if (resolved) {
28937
28944
  return `${prefix}${srcUrl(resolved, projectRoot)}${suffix}`;
28938
28945
  }
28939
- return `${prefix}/@stub/${encodeURIComponent(specifier)}${suffix}`;
28946
+ const requested = importedBindingNames(prefix);
28947
+ const namesSegment = requested.length > 0 ? `/${encodeURIComponent(requested.join(","))}` : "";
28948
+ return `${prefix}/@stub/${encodeURIComponent(specifier)}${namesSegment}${suffix}`;
28940
28949
  };
28941
28950
  result = result.replace(/^((?:import\s+[^"'`;]+?\s+from|export\s+[^"'`;]+?\s+from|import)\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
28942
28951
  result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
@@ -29393,8 +29402,10 @@ ${code2}`;
29393
29402
  ].join(`
29394
29403
  `);
29395
29404
  }, handleStubRequest = async (pathname) => {
29396
- const specifier = decodeURIComponent(pathname.slice("/@stub/".length));
29397
- const stubCode = await buildStubCode(specifier);
29405
+ const [encodedSpecifier = "", encodedNames] = pathname.slice("/@stub/".length).split("/");
29406
+ const specifier = decodeURIComponent(encodedSpecifier);
29407
+ const requested = encodedNames === undefined ? [] : decodeURIComponent(encodedNames).split(",").filter((name) => name.length > 0);
29408
+ const stubCode = await buildStubCode(specifier, requested);
29398
29409
  return new Response(stubCode, {
29399
29410
  headers: {
29400
29411
  "Cache-Control": "no-cache",
@@ -29406,22 +29417,17 @@ ${code2}`;
29406
29417
  "Cache-Control": "no-cache",
29407
29418
  "Content-Type": "application/javascript"
29408
29419
  }
29409
- }), buildStubCode = async (specifier) => {
29410
- try {
29411
- const mod = await import(specifier);
29412
- const names = Object.keys(mod).filter((key) => key !== "default" && key !== "__esModule");
29413
- if (names.length === 0)
29414
- return `export default {};
29420
+ }), buildStubCode = async (specifier, requested = []) => {
29421
+ const discovered = await import(specifier).then((mod) => Object.keys(mod).filter((key) => key !== "default" && key !== "__esModule"), () => []);
29422
+ const names = [...new Set([...discovered, ...requested])];
29423
+ if (names.length === 0)
29424
+ return `export default {};
29415
29425
  `;
29416
- const noops = names.map((n) => `export const ${n} = () => {};`).join(`
29426
+ const noops = names.map((name) => `export const ${name} = () => {};`).join(`
29417
29427
  `);
29418
- return `${noops}
29428
+ return `${noops}
29419
29429
  export default {};
29420
29430
  `;
29421
- } catch {
29422
- return `export default {};
29423
- `;
29424
- }
29425
29431
  }, handleHmrBootstrap = (pathname, vendorPaths) => {
29426
29432
  const rest = pathname.slice("/@hmr/".length);
29427
29433
  const slashIdx = rest.indexOf("/");
@@ -32876,6 +32882,7 @@ var init_rebuildTrigger = __esm(() => {
32876
32882
  var exports_buildDepVendor = {};
32877
32883
  __export(exports_buildDepVendor, {
32878
32884
  buildDepVendor: () => buildDepVendor,
32885
+ collectTransitiveImports: () => collectTransitiveImports,
32879
32886
  computeDepVendorPaths: () => computeDepVendorPaths
32880
32887
  });
32881
32888
  import { mkdirSync as mkdirSync14 } from "fs";
@@ -32986,20 +32993,29 @@ var toSafeFileName6 = (specifier) => {
32986
32993
  }
32987
32994
  }
32988
32995
  return Array.from(bareOut);
32989
- }, collectTransitiveImports = async (specs, alreadyVendored, alreadyScanned) => {
32996
+ }, MAX_DISCOVERY_FILES = 2000, collectTransitiveImports = async (specs, alreadyVendored, alreadyScanned) => {
32997
+ const { dirname: dirname35 } = await import("path");
32990
32998
  const transpiler7 = new Bun.Transpiler({ loader: "js" });
32991
32999
  const newSpecs = new Set;
32992
- for (const spec of specs) {
32993
- if (alreadyScanned.has(spec))
33000
+ const queue = [...specs].map((spec) => ({ from: process.cwd(), spec }));
33001
+ let visited = 0;
33002
+ while (queue.length > 0 && visited < MAX_DISCOVERY_FILES) {
33003
+ const next = queue.shift();
33004
+ if (!next)
33005
+ break;
33006
+ const key = `${next.from}\x00${next.spec}`;
33007
+ if (alreadyScanned.has(key))
32994
33008
  continue;
32995
- alreadyScanned.add(spec);
33009
+ alreadyScanned.add(key);
32996
33010
  let resolved;
32997
33011
  try {
32998
- resolved = Bun.resolveSync(spec, process.cwd());
33012
+ resolved = Bun.resolveSync(next.spec, next.from);
32999
33013
  } catch {
33000
33014
  continue;
33001
33015
  }
33016
+ visited += 1;
33002
33017
  const bareImports = await collectBareImportsFromFile(resolved, transpiler7);
33018
+ const importerDirectory = dirname35(resolved);
33003
33019
  for (const child of bareImports) {
33004
33020
  if (!isBareSpecifier3(child))
33005
33021
  continue;
@@ -33009,11 +33025,9 @@ var toSafeFileName6 = (specifier) => {
33009
33025
  continue;
33010
33026
  if (isAbsolutePackageSpecifier(child))
33011
33027
  continue;
33012
- if (alreadyVendored.has(child))
33013
- continue;
33014
- if (!isResolvable3(child))
33015
- continue;
33016
- newSpecs.add(child);
33028
+ if (!alreadyVendored.has(child) && isResolvable3(child))
33029
+ newSpecs.add(child);
33030
+ queue.push({ from: importerDirectory, spec: child });
33017
33031
  }
33018
33032
  }
33019
33033
  return newSpecs;
@@ -43595,5 +43609,5 @@ export {
43595
43609
  wrapPageHandlerWithStreamingSlots
43596
43610
  };
43597
43611
 
43598
- //# debugId=6F1D3AD5600A3EC864756E2164756E21
43612
+ //# debugId=E624779573FE1A6E64756E2164756E21
43599
43613
  //# sourceMappingURL=index.js.map