@absolutejs/absolute 0.19.0-beta.72 → 0.19.0-beta.74

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
@@ -133,6 +133,36 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
133
133
  </html>`;
134
134
  };
135
135
 
136
+ // src/build/freshReadPlugin.ts
137
+ var createFreshReadPlugin = (changedFiles) => {
138
+ const changed = new Set(changedFiles.map((f) => f.replace(/\\/g, "/")));
139
+ const escaped = changedFiles.map((f) => f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
140
+ const pattern = escaped.length > 0 ? new RegExp(`(${escaped.join("|")})$`) : /(?!)/;
141
+ return {
142
+ name: "fresh-read",
143
+ setup(build2) {
144
+ build2.onLoad({ filter: pattern }, async (args) => {
145
+ const normalized = args.path.replace(/\\/g, "/");
146
+ if (!changed.has(normalized))
147
+ return;
148
+ const contents = await Bun.file(args.path).text();
149
+ const ext = args.path.split(".").pop();
150
+ const loaderMap = {
151
+ ts: "ts",
152
+ tsx: "tsx",
153
+ js: "js",
154
+ jsx: "jsx",
155
+ css: "css"
156
+ };
157
+ return {
158
+ contents,
159
+ loader: loaderMap[ext ?? ""] ?? "ts"
160
+ };
161
+ });
162
+ }
163
+ };
164
+ };
165
+
136
166
  // src/utils/normalizePath.ts
137
167
  var normalizePath = (path) => path.replace(/\\/g, "/");
138
168
 
@@ -171290,6 +171320,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171290
171320
  await resolveAbsoluteVersion();
171291
171321
  const isIncremental = incrementalFiles && incrementalFiles.length > 0;
171292
171322
  const normalizedIncrementalFiles = incrementalFiles?.map(normalizePath);
171323
+ const freshReadPlugins = isIncremental ? [createFreshReadPlugin(incrementalFiles)] : [];
171293
171324
  const throwOnError = options?.throwOnError === true;
171294
171325
  const hmr = options?.injectHMR === true;
171295
171326
  const buildPath = validateSafePath(buildDirectory, projectRoot);
@@ -171547,6 +171578,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171547
171578
  naming: `[dir]/[name].[hash].[ext]`,
171548
171579
  outdir: buildPath,
171549
171580
  ...hmr ? { jsx: { development: true }, reactFastRefresh: true } : {},
171581
+ plugins: [...freshReadPlugins],
171550
171582
  root: clientRoot,
171551
171583
  splitting: true,
171552
171584
  target: "browser",
@@ -171592,6 +171624,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171592
171624
  format: "esm",
171593
171625
  naming: `[dir]/[name].[hash].[ext]`,
171594
171626
  outdir: serverOutDir,
171627
+ plugins: [...freshReadPlugins],
171595
171628
  root: serverRoot,
171596
171629
  target: "bun",
171597
171630
  throw: false
@@ -171610,6 +171643,7 @@ var isDev, extractBuildError = (logs, pass, label, frameworkNames, isIncremental
171610
171643
  naming: `[dir]/[name].[hash].[ext]`,
171611
171644
  outdir: buildPath,
171612
171645
  plugins: [
171646
+ ...freshReadPlugins,
171613
171647
  ...angularDir && !isDev ? [angularLinkerPlugin] : [],
171614
171648
  ...htmlScriptPlugin ? [htmlScriptPlugin] : []
171615
171649
  ],
@@ -202323,15 +202357,6 @@ var init_pageHandler = __esm(() => {
202323
202357
  });
202324
202358
 
202325
202359
  // 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
- });
202335
202360
  var globalStore, cache, importers, getTransformed = (filePath) => cache.get(filePath)?.content, setTransformed = (filePath, content, mtime, imports) => {
202336
202361
  const resolvedImports = imports ?? [];
202337
202362
  cache.set(filePath, { content, imports: resolvedImports, mtime });
@@ -202350,28 +202375,6 @@ var globalStore, cache, importers, getTransformed = (filePath) => cache.get(file
202350
202375
  cache.delete(parent);
202351
202376
  }
202352
202377
  }
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;
202375
202378
  };
202376
202379
  var init_transformCache = __esm(() => {
202377
202380
  globalStore = globalThis;
@@ -203497,11 +203500,12 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203497
203500
  const reactIndexesPath = resolve21(reactDir, "indexes");
203498
203501
  const { buildDir } = state.resolvedPaths;
203499
203502
  const reactFiles = filesToRebuild.filter((file4) => detectFramework(file4, state.resolvedPaths) === "react");
203500
- if (reactFiles.length > 0) {
203503
+ const componentFiles = reactFiles.filter((f) => f.endsWith(".tsx") || f.endsWith(".jsx"));
203504
+ if (componentFiles.length > 0 && componentFiles.length === reactFiles.length) {
203501
203505
  for (const file4 of reactFiles) {
203502
203506
  state.fileHashes.set(resolve21(file4), computeFileHash(file4));
203503
203507
  }
203504
- const primaryFile = reactFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? reactFiles[0];
203508
+ const primaryFile = componentFiles.find((f) => !f.replace(/\\/g, "/").includes("/pages/")) ?? componentFiles[0];
203505
203509
  if (!primaryFile) {
203506
203510
  onRebuildComplete({
203507
203511
  hmrState: state,
@@ -203513,15 +203517,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
203513
203517
  for (const file4 of reactFiles) {
203514
203518
  invalidateModule2(file4);
203515
203519
  }
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);
203520
+ const pageModuleUrl = await getReactModuleUrl(primaryFile);
203525
203521
  if (pageModuleUrl) {
203526
203522
  const serverDuration = Date.now() - startTime;
203527
203523
  state.lastHmrPath = relative9(process.cwd(), primaryFile).replace(/\\/g, "/");
@@ -205308,5 +205304,5 @@ export {
205308
205304
  ANGULAR_INIT_TIMEOUT_MS
205309
205305
  };
205310
205306
 
205311
- //# debugId=FF24C941A8BB22E364756E2164756E21
205307
+ //# debugId=425D48C1FC21F89264756E2164756E21
205312
205308
  //# sourceMappingURL=index.js.map