@absolutejs/absolute 0.18.9-beta.1 → 0.18.9-beta.3

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
@@ -782,6 +782,16 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), applyAllR
782
782
  result = result.replace(dynamicRegex, `$1${webPath}$2`);
783
783
  }
784
784
  return result;
785
+ }, REFRESH_STUBS, patchRefreshGlobals = async (outputPaths) => {
786
+ const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
787
+ await Promise.all(jsFiles.map(async (filePath) => {
788
+ const content = await Bun.file(filePath).text();
789
+ if (!content.includes("$RefreshReg$(") && !content.includes("$RefreshSig$("))
790
+ return;
791
+ if (content.startsWith("window.$RefreshReg$"))
792
+ return;
793
+ await Bun.write(filePath, REFRESH_STUBS + content);
794
+ }));
785
795
  }, rewriteReactImports = async (outputPaths, vendorPaths) => {
786
796
  const jsFiles = outputPaths.filter((path) => path.endsWith(".js"));
787
797
  if (jsFiles.length === 0)
@@ -795,6 +805,10 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), applyAllR
795
805
  }
796
806
  }));
797
807
  };
808
+ var init_rewriteReactImports = __esm(() => {
809
+ REFRESH_STUBS = "window.$RefreshReg$||(window.$RefreshReg$=function(){});" + `window.$RefreshSig$||(window.$RefreshSig$=function(){return function(t){return t}});
810
+ `;
811
+ });
798
812
 
799
813
  // src/core/devVendorPaths.ts
800
814
  var exports_devVendorPaths = {};
@@ -171334,8 +171348,12 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171334
171348
  if (reactClientResult && !reactClientResult.success && reactClientLogs.length > 0) {
171335
171349
  extractBuildError(reactClientLogs, "react-client", "React client", frameworkNames, isIncremental, throwOnError);
171336
171350
  }
171337
- if (vendorPaths && reactClientOutputs.length > 0) {
171338
- await rewriteReactImports(reactClientOutputs.map((artifact) => artifact.path), vendorPaths);
171351
+ const reactClientOutputPaths = reactClientOutputs.map((artifact) => artifact.path);
171352
+ if (vendorPaths && reactClientOutputPaths.length > 0) {
171353
+ await rewriteReactImports(reactClientOutputPaths, vendorPaths);
171354
+ }
171355
+ if (hmr && reactClientOutputPaths.length > 0) {
171356
+ await patchRefreshGlobals(reactClientOutputPaths);
171339
171357
  }
171340
171358
  const nonReactClientLogs = nonReactClientResult?.logs ?? [];
171341
171359
  const nonReactClientOutputs = nonReactClientResult?.outputs ?? [];
@@ -171487,6 +171505,7 @@ var init_build = __esm(() => {
171487
171505
  init_scanCssEntryPoints();
171488
171506
  init_updateAssetPaths();
171489
171507
  init_buildHMRClient();
171508
+ init_rewriteReactImports();
171490
171509
  init_telemetryEvent();
171491
171510
  init_angularLinkerPlugin();
171492
171511
  init_cleanStaleOutputs();
@@ -202478,9 +202497,11 @@ var parseErrorLocationFromMessage = (msg) => {
202478
202497
  if (!clientResult.success) {
202479
202498
  return;
202480
202499
  }
202500
+ const clientOutputPaths = clientResult.outputs.map((art) => art.path);
202481
202501
  if (vendorPaths) {
202482
- await rewriteReactImports(clientResult.outputs.map((art) => art.path), vendorPaths);
202502
+ await rewriteReactImports(clientOutputPaths, vendorPaths);
202483
202503
  }
202504
+ await patchRefreshGlobals(clientOutputPaths);
202484
202505
  const clientManifest = generateManifest(clientResult.outputs, buildDir);
202485
202506
  Object.assign(state.manifest, clientManifest);
202486
202507
  populateAssetStore(state.assetStore, clientManifest, buildDir);
@@ -202509,9 +202530,11 @@ var parseErrorLocationFromMessage = (msg) => {
202509
202530
  if (!result.success) {
202510
202531
  return;
202511
202532
  }
202533
+ const pageOutputPaths = result.outputs.map((artifact) => artifact.path);
202512
202534
  if (vendorPaths) {
202513
- await rewriteReactImports(result.outputs.map((artifact) => artifact.path), vendorPaths);
202535
+ await rewriteReactImports(pageOutputPaths, vendorPaths);
202514
202536
  }
202537
+ await patchRefreshGlobals(pageOutputPaths);
202515
202538
  const pageManifest = generateManifest(result.outputs, buildDir);
202516
202539
  Object.assign(state.manifest, pageManifest);
202517
202540
  populateAssetStore(state.assetStore, pageManifest, buildDir);
@@ -203424,6 +203447,7 @@ var init_rebuildTrigger = __esm(() => {
203424
203447
  init_compileVue();
203425
203448
  init_compileAngular();
203426
203449
  init_commonAncestor();
203450
+ init_rewriteReactImports();
203427
203451
  });
203428
203452
 
203429
203453
  // src/core/devBuild.ts
@@ -203770,11 +203794,10 @@ var handleReactPageRequest = async (PageComponent, index, ...props) => {
203770
203794
  const { createElement } = await import("react");
203771
203795
  const { renderToReadableStream } = await import("react-dom/server");
203772
203796
  const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
203773
- const refreshPreamble = "window.$RefreshReg$||(window.$RefreshReg$=function(){});window.$RefreshSig$||(window.$RefreshSig$=function(){return function(t){return t}});";
203774
- const propsScript = maybeProps ? `${refreshPreamble}window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : refreshPreamble;
203797
+ const propsScript = maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : "";
203775
203798
  const stream = await renderToReadableStream(element, {
203776
203799
  bootstrapModules: [index],
203777
- bootstrapScriptContent: propsScript,
203800
+ bootstrapScriptContent: propsScript || undefined,
203778
203801
  onError(error) {
203779
203802
  console.error("[SSR] React streaming error:", error);
203780
203803
  }
@@ -203989,5 +204012,5 @@ export {
203989
204012
  ANGULAR_INIT_TIMEOUT_MS
203990
204013
  };
203991
204014
 
203992
- //# debugId=FFE333B06D57E72364756E2164756E21
204015
+ //# debugId=10F0D535EDA432F464756E2164756E21
203993
204016
  //# sourceMappingURL=index.js.map