@absolutejs/absolute 0.18.3-beta.9 → 0.18.4

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
@@ -173552,18 +173552,21 @@ __export(exports_devBuild, {
173552
173552
  import { readdir as readdir2 } from "fs/promises";
173553
173553
  import { statSync } from "fs";
173554
173554
  import { resolve as resolve19 } from "path";
173555
- var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173555
+ var FRAMEWORK_DIR_KEYS, parseDirectoryConfig = (source) => {
173556
+ const config = {};
173557
+ const dirPattern = /(\w+Directory)\s*:\s*['"]([^'"]+)['"]/g;
173558
+ let match;
173559
+ while ((match = dirPattern.exec(source)) !== null) {
173560
+ const [, key, value] = match;
173561
+ if (key && value)
173562
+ Object.assign(config, { [key]: value });
173563
+ }
173564
+ return Object.keys(config).length > 0 ? config : null;
173565
+ }, reloadConfig = async () => {
173556
173566
  try {
173557
173567
  const configPath2 = resolve19(process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts");
173558
173568
  const source = await Bun.file(configPath2).text();
173559
- const config = {};
173560
- const dirPattern = /(\w+Directory)\s*:\s*['"]([^'"]+)['"]/g;
173561
- let match;
173562
- while ((match = dirPattern.exec(source)) !== null) {
173563
- const [, key, value] = match;
173564
- config[key] = value;
173565
- }
173566
- return Object.keys(config).length > 0 ? config : null;
173569
+ return parseDirectoryConfig(source);
173567
173570
  } catch {
173568
173571
  return null;
173569
173572
  }
@@ -173573,13 +173576,7 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173573
173576
  return;
173574
173577
  const state = cached.hmrState;
173575
173578
  const oldConfig = state.config;
173576
- let hasChanges = false;
173577
- for (const key of FRAMEWORK_DIR_KEYS) {
173578
- if (newConfig[key] !== oldConfig[key]) {
173579
- hasChanges = true;
173580
- break;
173581
- }
173582
- }
173579
+ const hasChanges = FRAMEWORK_DIR_KEYS.some((key) => newConfig[key] !== oldConfig[key]);
173583
173580
  if (!hasChanges)
173584
173581
  return;
173585
173582
  const oldWatchPaths = new Set(getWatchPaths(oldConfig, state.resolvedPaths));
@@ -173594,7 +173591,7 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173594
173591
  setAngularVendorPaths(computeAngularVendorPaths());
173595
173592
  }
173596
173593
  const newWatchPaths = getWatchPaths(state.config, state.resolvedPaths);
173597
- const addedPaths = newWatchPaths.filter((p) => !oldWatchPaths.has(p));
173594
+ const addedPaths = newWatchPaths.filter((path) => !oldWatchPaths.has(path));
173598
173595
  if (addedPaths.length > 0) {
173599
173596
  buildInitialDependencyGraph(state.dependencyGraph, addedPaths);
173600
173597
  addFileWatchers(state, addedPaths, (filePath) => {
@@ -173604,11 +173601,18 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173604
173601
  });
173605
173602
  });
173606
173603
  }
173607
- }, rebuildManifest = async (cached) => {
173608
- const state = cached.hmrState;
173604
+ }, removeStaleKeys = (target, source) => {
173605
+ for (const key of Object.keys(target)) {
173606
+ if (!(key in source))
173607
+ delete target[key];
173608
+ }
173609
+ }, REBUILD_POLL_MS = 10, waitForRebuild = async (state) => {
173609
173610
  while (state.isRebuilding) {
173610
- await Bun.sleep(10);
173611
+ await Bun.sleep(REBUILD_POLL_MS);
173611
173612
  }
173613
+ }, rebuildManifest = async (cached) => {
173614
+ const state = cached.hmrState;
173615
+ await waitForRebuild(state);
173612
173616
  state.isRebuilding = true;
173613
173617
  try {
173614
173618
  const newManifest = await build({
@@ -173620,19 +173624,15 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173620
173624
  throwOnError: true
173621
173625
  }
173622
173626
  });
173623
- if (newManifest) {
173624
- for (const key of Object.keys(cached.manifest)) {
173625
- if (!(key in newManifest)) {
173626
- delete cached.manifest[key];
173627
- }
173628
- }
173629
- Object.assign(cached.manifest, newManifest);
173630
- state.manifest = cached.manifest;
173631
- await populateAssetStore(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
173632
- await cleanStaleAssets(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
173633
- }
173634
- state.rebuildCount++;
173627
+ if (!newManifest)
173628
+ return;
173629
+ removeStaleKeys(cached.manifest, newManifest);
173630
+ Object.assign(cached.manifest, newManifest);
173631
+ state.manifest = cached.manifest;
173632
+ await populateAssetStore(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
173633
+ await cleanStaleAssets(state.assetStore, cached.manifest, state.resolvedPaths.buildDir);
173635
173634
  } catch {} finally {
173635
+ state.rebuildCount++;
173636
173636
  state.isRebuilding = false;
173637
173637
  state.fileChangeQueue.clear();
173638
173638
  }
@@ -173647,15 +173647,15 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173647
173647
  if (cached?.hmrState.config.angularDirectory) {
173648
173648
  setAngularVendorPaths(computeAngularVendorPaths());
173649
173649
  }
173650
- if (serverMtime !== lastMtime) {
173651
- logServerReload();
173652
- if (cached) {
173653
- await detectConfigChanges(cached);
173654
- await rebuildManifest(cached);
173655
- }
173656
- } else {
173650
+ if (serverMtime === lastMtime) {
173657
173651
  globalThis.__hmrSkipServerRestart = true;
173652
+ return;
173658
173653
  }
173654
+ logServerReload();
173655
+ if (!cached)
173656
+ return;
173657
+ await detectConfigChanges(cached);
173658
+ await rebuildManifest(cached);
173659
173659
  }, tryReadPackageVersion = async (path) => {
173660
173660
  const pkg = await Bun.file(path).json().catch(() => null);
173661
173661
  if (!pkg || pkg.name !== "@absolutejs/absolute") {
@@ -173716,9 +173716,9 @@ var FRAMEWORK_DIR_KEYS, reloadConfig = async () => {
173716
173716
  await buildReactVendor(state.resolvedPaths.buildDir);
173717
173717
  const vendorDir = resolve19(state.resolvedPaths.buildDir, "react", "vendor");
173718
173718
  await loadVendorFiles(state.assetStore, vendorDir, "react");
173719
- if (!globalThis.__reactModuleRef) {
173720
- globalThis.__reactModuleRef = await import("react");
173721
- }
173719
+ }
173720
+ if (config.reactDirectory && !globalThis.__reactModuleRef) {
173721
+ globalThis.__reactModuleRef = await import("react");
173722
173722
  }
173723
173723
  if (config.angularDirectory) {
173724
173724
  await buildAngularVendor(state.resolvedPaths.buildDir);
@@ -173771,5 +173771,5 @@ export {
173771
173771
  build
173772
173772
  };
173773
173773
 
173774
- //# debugId=1F269857F58E64E164756E2164756E21
173774
+ //# debugId=788DB8B99A279E0164756E2164756E21
173775
173775
  //# sourceMappingURL=build.js.map