@absolutejs/absolute 0.19.0-beta.134 → 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/index.js CHANGED
@@ -171258,7 +171258,7 @@ import {
171258
171258
  statSync,
171259
171259
  writeFileSync as writeFileSync3
171260
171260
  } from "fs";
171261
- import { basename as basename5, dirname as dirname6, join as join13, relative as relative7, resolve as resolve11 } from "path";
171261
+ import { basename as basename5, join as join13, relative as relative7, resolve as resolve11 } from "path";
171262
171262
  import { cwd, env as env2, exit } from "process";
171263
171263
  var {build: bunBuild6, Glob: Glob5 } = globalThis.Bun;
171264
171264
  var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental, throwOnError) => {
@@ -171538,13 +171538,23 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171538
171538
  ...angularServerPaths
171539
171539
  ];
171540
171540
  const reactClientEntryPoints = [...reactEntries];
171541
+ const allFrameworkDirs = [
171542
+ reactDir,
171543
+ svelteDir,
171544
+ vueDir,
171545
+ angularDir,
171546
+ htmlDir,
171547
+ htmxDir
171548
+ ].filter((d) => Boolean(d));
171549
+ const urlReferencedFiles = await scanWorkerReferences(allFrameworkDirs);
171541
171550
  const nonReactClientEntryPoints = [
171542
171551
  ...svelteIndexPaths,
171543
171552
  ...svelteClientPaths,
171544
171553
  ...htmlEntries,
171545
171554
  ...vueIndexPaths,
171546
171555
  ...vueClientPaths,
171547
- ...angularClientPaths
171556
+ ...angularClientPaths,
171557
+ ...urlReferencedFiles
171548
171558
  ];
171549
171559
  if (serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
171550
171560
  logWarn("No entry points found, manifest will be empty");
@@ -171719,15 +171729,6 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171719
171729
  if (hmr && reactClientOutputPaths.length > 0) {
171720
171730
  await patchRefreshGlobals(reactClientOutputPaths);
171721
171731
  }
171722
- const frameworkDirs = [
171723
- reactDir,
171724
- svelteDir,
171725
- vueDir,
171726
- angularDir,
171727
- htmlDir,
171728
- htmxDir
171729
- ].filter((d) => Boolean(d));
171730
- const workerEntryPoints = await scanWorkerReferences(frameworkDirs);
171731
171732
  const nonReactClientLogs = nonReactClientResult?.logs ?? [];
171732
171733
  const nonReactClientOutputs = nonReactClientResult?.outputs ?? [];
171733
171734
  if (nonReactClientResult && !nonReactClientResult.success && nonReactClientLogs.length > 0) {
@@ -171758,32 +171759,36 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171758
171759
  if (vueCssResult && !vueCssResult.success && vueCssResult.logs.length > 0) {
171759
171760
  extractBuildError(vueCssResult.logs, "vue-css", "Vue CSS", frameworkNames, isIncremental, throwOnError);
171760
171761
  }
171761
- if (hmr && workerEntryPoints.length > 0) {
171762
+ if (urlReferencedFiles.length > 0) {
171762
171763
  const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
171763
171764
  const allClientOutputPaths = [
171764
171765
  ...reactClientOutputPaths,
171765
171766
  ...nonReactClientOutputs.map((a) => a.path)
171766
171767
  ];
171767
- const detectFramework = (outputPath) => {
171768
- const relOut = relative7(buildPath, outputPath).replace(/\\/g, "/");
171769
- for (const dir of frameworkDirs) {
171770
- const dirName = basename5(dir);
171771
- if (relOut.startsWith(dirName + "/"))
171772
- return dir;
171773
- }
171774
- return frameworkDirs[0];
171775
- };
171768
+ const urlFileMap = new Map;
171769
+ if (hmr) {
171770
+ for (const srcPath of urlReferencedFiles) {
171771
+ const rel = relative7(projectRoot, srcPath).replace(/\\/g, "/");
171772
+ urlFileMap.set(basename5(srcPath), `/@src/${rel}`);
171773
+ }
171774
+ } else {
171775
+ for (const srcPath of urlReferencedFiles) {
171776
+ const srcBase = basename5(srcPath).replace(/\.[^.]+$/, "");
171777
+ const output = nonReactClientOutputs.find((a) => basename5(a.path).startsWith(srcBase + "."));
171778
+ if (output) {
171779
+ urlFileMap.set(basename5(srcPath), "/" + relative7(buildPath, output.path).replace(/\\/g, "/"));
171780
+ }
171781
+ }
171782
+ }
171776
171783
  for (const outputPath of allClientOutputPaths) {
171777
171784
  let content = readFileSync5(outputPath, "utf-8");
171778
171785
  let changed = false;
171779
- const frameworkDir = detectFramework(outputPath);
171780
171786
  content = content.replace(urlPattern, (_match, relPath) => {
171781
171787
  const targetName = basename5(relPath);
171782
- const workerSrc = workerEntryPoints.find((wp) => basename5(wp) === targetName && frameworkDir && wp.startsWith(frameworkDir)) ?? workerEntryPoints.find((wp) => basename5(wp) === targetName);
171783
- if (workerSrc) {
171784
- const rel = relative7(projectRoot, workerSrc);
171788
+ const resolvedPath = urlFileMap.get(targetName);
171789
+ if (resolvedPath) {
171785
171790
  changed = true;
171786
- return `new URL('/@src/${rel.replace(/\\/g, "/")}', import.meta.url)`;
171791
+ return `new URL('${resolvedPath}', import.meta.url)`;
171787
171792
  }
171788
171793
  return _match;
171789
171794
  });
@@ -171791,59 +171796,6 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171791
171796
  writeFileSync3(outputPath, content);
171792
171797
  }
171793
171798
  }
171794
- let workerOutputs = [];
171795
- if (workerEntryPoints.length > 0) {
171796
- const workerResult = await bunBuild6({
171797
- entrypoints: workerEntryPoints,
171798
- format: "esm",
171799
- minify: !isDev,
171800
- naming: "[dir]/[name].[hash].[ext]",
171801
- outdir: buildPath,
171802
- root: commonAncestor(workerEntryPoints.map((p) => dirname6(p))),
171803
- target: "browser",
171804
- throw: false
171805
- });
171806
- if (workerResult.success) {
171807
- workerOutputs = workerResult.outputs;
171808
- const workerUrlMap = new Map;
171809
- for (const artifact of workerOutputs) {
171810
- for (const ep of workerEntryPoints) {
171811
- const epBase = basename5(ep).replace(/\.[^.]+$/, "");
171812
- if (basename5(artifact.path).startsWith(epBase)) {
171813
- workerUrlMap.set(ep, "/" + relative7(buildPath, artifact.path));
171814
- }
171815
- }
171816
- }
171817
- const allClientOutputPaths = [
171818
- ...reactClientOutputPaths,
171819
- ...nonReactClientOutputs.map((a) => a.path)
171820
- ];
171821
- for (const outputPath of allClientOutputPaths) {
171822
- let content = readFileSync5(outputPath, "utf-8");
171823
- let changed = false;
171824
- for (const [srcPath, hashedPath] of workerUrlMap) {
171825
- const srcRelPatterns = [
171826
- "./" + relative7(buildPath, srcPath),
171827
- "../" + relative7(buildPath, srcPath),
171828
- relative7(buildPath, srcPath)
171829
- ];
171830
- for (const pattern of srcRelPatterns) {
171831
- if (content.includes(pattern)) {
171832
- content = content.replaceAll(pattern, hashedPath);
171833
- changed = true;
171834
- }
171835
- }
171836
- }
171837
- if (changed)
171838
- writeFileSync3(outputPath, content);
171839
- }
171840
- } else {
171841
- const workerLogs = workerResult.logs;
171842
- if (workerLogs.length > 0) {
171843
- extractBuildError(workerLogs, "worker", "Worker", frameworkNames, isIncremental, throwOnError);
171844
- }
171845
- }
171846
- }
171847
171799
  const allLogs = [
171848
171800
  ...serverLogs,
171849
171801
  ...reactClientLogs,
@@ -171857,8 +171809,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171857
171809
  ...serverOutputs,
171858
171810
  ...reactClientOutputs,
171859
171811
  ...nonReactClientOutputs,
171860
- ...cssOutputs,
171861
- ...workerOutputs
171812
+ ...cssOutputs
171862
171813
  ], buildPath)
171863
171814
  };
171864
171815
  for (const artifact of serverOutputs) {
@@ -205745,5 +205696,5 @@ export {
205745
205696
  ANGULAR_INIT_TIMEOUT_MS
205746
205697
  };
205747
205698
 
205748
- //# debugId=0752DF2B88DFF98D64756E2164756E21
205699
+ //# debugId=74CA01BF01A9C39364756E2164756E21
205749
205700
  //# sourceMappingURL=index.js.map