@absolutejs/absolute 0.19.0-beta.124 → 0.19.0-beta.125

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
@@ -171299,6 +171299,28 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171299
171299
  globalThis.__absoluteVersion = pkg.version;
171300
171300
  return;
171301
171301
  }
171302
+ }, scanWorkerReferences = async (dirs) => {
171303
+ const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
171304
+ const resolvePattern = /import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g;
171305
+ const workerPaths = new Set;
171306
+ for (const dir of dirs) {
171307
+ const glob = new Glob5("**/*.{ts,tsx,js,jsx}");
171308
+ for await (const file4 of glob.scan({ absolute: true, cwd: dir })) {
171309
+ const content = readFileSync5(file4, "utf-8");
171310
+ for (const pattern of [urlPattern, resolvePattern]) {
171311
+ pattern.lastIndex = 0;
171312
+ let match;
171313
+ while ((match = pattern.exec(content)) !== null) {
171314
+ const relPath = match[1];
171315
+ if (!relPath)
171316
+ continue;
171317
+ const absPath = resolve11(file4, "..", relPath);
171318
+ workerPaths.add(absPath);
171319
+ }
171320
+ }
171321
+ }
171322
+ }
171323
+ return [...workerPaths];
171302
171324
  }, vueFeatureFlags, build2 = async ({
171303
171325
  buildDirectory = "build",
171304
171326
  assetsDirectory,
@@ -171711,6 +171733,68 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171711
171733
  if (vueCssResult && !vueCssResult.success && vueCssResult.logs.length > 0) {
171712
171734
  extractBuildError(vueCssResult.logs, "vue-css", "Vue CSS", frameworkNames, isIncremental, throwOnError);
171713
171735
  }
171736
+ const frameworkDirs = [
171737
+ reactDir,
171738
+ svelteDir,
171739
+ vueDir,
171740
+ angularDir,
171741
+ htmlDir,
171742
+ htmxDir
171743
+ ].filter((d) => Boolean(d));
171744
+ const workerEntryPoints = await scanWorkerReferences(frameworkDirs);
171745
+ let workerOutputs = [];
171746
+ if (workerEntryPoints.length > 0) {
171747
+ const workerResult = await bunBuild6({
171748
+ entrypoints: workerEntryPoints,
171749
+ format: "esm",
171750
+ minify: !isDev,
171751
+ naming: "[dir]/[name].[hash].[ext]",
171752
+ outdir: buildPath,
171753
+ root: commonAncestor(workerEntryPoints),
171754
+ target: "browser",
171755
+ throw: false
171756
+ });
171757
+ if (workerResult.success) {
171758
+ workerOutputs = workerResult.outputs;
171759
+ const workerUrlMap = new Map;
171760
+ for (const artifact of workerOutputs) {
171761
+ for (const ep of workerEntryPoints) {
171762
+ const epBase = basename5(ep).replace(/\.[^.]+$/, "");
171763
+ if (basename5(artifact.path).startsWith(epBase)) {
171764
+ workerUrlMap.set(ep, "/" + relative7(buildPath, artifact.path));
171765
+ }
171766
+ }
171767
+ }
171768
+ const allClientOutputPaths = [
171769
+ ...reactClientOutputPaths,
171770
+ ...nonReactClientOutputs.map((a) => a.path)
171771
+ ];
171772
+ for (const outputPath of allClientOutputPaths) {
171773
+ let content = readFileSync5(outputPath, "utf-8");
171774
+ let changed = false;
171775
+ for (const [srcPath, hashedPath] of workerUrlMap) {
171776
+ const srcRelPatterns = [
171777
+ "./" + relative7(buildPath, srcPath),
171778
+ "../" + relative7(buildPath, srcPath),
171779
+ relative7(buildPath, srcPath)
171780
+ ];
171781
+ for (const pattern of srcRelPatterns) {
171782
+ if (content.includes(pattern)) {
171783
+ content = content.replaceAll(pattern, hashedPath);
171784
+ changed = true;
171785
+ }
171786
+ }
171787
+ }
171788
+ if (changed)
171789
+ writeFileSync3(outputPath, content);
171790
+ }
171791
+ } else {
171792
+ const workerLogs = workerResult.logs;
171793
+ if (workerLogs.length > 0) {
171794
+ extractBuildError(workerLogs, "worker", "Worker", frameworkNames, isIncremental, throwOnError);
171795
+ }
171796
+ }
171797
+ }
171714
171798
  const allLogs = [
171715
171799
  ...serverLogs,
171716
171800
  ...reactClientLogs,
@@ -171724,7 +171808,8 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171724
171808
  ...serverOutputs,
171725
171809
  ...reactClientOutputs,
171726
171810
  ...nonReactClientOutputs,
171727
- ...cssOutputs
171811
+ ...cssOutputs,
171812
+ ...workerOutputs
171728
171813
  ], buildPath)
171729
171814
  };
171730
171815
  for (const artifact of serverOutputs) {
@@ -202553,6 +202638,16 @@ ${stubs}
202553
202638
  }
202554
202639
  return _match;
202555
202640
  });
202641
+ result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
202642
+ const absPath = resolve18(fileDir, relPath);
202643
+ const rel = relative8(projectRoot, absPath);
202644
+ return `new URL('/${srcUrl(rel, projectRoot)}', import.meta.url)`;
202645
+ });
202646
+ result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
202647
+ const absPath = resolve18(fileDir, relPath);
202648
+ const rel = relative8(projectRoot, absPath);
202649
+ return `'${srcUrl(rel, projectRoot)}'`;
202650
+ });
202556
202651
  return result;
202557
202652
  }, HOOK_NAMES, REFRESH_PREAMBLE, JSX_AUTO_RE, JSXS_AUTO_RE, JSX_PROD_RE, FRAGMENT_RE, addJsxImport = (code) => {
202558
202653
  const imports = [];
@@ -205600,5 +205695,5 @@ export {
205600
205695
  ANGULAR_INIT_TIMEOUT_MS
205601
205696
  };
205602
205697
 
205603
- //# debugId=E99B445C59288BB764756E2164756E21
205698
+ //# debugId=FAEDECCCFD8E76FD64756E2164756E21
205604
205699
  //# sourceMappingURL=index.js.map