@absolutejs/absolute 0.19.0-beta.133 → 0.19.0-beta.135

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
@@ -171179,7 +171179,7 @@ import {
171179
171179
  statSync,
171180
171180
  writeFileSync as writeFileSync3
171181
171181
  } from "fs";
171182
- import { basename as basename5, dirname as dirname6, join as join13, relative as relative7, resolve as resolve10 } from "path";
171182
+ import { basename as basename5, join as join13, relative as relative7, resolve as resolve10 } from "path";
171183
171183
  import { cwd, env as env2, exit } from "process";
171184
171184
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171185
171185
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171459,13 +171459,23 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171459
171459
  ...angularServerPaths
171460
171460
  ];
171461
171461
  const reactClientEntryPoints = [...reactEntries];
171462
+ const allFrameworkDirs = [
171463
+ reactDir,
171464
+ svelteDir,
171465
+ vueDir,
171466
+ angularDir,
171467
+ htmlDir,
171468
+ htmxDir
171469
+ ].filter((d) => Boolean(d));
171470
+ const urlReferencedFiles = await scanWorkerReferences(allFrameworkDirs);
171462
171471
  const nonReactClientEntryPoints = [
171463
171472
  ...svelteIndexPaths,
171464
171473
  ...svelteClientPaths,
171465
171474
  ...htmlEntries,
171466
171475
  ...vueIndexPaths,
171467
171476
  ...vueClientPaths,
171468
- ...angularClientPaths
171477
+ ...angularClientPaths,
171478
+ ...urlReferencedFiles
171469
171479
  ];
171470
171480
  if (serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
171471
171481
  logWarn("No entry points found, manifest will be empty");
@@ -171640,15 +171650,6 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171640
171650
  if (hmr && reactClientOutputPaths.length > 0) {
171641
171651
  await patchRefreshGlobals(reactClientOutputPaths);
171642
171652
  }
171643
- const frameworkDirs = [
171644
- reactDir,
171645
- svelteDir,
171646
- vueDir,
171647
- angularDir,
171648
- htmlDir,
171649
- htmxDir
171650
- ].filter((d) => Boolean(d));
171651
- const workerEntryPoints = await scanWorkerReferences(frameworkDirs);
171652
171653
  const nonReactClientLogs = nonReactClientResult?.logs ?? [];
171653
171654
  const nonReactClientOutputs = nonReactClientResult?.outputs ?? [];
171654
171655
  if (nonReactClientResult && !nonReactClientResult.success && nonReactClientLogs.length > 0) {
@@ -171679,22 +171680,36 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171679
171680
  if (vueCssResult && !vueCssResult.success && vueCssResult.logs.length > 0) {
171680
171681
  extractBuildError(vueCssResult.logs, "vue-css", "Vue CSS", frameworkNames, isIncremental, throwOnError);
171681
171682
  }
171682
- if (hmr && workerEntryPoints.length > 0) {
171683
+ if (urlReferencedFiles.length > 0) {
171683
171684
  const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
171684
171685
  const allClientOutputPaths = [
171685
171686
  ...reactClientOutputPaths,
171686
171687
  ...nonReactClientOutputs.map((a) => a.path)
171687
171688
  ];
171689
+ const urlFileMap = new Map;
171690
+ if (hmr) {
171691
+ for (const srcPath of urlReferencedFiles) {
171692
+ const rel = relative7(projectRoot, srcPath).replace(/\\/g, "/");
171693
+ urlFileMap.set(basename5(srcPath), `/@src/${rel}`);
171694
+ }
171695
+ } else {
171696
+ for (const srcPath of urlReferencedFiles) {
171697
+ const srcBase = basename5(srcPath).replace(/\.[^.]+$/, "");
171698
+ const output = nonReactClientOutputs.find((a) => basename5(a.path).startsWith(srcBase + "."));
171699
+ if (output) {
171700
+ urlFileMap.set(basename5(srcPath), "/" + relative7(buildPath, output.path).replace(/\\/g, "/"));
171701
+ }
171702
+ }
171703
+ }
171688
171704
  for (const outputPath of allClientOutputPaths) {
171689
171705
  let content = readFileSync5(outputPath, "utf-8");
171690
171706
  let changed = false;
171691
171707
  content = content.replace(urlPattern, (_match, relPath) => {
171692
171708
  const targetName = basename5(relPath);
171693
- const workerSrc = workerEntryPoints.find((wp) => basename5(wp) === targetName);
171694
- if (workerSrc) {
171695
- const rel = relative7(projectRoot, workerSrc);
171709
+ const resolvedPath = urlFileMap.get(targetName);
171710
+ if (resolvedPath) {
171696
171711
  changed = true;
171697
- return `new URL('/@src/${rel.replace(/\\/g, "/")}', import.meta.url)`;
171712
+ return `new URL('${resolvedPath}', import.meta.url)`;
171698
171713
  }
171699
171714
  return _match;
171700
171715
  });
@@ -171702,59 +171717,6 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171702
171717
  writeFileSync3(outputPath, content);
171703
171718
  }
171704
171719
  }
171705
- let workerOutputs = [];
171706
- if (workerEntryPoints.length > 0) {
171707
- const workerResult = await bunBuild6({
171708
- entrypoints: workerEntryPoints,
171709
- format: "esm",
171710
- minify: !isDev,
171711
- naming: "[dir]/[name].[hash].[ext]",
171712
- outdir: buildPath,
171713
- root: commonAncestor(workerEntryPoints.map((p) => dirname6(p))),
171714
- target: "browser",
171715
- throw: false
171716
- });
171717
- if (workerResult.success) {
171718
- workerOutputs = workerResult.outputs;
171719
- const workerUrlMap = new Map;
171720
- for (const artifact of workerOutputs) {
171721
- for (const ep of workerEntryPoints) {
171722
- const epBase = basename5(ep).replace(/\.[^.]+$/, "");
171723
- if (basename5(artifact.path).startsWith(epBase)) {
171724
- workerUrlMap.set(ep, "/" + relative7(buildPath, artifact.path));
171725
- }
171726
- }
171727
- }
171728
- const allClientOutputPaths = [
171729
- ...reactClientOutputPaths,
171730
- ...nonReactClientOutputs.map((a) => a.path)
171731
- ];
171732
- for (const outputPath of allClientOutputPaths) {
171733
- let content = readFileSync5(outputPath, "utf-8");
171734
- let changed = false;
171735
- for (const [srcPath, hashedPath] of workerUrlMap) {
171736
- const srcRelPatterns = [
171737
- "./" + relative7(buildPath, srcPath),
171738
- "../" + relative7(buildPath, srcPath),
171739
- relative7(buildPath, srcPath)
171740
- ];
171741
- for (const pattern of srcRelPatterns) {
171742
- if (content.includes(pattern)) {
171743
- content = content.replaceAll(pattern, hashedPath);
171744
- changed = true;
171745
- }
171746
- }
171747
- }
171748
- if (changed)
171749
- writeFileSync3(outputPath, content);
171750
- }
171751
- } else {
171752
- const workerLogs = workerResult.logs;
171753
- if (workerLogs.length > 0) {
171754
- extractBuildError(workerLogs, "worker", "Worker", frameworkNames, isIncremental, throwOnError);
171755
- }
171756
- }
171757
- }
171758
171720
  const allLogs = [
171759
171721
  ...serverLogs,
171760
171722
  ...reactClientLogs,
@@ -171768,8 +171730,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171768
171730
  ...serverOutputs,
171769
171731
  ...reactClientOutputs,
171770
171732
  ...nonReactClientOutputs,
171771
- ...cssOutputs,
171772
- ...workerOutputs
171733
+ ...cssOutputs
171773
171734
  ], buildPath)
171774
171735
  };
171775
171736
  for (const artifact of serverOutputs) {
@@ -205073,5 +205034,5 @@ export {
205073
205034
  build
205074
205035
  };
205075
205036
 
205076
- //# debugId=21A4AC39964F0D2D64756E2164756E21
205037
+ //# debugId=6DD1FD295802A4FC64756E2164756E21
205077
205038
  //# sourceMappingURL=build.js.map