@absolutejs/absolute 0.19.0-beta.831 → 0.19.0-beta.833

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
@@ -8645,10 +8645,6 @@ var init_generateManifest = __esm(() => {
8645
8645
  });
8646
8646
 
8647
8647
  // src/build/generateReactIndexes.ts
8648
- var exports_generateReactIndexes = {};
8649
- __export(exports_generateReactIndexes, {
8650
- generateReactIndexFiles: () => generateReactIndexFiles
8651
- });
8652
8648
  import { existsSync as existsSync7, mkdirSync as mkdirSync2 } from "fs";
8653
8649
  import { readdir as readdir2, rm, writeFile } from "fs/promises";
8654
8650
  import { basename as basename3, join as join8, relative as relative4, resolve as resolve10, sep } from "path";
@@ -9592,11 +9588,6 @@ var init_nativeRewrite = __esm(() => {
9592
9588
  });
9593
9589
 
9594
9590
  // src/build/rewriteReactImports.ts
9595
- var exports_rewriteReactImports = {};
9596
- __export(exports_rewriteReactImports, {
9597
- rewriteReactImports: () => rewriteReactImports,
9598
- patchRefreshGlobals: () => patchRefreshGlobals
9599
- });
9600
9591
  var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), rewriterCache, cacheKey = (vendorPaths) => {
9601
9592
  const entries = Object.entries(vendorPaths).sort(([left], [right]) => left.localeCompare(right));
9602
9593
  let key = "";
@@ -11459,21 +11450,34 @@ ${registrations}
11459
11450
  if (fileName.startsWith(outDir))
11460
11451
  return fileName.substring(outDir.length + 1);
11461
11452
  return fileName;
11462
- }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
11463
- if (specifier.endsWith(".ts"))
11464
- return specifier.replace(/\.ts$/, ".js");
11465
- if (hasJsLikeExtension(specifier))
11466
- return specifier;
11453
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), splitSpecifierAndQuery = (specifier) => {
11454
+ const separator = specifier.indexOf("?");
11455
+ if (separator === -1) {
11456
+ return {
11457
+ path: specifier,
11458
+ query: ""
11459
+ };
11460
+ }
11461
+ return {
11462
+ path: specifier.substring(0, separator),
11463
+ query: specifier.substring(separator)
11464
+ };
11465
+ }, rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
11466
+ const { path, query } = splitSpecifierAndQuery(specifier);
11467
+ if (path.endsWith(".ts"))
11468
+ return `${path.replace(/\.ts$/, ".js")}${query}`;
11469
+ if (hasJsLikeExtension(path))
11470
+ return `${path}${query}`;
11467
11471
  const importerDir = dirname13(importerOutputPath);
11468
- const fileCandidate = resolve19(importerDir, `${specifier}.js`);
11472
+ const fileCandidate = resolve19(importerDir, `${path}.js`);
11469
11473
  if (outputFiles?.has(fileCandidate) || existsSync17(fileCandidate)) {
11470
- return `${specifier}.js`;
11474
+ return `${path}.js${query}`;
11471
11475
  }
11472
- const indexCandidate = resolve19(importerDir, specifier, "index.js");
11476
+ const indexCandidate = resolve19(importerDir, path, "index.js");
11473
11477
  if (outputFiles?.has(indexCandidate) || existsSync17(indexCandidate)) {
11474
- return `${specifier}/index.js`;
11478
+ return `${path}/index.js${query}`;
11475
11479
  }
11476
- return `${specifier}.js`;
11480
+ return `${path}.js${query}`;
11477
11481
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
11478
11482
  const sourceFile = ts2.createSourceFile(fileName, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
11479
11483
  const specifiers = [];
@@ -11989,7 +11993,7 @@ ${fields}
11989
11993
  deferSlots: inlinedTemplate.deferSlots,
11990
11994
  source: result
11991
11995
  };
11992
- }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors) => {
11996
+ }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
11993
11997
  const entryPath = resolve19(inputPath);
11994
11998
  const allOutputs = [];
11995
11999
  const visited = new Set;
@@ -12043,13 +12047,18 @@ ${fields}
12043
12047
  const fileBase = basename7(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
12044
12048
  return join17(outDir, relativeDir, fileBase);
12045
12049
  };
12050
+ const withCacheBuster = (specifier) => {
12051
+ if (!cacheBuster)
12052
+ return specifier;
12053
+ return specifier.includes("?") ? `${specifier}&t=${cacheBuster}` : `${specifier}?t=${cacheBuster}`;
12054
+ };
12046
12055
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
12047
12056
  let processedContent = angularTranspiler.transformSync(sourceCode);
12048
12057
  const outputPath = toOutputPath(actualPath);
12049
12058
  const rewriteBareImport = (prefix, specifier, suffix) => {
12050
12059
  const rewritten = importRewrites.get(specifier);
12051
12060
  if (rewritten) {
12052
- return `${prefix}${rewritten}${suffix}`;
12061
+ return `${prefix}${withCacheBuster(rewritten)}${suffix}`;
12053
12062
  }
12054
12063
  if (specifier.startsWith(".") || specifier.startsWith("/")) {
12055
12064
  return `${prefix}${specifier}${suffix}`;
@@ -12117,20 +12126,20 @@ ${fields}
12117
12126
  if (!resolved2)
12118
12127
  return null;
12119
12128
  const relativeImport = relative9(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
12120
- importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
12129
+ const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
12130
+ importRewrites.set(specifier, relativeRewrite);
12121
12131
  return resolved2;
12122
12132
  }).filter((path) => Boolean(path));
12123
12133
  const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
12124
12134
  const cacheKey2 = actualPath;
12125
- if (jitContentCache.get(cacheKey2) === contentHash && existsSync17(targetPath)) {
12126
- allOutputs.push(targetPath);
12127
- } else {
12135
+ const shouldWriteFile = cacheBuster ? true : jitContentCache.get(cacheKey2) !== contentHash || !existsSync17(targetPath);
12136
+ if (shouldWriteFile) {
12128
12137
  const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
12129
12138
  await fs.mkdir(targetDir, { recursive: true });
12130
12139
  await fs.writeFile(targetPath, processedContent, "utf-8");
12131
- allOutputs.push(targetPath);
12132
12140
  jitContentCache.set(cacheKey2, contentHash);
12133
12141
  }
12142
+ allOutputs.push(targetPath);
12134
12143
  await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
12135
12144
  };
12136
12145
  await transpileFile(inputPath);
@@ -15509,7 +15518,25 @@ ${stubs}
15509
15518
  return `${imports.join(`
15510
15519
  `)}
15511
15520
  ${code}`;
15512
- }, reactTranspilerOptions, reactTranspiler, transformReactFile = (filePath, projectRoot, rewriter) => {
15521
+ }, reactTranspilerOptions, reactTranspiler, probeReactFastRefresh = () => {
15522
+ try {
15523
+ const probeOptions = {
15524
+ loader: "tsx",
15525
+ reactFastRefresh: true
15526
+ };
15527
+ const probe = new Bun.Transpiler(probeOptions);
15528
+ const out = probe.transformSync("export function __AbsoluteRefreshProbe(){return null;}");
15529
+ return out.includes("$RefreshReg$");
15530
+ } catch {
15531
+ return false;
15532
+ }
15533
+ }, reactFastRefreshSupported, reactFastRefreshWarningEmitted = false, warnIfReactFastRefreshUnsupported = () => {
15534
+ if (reactFastRefreshSupported || reactFastRefreshWarningEmitted)
15535
+ return;
15536
+ reactFastRefreshWarningEmitted = true;
15537
+ logWarn("React HMR is blocked: this Bun build ignores " + "`reactFastRefresh` on Bun.Transpiler, so component state " + "cannot be preserved across edits. Tracking " + "https://github.com/oven-sh/bun/pull/28312 \u2014 if it still has " + "not merged, leave a \uD83D\uDC4D on the PR so the Bun team knows it " + "is blocking you. Until then, React edits trigger a full " + "reload instead of a fast refresh.");
15538
+ }, transformReactFile = (filePath, projectRoot, rewriter) => {
15539
+ warnIfReactFastRefreshUnsupported();
15513
15540
  const raw = readFileSync16(filePath, "utf-8");
15514
15541
  const valueExports = tsxTranspiler.scan(raw).exports;
15515
15542
  let transpiled = reactTranspiler.transformSync(raw);
@@ -16032,6 +16059,7 @@ var init_moduleServer = __esm(() => {
16032
16059
  init_stylePreprocessor();
16033
16060
  init_lowerAwaitSlotSyntax();
16034
16061
  init_lowerIslandSyntax();
16062
+ init_logger();
16035
16063
  init_transformCache();
16036
16064
  jsTranspiler2 = new Bun.Transpiler({
16037
16065
  loader: "js",
@@ -16077,6 +16105,7 @@ var init_moduleServer = __esm(() => {
16077
16105
  trimUnusedImports: true
16078
16106
  };
16079
16107
  reactTranspiler = new Bun.Transpiler(reactTranspilerOptions);
16108
+ reactFastRefreshSupported = probeReactFastRefresh();
16080
16109
  svelteExternalCss = new Map;
16081
16110
  SRC_IMPORT_RE = /\/@src\/([^"'?\s]+)/g;
16082
16111
  SRC_URL_PREFIX = SRC_PREFIX;
@@ -16577,101 +16606,6 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
16577
16606
  broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime);
16578
16607
  onRebuildComplete({ hmrState: state, manifest });
16579
16608
  return manifest;
16580
- }, resolveReactEntryForPageFile = (normalized, pagesPathResolved, reactIndexesPath) => {
16581
- const pageName = basename11(normalized, ".tsx");
16582
- const indexPath = resolve31(reactIndexesPath, `${pageName}.tsx`);
16583
- if (!existsSync23(indexPath)) {
16584
- return;
16585
- }
16586
- return indexPath;
16587
- }, resolveReactEntriesFromDeps = (state, normalized, pagesPathResolved, reactIndexesPath, reactEntries) => {
16588
- const affected = getAffectedFiles(state.dependencyGraph, normalized);
16589
- affected.forEach((dep) => {
16590
- if (!dep.startsWith(pagesPathResolved)) {
16591
- return;
16592
- }
16593
- const pageName = basename11(dep, ".tsx");
16594
- const indexPath = resolve31(reactIndexesPath, `${pageName}.tsx`);
16595
- if (existsSync23(indexPath) && !reactEntries.includes(indexPath)) {
16596
- reactEntries.push(indexPath);
16597
- }
16598
- });
16599
- }, resolveReactEntryForFile = (state, file4, pagesPathResolved, reactIndexesPath, reactEntries) => {
16600
- const normalized = resolve31(file4);
16601
- if (!normalized.startsWith(pagesPathResolved)) {
16602
- resolveReactEntriesFromDeps(state, normalized, pagesPathResolved, reactIndexesPath, reactEntries);
16603
- return;
16604
- }
16605
- const entry = resolveReactEntryForPageFile(normalized, pagesPathResolved, reactIndexesPath);
16606
- if (entry) {
16607
- reactEntries.push(entry);
16608
- }
16609
- }, collectReactEntries = (state, filesToRebuild, reactPagesPath, reactIndexesPath) => {
16610
- const reactEntries = [];
16611
- const pagesPathResolved = resolve31(reactPagesPath);
16612
- filesToRebuild.forEach((file4) => {
16613
- resolveReactEntryForFile(state, file4, pagesPathResolved, reactIndexesPath, reactEntries);
16614
- });
16615
- return reactEntries;
16616
- }, bundleReactClient = async (state, reactEntries, reactIndexesPath, buildDir) => {
16617
- const { build: bunBuild7 } = await Promise.resolve(globalThis.Bun);
16618
- const { generateManifest: generateManifest2 } = await Promise.resolve().then(() => (init_generateManifest(), exports_generateManifest));
16619
- const { getDevVendorPaths: getDevVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
16620
- const { rewriteReactImports: rewriteReactImports2 } = await Promise.resolve().then(() => (init_rewriteReactImports(), exports_rewriteReactImports));
16621
- const clientRoot = await computeClientRoot(state.resolvedPaths);
16622
- const depVendorPaths = globalThis.__depVendorPaths ?? {};
16623
- const refreshEntry = resolve31(reactIndexesPath, "_refresh.tsx");
16624
- if (!reactEntries.includes(refreshEntry)) {
16625
- reactEntries.push(refreshEntry);
16626
- }
16627
- let vendorPaths = getDevVendorPaths2();
16628
- if (!vendorPaths) {
16629
- const { computeVendorPaths: computeVendorPaths2 } = await Promise.resolve().then(() => (init_buildReactVendor(), exports_buildReactVendor));
16630
- const { setDevVendorPaths: setDevVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
16631
- vendorPaths = computeVendorPaths2();
16632
- setDevVendorPaths2(vendorPaths);
16633
- }
16634
- const { rmSync: rmSync3 } = await import("fs");
16635
- rmSync3(resolve31(buildDir, "react", "generated", "indexes"), {
16636
- force: true,
16637
- recursive: true
16638
- });
16639
- const clientResult = await bunBuild7({
16640
- entrypoints: reactEntries,
16641
- format: "esm",
16642
- jsx: { development: true },
16643
- naming: "[dir]/[name].[hash].[ext]",
16644
- outdir: buildDir,
16645
- plugins: [
16646
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
16647
- ],
16648
- reactFastRefresh: true,
16649
- root: clientRoot,
16650
- splitting: true,
16651
- target: "browser",
16652
- throw: false,
16653
- ...Object.keys({
16654
- ...vendorPaths ?? {},
16655
- ...depVendorPaths
16656
- }).length > 0 ? {
16657
- external: Object.keys({
16658
- ...vendorPaths ?? {},
16659
- ...depVendorPaths
16660
- })
16661
- } : {}
16662
- });
16663
- if (!clientResult.success) {
16664
- return;
16665
- }
16666
- if (vendorPaths || Object.keys(depVendorPaths).length > 0) {
16667
- await rewriteReactImports2(clientResult.outputs.map((art) => art.path), {
16668
- ...vendorPaths ?? {},
16669
- ...depVendorPaths
16670
- });
16671
- }
16672
- const clientManifest = generateManifest2(clientResult.outputs, buildDir);
16673
- Object.assign(state.manifest, clientManifest);
16674
- await populateAssetStore(state.assetStore, clientManifest, buildDir);
16675
16609
  }, getModuleUrl = async (pageFile) => {
16676
16610
  const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
16677
16611
  invalidateModule2(pageFile);
@@ -16728,39 +16662,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
16728
16662
  manifest: state.manifest
16729
16663
  });
16730
16664
  return state.manifest;
16731
- }, handleReactFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
16732
- const reactDir = config.reactDirectory ?? "";
16733
- const reactPagesPath = resolve31(reactDir, "pages");
16734
- const reactIndexesPath = resolve31(reactDir, "generated", "indexes");
16735
- const { buildDir } = state.resolvedPaths;
16665
+ }, handleReactFastPath = async (state, _config, filesToRebuild, startTime, onRebuildComplete) => {
16736
16666
  const reactFiles = filesToRebuild.filter((file4) => detectFramework(file4, state.resolvedPaths) === "react");
16737
- if (reactFiles.length > 0) {
16738
- return handleReactModuleServerPath(state, reactFiles, startTime, onRebuildComplete);
16739
- }
16740
- const { generateReactIndexFiles: generateReactIndexFiles2 } = await Promise.resolve().then(() => (init_generateReactIndexes(), exports_generateReactIndexes));
16741
- await generateReactIndexFiles2(reactPagesPath, reactIndexesPath, true);
16742
- const reactEntries = collectReactEntries(state, filesToRebuild, reactPagesPath, reactIndexesPath);
16743
- if (reactEntries.length > 0) {
16744
- await bundleReactClient(state, reactEntries, reactIndexesPath, buildDir);
16667
+ if (reactFiles.length === 0) {
16668
+ onRebuildComplete({ hmrState: state, manifest: state.manifest });
16669
+ return state.manifest;
16745
16670
  }
16746
- const { manifest } = state;
16747
- const duration = Date.now() - startTime;
16748
- const reactPageFiles = reactFiles.filter((file4) => file4.replace(/\\/g, "/").includes("/pages/"));
16749
- const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
16750
- logHmrUpdate(sourceFiles[0] ?? reactFiles[0] ?? "", "react", duration);
16751
- broadcastToClients(state, {
16752
- data: {
16753
- framework: "react",
16754
- hasComponentChanges: true,
16755
- hasCSSChanges: false,
16756
- manifest,
16757
- primarySource: sourceFiles[0],
16758
- sourceFiles
16759
- },
16760
- type: "react-update"
16761
- });
16762
- onRebuildComplete({ hmrState: state, manifest });
16763
- return manifest;
16671
+ return handleReactModuleServerPath(state, reactFiles, startTime, onRebuildComplete);
16764
16672
  }, handleServerManifestUpdate = (state, serverResult) => {
16765
16673
  if (!serverResult?.success) {
16766
16674
  return;
@@ -26832,5 +26740,5 @@ export {
26832
26740
  ANGULAR_INIT_TIMEOUT_MS
26833
26741
  };
26834
26742
 
26835
- //# debugId=160F1700C5043F5364756E2164756E21
26743
+ //# debugId=055B32AF286F100564756E2164756E21
26836
26744
  //# sourceMappingURL=index.js.map