@absolutejs/absolute 0.19.0-beta.95 → 0.19.0-beta.96

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.
@@ -102,7 +102,6 @@ export const handleModuleUpdate = (message: {
102
102
  export const handleRebuildComplete = (message: {
103
103
  data: {
104
104
  affectedFrameworks?: string[];
105
- fullReload?: boolean;
106
105
  manifest?: Record<string, string>;
107
106
  };
108
107
  }) => {
@@ -113,15 +112,6 @@ export const handleRebuildComplete = (message: {
113
112
  window.__HMR_MANIFEST__ = message.data.manifest;
114
113
  }
115
114
 
116
- // Subprocess build: the server's manifest now points to fresh
117
- // bundles. Reload to get the new HTML (with updated script tag)
118
- // and let React hydrate with the fresh bundled JS.
119
- if (message.data.fullReload) {
120
- window.location.reload();
121
-
122
- return;
123
- }
124
-
125
115
  if (
126
116
  message.data.affectedFrameworks &&
127
117
  !message.data.affectedFrameworks.includes('angular') &&
package/dist/index.js CHANGED
@@ -202323,6 +202323,15 @@ var init_pageHandler = __esm(() => {
202323
202323
  });
202324
202324
 
202325
202325
  // src/dev/transformCache.ts
202326
+ var exports_transformCache = {};
202327
+ __export(exports_transformCache, {
202328
+ setTransformed: () => setTransformed,
202329
+ invalidateAll: () => invalidateAll,
202330
+ invalidate: () => invalidate,
202331
+ getTransformed: () => getTransformed,
202332
+ getInvalidationVersion: () => getInvalidationVersion,
202333
+ findNearestComponent: () => findNearestComponent
202334
+ });
202326
202335
  var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
202327
202336
  const resolvedImports = imports ?? [];
202328
202337
  cache.set(filePath, { content, imports: resolvedImports, mtime });
@@ -202341,6 +202350,28 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
202341
202350
  cache.delete(parent);
202342
202351
  }
202343
202352
  }
202353
+ }, invalidateAll = () => {
202354
+ cache.clear();
202355
+ importers.clear();
202356
+ }, findNearestComponent = (filePath) => {
202357
+ const visited = new Set;
202358
+ const queue = [filePath];
202359
+ while (queue.length > 0) {
202360
+ const current = queue.shift();
202361
+ if (visited.has(current))
202362
+ continue;
202363
+ visited.add(current);
202364
+ const parents = importers.get(current);
202365
+ if (!parents)
202366
+ continue;
202367
+ for (const parent of parents) {
202368
+ if (parent.endsWith(".tsx") || parent.endsWith(".jsx")) {
202369
+ return parent;
202370
+ }
202371
+ queue.push(parent);
202372
+ }
202373
+ }
202374
+ return;
202344
202375
  };
202345
202376
  var init_transformCache = __esm(() => {
202346
202377
  globalStore = globalThis;
@@ -203022,7 +203053,7 @@ var init_simpleHTMXHMR = () => {};
203022
203053
  // src/dev/rebuildTrigger.ts
203023
203054
  import { existsSync as existsSync14 } from "fs";
203024
203055
  import { rm as rm8 } from "fs/promises";
203025
- import { basename as basename8, dirname as dirname8, relative as relative9, resolve as resolve21 } from "path";
203056
+ import { basename as basename8, relative as relative9, resolve as resolve21 } from "path";
203026
203057
  var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
203027
203058
  const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
203028
203059
  if (pathLineCol) {
@@ -203466,12 +203497,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203466
203497
  const reactIndexesPath = resolve21(reactDir, "indexes");
203467
203498
  const { buildDir } = state.resolvedPaths;
203468
203499
  const reactFiles = filesToRebuild.filter((file4) => detectFramework(file4, state.resolvedPaths) === "react");
203469
- const componentFiles = reactFiles.filter((f) => f.endsWith(".tsx") || f.endsWith(".jsx"));
203470
- if (componentFiles.length > 0 && componentFiles.length === reactFiles.length) {
203500
+ if (reactFiles.length > 0) {
203471
203501
  for (const file4 of reactFiles) {
203472
203502
  state.fileHashes.set(resolve21(file4), computeFileHash(file4));
203473
203503
  }
203474
- const primaryFile = componentFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? componentFiles[0];
203504
+ const primaryFile = reactFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
203475
203505
  if (!primaryFile) {
203476
203506
  onRebuildComplete({
203477
203507
  hmrState: state,
@@ -203483,7 +203513,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203483
203513
  for (const file4 of reactFiles) {
203484
203514
  invalidateModule2(file4);
203485
203515
  }
203486
- const pageModuleUrl = await getReactModuleUrl(primaryFile);
203516
+ const isComponentFile = primaryFile.endsWith(".tsx") || primaryFile.endsWith(".jsx");
203517
+ let broadcastTarget = primaryFile;
203518
+ if (!isComponentFile) {
203519
+ const { findNearestComponent: findNearestComponent2 } = await Promise.resolve().then(() => (init_transformCache(), exports_transformCache));
203520
+ const nearest = findNearestComponent2(resolve21(primaryFile));
203521
+ if (nearest)
203522
+ broadcastTarget = nearest;
203523
+ }
203524
+ const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
203487
203525
  if (pageModuleUrl) {
203488
203526
  const serverDuration = Date.now() - startTime;
203489
203527
  state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
@@ -204212,11 +204250,8 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204212
204250
  files.filter((f) => detectFramework(f, state.resolvedPaths) === "angular").forEach((f) => handled.add(f));
204213
204251
  }
204214
204252
  if (config.reactDirectory && affectedFrameworks.includes("react")) {
204215
- const reactComponentFiles = files.filter((f) => detectFramework(f, state.resolvedPaths) === "react" && (f.endsWith(".tsx") || f.endsWith(".jsx")));
204216
- if (reactComponentFiles.length > 0) {
204217
- await handleReactFastPath(state, config, files, startTime, onRebuildComplete);
204218
- }
204219
- reactComponentFiles.forEach((f) => handled.add(f));
204253
+ await handleReactFastPath(state, config, files, startTime, onRebuildComplete);
204254
+ files.filter((f) => detectFramework(f, state.resolvedPaths) === "react").forEach((f) => handled.add(f));
204220
204255
  }
204221
204256
  if (config.svelteDirectory && affectedFrameworks.includes("svelte")) {
204222
204257
  await handleSvelteFastPath(state, config, files, startTime, onRebuildComplete);
@@ -204331,19 +204366,6 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204331
204366
  });
204332
204367
  return state.manifest;
204333
204368
  }
204334
- const hasNonComponentFiles = (filesToRebuild ?? []).some((f) => f.endsWith(".ts") && !f.endsWith(".d.ts"));
204335
- const subprocessConfig = hasNonComponentFiles ? {
204336
- buildDirectory: config.buildDirectory,
204337
- assetsDirectory: config.assetsDirectory,
204338
- reactDirectory: config.reactDirectory,
204339
- stylesConfig: config.stylesConfig,
204340
- options: {
204341
- ...config.options,
204342
- baseManifest: state.manifest,
204343
- injectHMR: true,
204344
- throwOnError: true
204345
- }
204346
- } : undefined;
204347
204369
  const buildConfig = {
204348
204370
  ...config,
204349
204371
  incrementalFiles: filesToRebuild && filesToRebuild.length > 0 ? filesToRebuild : undefined,
@@ -204354,52 +204376,11 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204354
204376
  throwOnError: true
204355
204377
  }
204356
204378
  };
204357
- let manifest;
204358
- if (hasNonComponentFiles && subprocessConfig) {
204359
- const distDir = dirname8(new URL(import.meta.url).pathname);
204360
- const workerPath = resolve21(distDir, "freshBuildWorker.js");
204361
- const configJson = JSON.stringify(subprocessConfig);
204362
- const proc = Bun.spawn(["bun", "run", workerPath, configJson], {
204363
- cwd: process.cwd(),
204364
- stderr: "pipe",
204365
- stdout: "pipe"
204366
- });
204367
- const stdout = await new Response(proc.stdout).text();
204368
- const stderr = await new Response(proc.stderr).text();
204369
- await proc.exited;
204370
- if (proc.exitCode !== 0) {
204371
- logWarn(`Fresh build failed: ${stderr.slice(0, 300)}`);
204372
- manifest = await build2(buildConfig);
204373
- } else {
204374
- const manifestLine = stdout.split(`
204375
- `).find((l) => l.startsWith("__MANIFEST__"));
204376
- if (manifestLine) {
204377
- const freshManifest = JSON.parse(manifestLine.slice("__MANIFEST__".length));
204378
- for (const [key, value] of Object.entries(freshManifest)) {
204379
- state.manifest[key] = value;
204380
- }
204381
- manifest = state.manifest;
204382
- } else {
204383
- manifest = await build2(buildConfig);
204384
- }
204385
- }
204386
- } else {
204387
- manifest = await build2(buildConfig);
204388
- }
204379
+ const manifest = await build2(buildConfig);
204389
204380
  if (!manifest) {
204390
204381
  throw new Error("Build failed - no manifest generated");
204391
204382
  }
204392
204383
  const duration = Date.now() - startTime;
204393
- const wasSubprocess = hasNonComponentFiles && subprocessConfig;
204394
- if (wasSubprocess) {
204395
- const dataFile = (filesToRebuild ?? []).find((f) => f.endsWith(".ts") && !f.endsWith(".d.ts"));
204396
- if (dataFile) {
204397
- const path = relative9(process.cwd(), dataFile).replace(/\\/g, "/");
204398
- logHmrUpdate(path, "react", duration);
204399
- }
204400
- state.lastHmrPath = undefined;
204401
- state.lastHmrFramework = undefined;
204402
- }
204403
204384
  sendTelemetryEvent("hmr:rebuild-complete", {
204404
204385
  durationMs: duration,
204405
204386
  fileCount: filesToRebuild?.length ?? 0,
@@ -204410,17 +204391,15 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
204410
204391
  broadcastToClients(state, {
204411
204392
  data: {
204412
204393
  affectedFrameworks,
204413
- fullReload: wasSubprocess,
204414
204394
  manifest
204415
204395
  },
204416
204396
  message: "Rebuild completed successfully",
204417
204397
  type: "rebuild-complete"
204418
204398
  });
204419
- if (filesToRebuild && filesToRebuild.length > 0 && !wasSubprocess) {
204399
+ if (filesToRebuild && filesToRebuild.length > 0) {
204420
204400
  await handleFullBuildHMR(state, config, affectedFrameworks, filesToRebuild, manifest, duration);
204421
204401
  }
204422
- if (!wasSubprocess)
204423
- broadcastFrameworkUpdates(state, affectedFrameworks, filesToRebuild, manifest, startTime);
204402
+ broadcastFrameworkUpdates(state, affectedFrameworks, filesToRebuild, manifest, startTime);
204424
204403
  if (affectedFrameworks.includes("angular")) {
204425
204404
  invalidateAngularSsrCache();
204426
204405
  }
@@ -205330,5 +205309,5 @@ export {
205330
205309
  ANGULAR_INIT_TIMEOUT_MS
205331
205310
  };
205332
205311
 
205333
- //# debugId=6E4CB61F15FAF56464756E2164756E21
205312
+ //# debugId=A2C8E272613C93C164756E2164756E21
205334
205313
  //# sourceMappingURL=index.js.map