@absolutejs/absolute 0.19.0-beta.832 → 0.19.0-beta.834

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
@@ -658,10 +658,6 @@ var init_islandEntries = __esm(() => {
658
658
  });
659
659
 
660
660
  // src/build/generateReactIndexes.ts
661
- var exports_generateReactIndexes = {};
662
- __export(exports_generateReactIndexes, {
663
- generateReactIndexFiles: () => generateReactIndexFiles
664
- });
665
661
  import { existsSync, mkdirSync as mkdirSync2 } from "fs";
666
662
  import { readdir, rm, writeFile } from "fs/promises";
667
663
  import { basename, join as join2, relative as relative2, resolve as resolve2, sep } from "path";
@@ -9323,11 +9319,6 @@ var init_nativeRewrite = __esm(() => {
9323
9319
  });
9324
9320
 
9325
9321
  // src/build/rewriteReactImports.ts
9326
- var exports_rewriteReactImports = {};
9327
- __export(exports_rewriteReactImports, {
9328
- rewriteReactImports: () => rewriteReactImports,
9329
- patchRefreshGlobals: () => patchRefreshGlobals
9330
- });
9331
9322
  var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), rewriterCache, cacheKey = (vendorPaths) => {
9332
9323
  const entries = Object.entries(vendorPaths).sort(([left], [right]) => left.localeCompare(right));
9333
9324
  let key = "";
@@ -11267,21 +11258,34 @@ ${registrations}
11267
11258
  if (fileName.startsWith(outDir))
11268
11259
  return fileName.substring(outDir.length + 1);
11269
11260
  return fileName;
11270
- }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
11271
- if (specifier.endsWith(".ts"))
11272
- return specifier.replace(/\.ts$/, ".js");
11273
- if (hasJsLikeExtension(specifier))
11274
- return specifier;
11261
+ }, hasJsLikeExtension = (path) => /\.(js|ts|mjs|cjs)$/.test(path), splitSpecifierAndQuery = (specifier) => {
11262
+ const separator = specifier.indexOf("?");
11263
+ if (separator === -1) {
11264
+ return {
11265
+ path: specifier,
11266
+ query: ""
11267
+ };
11268
+ }
11269
+ return {
11270
+ path: specifier.substring(0, separator),
11271
+ query: specifier.substring(separator)
11272
+ };
11273
+ }, rewriteRelativeJsSpecifier = (importerOutputPath, specifier, outputFiles) => {
11274
+ const { path, query } = splitSpecifierAndQuery(specifier);
11275
+ if (path.endsWith(".ts"))
11276
+ return `${path.replace(/\.ts$/, ".js")}${query}`;
11277
+ if (hasJsLikeExtension(path))
11278
+ return `${path}${query}`;
11275
11279
  const importerDir = dirname11(importerOutputPath);
11276
- const fileCandidate = resolve16(importerDir, `${specifier}.js`);
11280
+ const fileCandidate = resolve16(importerDir, `${path}.js`);
11277
11281
  if (outputFiles?.has(fileCandidate) || existsSync16(fileCandidate)) {
11278
- return `${specifier}.js`;
11282
+ return `${path}.js${query}`;
11279
11283
  }
11280
- const indexCandidate = resolve16(importerDir, specifier, "index.js");
11284
+ const indexCandidate = resolve16(importerDir, path, "index.js");
11281
11285
  if (outputFiles?.has(indexCandidate) || existsSync16(indexCandidate)) {
11282
- return `${specifier}/index.js`;
11286
+ return `${path}/index.js${query}`;
11283
11287
  }
11284
- return `${specifier}.js`;
11288
+ return `${path}.js${query}`;
11285
11289
  }, isRelativeModuleSpecifier = (specifier) => specifier.startsWith("./") || specifier.startsWith("../"), extractLocalImportSpecifiers = (source, fileName) => {
11286
11290
  const sourceFile = ts2.createSourceFile(fileName, source, ts2.ScriptTarget.Latest, true, ts2.ScriptKind.TS);
11287
11291
  const specifiers = [];
@@ -11797,7 +11801,7 @@ ${fields}
11797
11801
  deferSlots: inlinedTemplate.deferSlots,
11798
11802
  source: result
11799
11803
  };
11800
- }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors) => {
11804
+ }, compileAngularFileJIT = async (inputPath, outDir, rootDir, stylePreprocessors, cacheBuster) => {
11801
11805
  const entryPath = resolve16(inputPath);
11802
11806
  const allOutputs = [];
11803
11807
  const visited = new Set;
@@ -11851,13 +11855,18 @@ ${fields}
11851
11855
  const fileBase = basename6(sourcePath).replace(/\.[cm]?[tj]sx?$/, ".js");
11852
11856
  return join16(outDir, relativeDir, fileBase);
11853
11857
  };
11858
+ const withCacheBuster = (specifier) => {
11859
+ if (!cacheBuster)
11860
+ return specifier;
11861
+ return specifier.includes("?") ? `${specifier}&t=${cacheBuster}` : `${specifier}?t=${cacheBuster}`;
11862
+ };
11854
11863
  const transpileAndRewrite = (sourceCode, relativeDir, actualPath, importRewrites) => {
11855
11864
  let processedContent = angularTranspiler.transformSync(sourceCode);
11856
11865
  const outputPath = toOutputPath(actualPath);
11857
11866
  const rewriteBareImport = (prefix, specifier, suffix) => {
11858
11867
  const rewritten = importRewrites.get(specifier);
11859
11868
  if (rewritten) {
11860
- return `${prefix}${rewritten}${suffix}`;
11869
+ return `${prefix}${withCacheBuster(rewritten)}${suffix}`;
11861
11870
  }
11862
11871
  if (specifier.startsWith(".") || specifier.startsWith("/")) {
11863
11872
  return `${prefix}${specifier}${suffix}`;
@@ -11925,20 +11934,20 @@ ${fields}
11925
11934
  if (!resolved2)
11926
11935
  return null;
11927
11936
  const relativeImport = relative9(targetDir, toOutputPath(resolved2)).replace(/\\/g, "/").replace(/\.js$/, "");
11928
- importRewrites.set(specifier, relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`);
11937
+ const relativeRewrite = relativeImport.startsWith(".") ? relativeImport : `./${relativeImport}`;
11938
+ importRewrites.set(specifier, relativeRewrite);
11929
11939
  return resolved2;
11930
11940
  }).filter((path) => Boolean(path));
11931
11941
  const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
11932
11942
  const cacheKey2 = actualPath;
11933
- if (jitContentCache.get(cacheKey2) === contentHash && existsSync16(targetPath)) {
11934
- allOutputs.push(targetPath);
11935
- } else {
11943
+ const shouldWriteFile = cacheBuster ? true : jitContentCache.get(cacheKey2) !== contentHash || !existsSync16(targetPath);
11944
+ if (shouldWriteFile) {
11936
11945
  const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath, importRewrites);
11937
11946
  await fs.mkdir(targetDir, { recursive: true });
11938
11947
  await fs.writeFile(targetPath, processedContent, "utf-8");
11939
- allOutputs.push(targetPath);
11940
11948
  jitContentCache.set(cacheKey2, contentHash);
11941
11949
  }
11950
+ allOutputs.push(targetPath);
11942
11951
  await Promise.all(localImportPaths.map((importPath) => transpileFile(importPath)));
11943
11952
  };
11944
11953
  await transpileFile(inputPath);
@@ -15412,7 +15421,25 @@ ${stubs}
15412
15421
  return `${imports.join(`
15413
15422
  `)}
15414
15423
  ${code}`;
15415
- }, reactTranspilerOptions, reactTranspiler, transformReactFile = (filePath, projectRoot, rewriter) => {
15424
+ }, reactTranspilerOptions, reactTranspiler, probeReactFastRefresh = () => {
15425
+ try {
15426
+ const probeOptions = {
15427
+ loader: "tsx",
15428
+ reactFastRefresh: true
15429
+ };
15430
+ const probe = new Bun.Transpiler(probeOptions);
15431
+ const out = probe.transformSync("export function __AbsoluteRefreshProbe(){return null;}");
15432
+ return out.includes("$RefreshReg$");
15433
+ } catch {
15434
+ return false;
15435
+ }
15436
+ }, reactFastRefreshSupported, reactFastRefreshWarningEmitted = false, warnIfReactFastRefreshUnsupported = () => {
15437
+ if (reactFastRefreshSupported || reactFastRefreshWarningEmitted)
15438
+ return;
15439
+ reactFastRefreshWarningEmitted = true;
15440
+ 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.");
15441
+ }, transformReactFile = (filePath, projectRoot, rewriter) => {
15442
+ warnIfReactFastRefreshUnsupported();
15416
15443
  const raw = readFileSync15(filePath, "utf-8");
15417
15444
  const valueExports = tsxTranspiler.scan(raw).exports;
15418
15445
  let transpiled = reactTranspiler.transformSync(raw);
@@ -15935,6 +15962,7 @@ var init_moduleServer = __esm(() => {
15935
15962
  init_stylePreprocessor();
15936
15963
  init_lowerAwaitSlotSyntax();
15937
15964
  init_lowerIslandSyntax();
15965
+ init_logger();
15938
15966
  init_transformCache();
15939
15967
  jsTranspiler2 = new Bun.Transpiler({
15940
15968
  loader: "js",
@@ -15980,6 +16008,7 @@ var init_moduleServer = __esm(() => {
15980
16008
  trimUnusedImports: true
15981
16009
  };
15982
16010
  reactTranspiler = new Bun.Transpiler(reactTranspilerOptions);
16011
+ reactFastRefreshSupported = probeReactFastRefresh();
15983
16012
  svelteExternalCss = new Map;
15984
16013
  SRC_IMPORT_RE = /\/@src\/([^"'?\s]+)/g;
15985
16014
  SRC_URL_PREFIX = SRC_PREFIX;
@@ -16450,13 +16479,22 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
16450
16479
  const { clientPaths, serverPaths } = await compileAngular2(pageEntries, angularDir, true, getStyleTransformConfig(state.config));
16451
16480
  const { getAngularServerVendorPaths: getAngularServerVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
16452
16481
  const angServerVendorPaths = getAngularServerVendorPaths2();
16482
+ const ssrPaths = angServerVendorPaths ? serverPaths.map((serverPath) => serverPath.replace(/\.js$/, ".ssr.js")) : serverPaths;
16453
16483
  if (serverPaths.length > 0 && angServerVendorPaths) {
16484
+ const { copyFile } = await import("fs/promises");
16454
16485
  const { rewriteImports: rewriteImports3 } = await Promise.resolve().then(() => (init_rewriteImports(), exports_rewriteImports));
16455
- await rewriteImports3(serverPaths, angServerVendorPaths);
16486
+ await Promise.all(serverPaths.map((serverPath, idx) => {
16487
+ const ssrPath = ssrPaths[idx];
16488
+ if (!ssrPath)
16489
+ return Promise.resolve();
16490
+ return copyFile(serverPath, ssrPath);
16491
+ }));
16492
+ await rewriteImports3(ssrPaths, angServerVendorPaths);
16456
16493
  }
16457
- serverPaths.forEach((serverPath) => {
16494
+ serverPaths.forEach((serverPath, idx) => {
16458
16495
  const fileBase = basename10(serverPath, ".js");
16459
- state.manifest[toPascal(fileBase)] = resolve29(serverPath);
16496
+ const ssrPath = ssrPaths[idx] ?? serverPath;
16497
+ state.manifest[toPascal(fileBase)] = resolve29(ssrPath);
16460
16498
  });
16461
16499
  if (clientPaths.length > 0) {
16462
16500
  await bundleAngularClient(state, clientPaths, state.resolvedPaths.buildDir);
@@ -16480,101 +16518,6 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
16480
16518
  broadcastAngularPageUpdates(state, pagesToUpdate, manifest, startTime);
16481
16519
  onRebuildComplete({ hmrState: state, manifest });
16482
16520
  return manifest;
16483
- }, resolveReactEntryForPageFile = (normalized, pagesPathResolved, reactIndexesPath) => {
16484
- const pageName = basename10(normalized, ".tsx");
16485
- const indexPath = resolve29(reactIndexesPath, `${pageName}.tsx`);
16486
- if (!existsSync22(indexPath)) {
16487
- return;
16488
- }
16489
- return indexPath;
16490
- }, resolveReactEntriesFromDeps = (state, normalized, pagesPathResolved, reactIndexesPath, reactEntries) => {
16491
- const affected = getAffectedFiles(state.dependencyGraph, normalized);
16492
- affected.forEach((dep) => {
16493
- if (!dep.startsWith(pagesPathResolved)) {
16494
- return;
16495
- }
16496
- const pageName = basename10(dep, ".tsx");
16497
- const indexPath = resolve29(reactIndexesPath, `${pageName}.tsx`);
16498
- if (existsSync22(indexPath) && !reactEntries.includes(indexPath)) {
16499
- reactEntries.push(indexPath);
16500
- }
16501
- });
16502
- }, resolveReactEntryForFile = (state, file3, pagesPathResolved, reactIndexesPath, reactEntries) => {
16503
- const normalized = resolve29(file3);
16504
- if (!normalized.startsWith(pagesPathResolved)) {
16505
- resolveReactEntriesFromDeps(state, normalized, pagesPathResolved, reactIndexesPath, reactEntries);
16506
- return;
16507
- }
16508
- const entry = resolveReactEntryForPageFile(normalized, pagesPathResolved, reactIndexesPath);
16509
- if (entry) {
16510
- reactEntries.push(entry);
16511
- }
16512
- }, collectReactEntries = (state, filesToRebuild, reactPagesPath, reactIndexesPath) => {
16513
- const reactEntries = [];
16514
- const pagesPathResolved = resolve29(reactPagesPath);
16515
- filesToRebuild.forEach((file3) => {
16516
- resolveReactEntryForFile(state, file3, pagesPathResolved, reactIndexesPath, reactEntries);
16517
- });
16518
- return reactEntries;
16519
- }, bundleReactClient = async (state, reactEntries, reactIndexesPath, buildDir) => {
16520
- const { build: bunBuild7 } = await Promise.resolve(globalThis.Bun);
16521
- const { generateManifest: generateManifest2 } = await Promise.resolve().then(() => (init_generateManifest(), exports_generateManifest));
16522
- const { getDevVendorPaths: getDevVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
16523
- const { rewriteReactImports: rewriteReactImports2 } = await Promise.resolve().then(() => (init_rewriteReactImports(), exports_rewriteReactImports));
16524
- const clientRoot = await computeClientRoot(state.resolvedPaths);
16525
- const depVendorPaths = globalThis.__depVendorPaths ?? {};
16526
- const refreshEntry = resolve29(reactIndexesPath, "_refresh.tsx");
16527
- if (!reactEntries.includes(refreshEntry)) {
16528
- reactEntries.push(refreshEntry);
16529
- }
16530
- let vendorPaths = getDevVendorPaths2();
16531
- if (!vendorPaths) {
16532
- const { computeVendorPaths: computeVendorPaths2 } = await Promise.resolve().then(() => (init_buildReactVendor(), exports_buildReactVendor));
16533
- const { setDevVendorPaths: setDevVendorPaths2 } = await Promise.resolve().then(() => exports_devVendorPaths);
16534
- vendorPaths = computeVendorPaths2();
16535
- setDevVendorPaths2(vendorPaths);
16536
- }
16537
- const { rmSync: rmSync3 } = await import("fs");
16538
- rmSync3(resolve29(buildDir, "react", "generated", "indexes"), {
16539
- force: true,
16540
- recursive: true
16541
- });
16542
- const clientResult = await bunBuild7({
16543
- entrypoints: reactEntries,
16544
- format: "esm",
16545
- jsx: { development: true },
16546
- naming: "[dir]/[name].[hash].[ext]",
16547
- outdir: buildDir,
16548
- plugins: [
16549
- createStylePreprocessorPlugin(getStyleTransformConfig(state.config))
16550
- ],
16551
- reactFastRefresh: true,
16552
- root: clientRoot,
16553
- splitting: true,
16554
- target: "browser",
16555
- throw: false,
16556
- ...Object.keys({
16557
- ...vendorPaths ?? {},
16558
- ...depVendorPaths
16559
- }).length > 0 ? {
16560
- external: Object.keys({
16561
- ...vendorPaths ?? {},
16562
- ...depVendorPaths
16563
- })
16564
- } : {}
16565
- });
16566
- if (!clientResult.success) {
16567
- return;
16568
- }
16569
- if (vendorPaths || Object.keys(depVendorPaths).length > 0) {
16570
- await rewriteReactImports2(clientResult.outputs.map((art) => art.path), {
16571
- ...vendorPaths ?? {},
16572
- ...depVendorPaths
16573
- });
16574
- }
16575
- const clientManifest = generateManifest2(clientResult.outputs, buildDir);
16576
- Object.assign(state.manifest, clientManifest);
16577
- await populateAssetStore(state.assetStore, clientManifest, buildDir);
16578
16521
  }, getModuleUrl = async (pageFile) => {
16579
16522
  const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
16580
16523
  invalidateModule2(pageFile);
@@ -16631,39 +16574,13 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
16631
16574
  manifest: state.manifest
16632
16575
  });
16633
16576
  return state.manifest;
16634
- }, handleReactFastPath = async (state, config, filesToRebuild, startTime, onRebuildComplete) => {
16635
- const reactDir = config.reactDirectory ?? "";
16636
- const reactPagesPath = resolve29(reactDir, "pages");
16637
- const reactIndexesPath = resolve29(reactDir, "generated", "indexes");
16638
- const { buildDir } = state.resolvedPaths;
16577
+ }, handleReactFastPath = async (state, _config, filesToRebuild, startTime, onRebuildComplete) => {
16639
16578
  const reactFiles = filesToRebuild.filter((file3) => detectFramework(file3, state.resolvedPaths) === "react");
16640
- if (reactFiles.length > 0) {
16641
- return handleReactModuleServerPath(state, reactFiles, startTime, onRebuildComplete);
16642
- }
16643
- const { generateReactIndexFiles: generateReactIndexFiles2 } = await Promise.resolve().then(() => (init_generateReactIndexes(), exports_generateReactIndexes));
16644
- await generateReactIndexFiles2(reactPagesPath, reactIndexesPath, true);
16645
- const reactEntries = collectReactEntries(state, filesToRebuild, reactPagesPath, reactIndexesPath);
16646
- if (reactEntries.length > 0) {
16647
- await bundleReactClient(state, reactEntries, reactIndexesPath, buildDir);
16579
+ if (reactFiles.length === 0) {
16580
+ onRebuildComplete({ hmrState: state, manifest: state.manifest });
16581
+ return state.manifest;
16648
16582
  }
16649
- const { manifest } = state;
16650
- const duration = Date.now() - startTime;
16651
- const reactPageFiles = reactFiles.filter((file3) => file3.replace(/\\/g, "/").includes("/pages/"));
16652
- const sourceFiles = reactPageFiles.length > 0 ? reactPageFiles : reactFiles;
16653
- logHmrUpdate(sourceFiles[0] ?? reactFiles[0] ?? "", "react", duration);
16654
- broadcastToClients(state, {
16655
- data: {
16656
- framework: "react",
16657
- hasComponentChanges: true,
16658
- hasCSSChanges: false,
16659
- manifest,
16660
- primarySource: sourceFiles[0],
16661
- sourceFiles
16662
- },
16663
- type: "react-update"
16664
- });
16665
- onRebuildComplete({ hmrState: state, manifest });
16666
- return manifest;
16583
+ return handleReactModuleServerPath(state, reactFiles, startTime, onRebuildComplete);
16667
16584
  }, handleServerManifestUpdate = (state, serverResult) => {
16668
16585
  if (!serverResult?.success) {
16669
16586
  return;
@@ -18237,5 +18154,5 @@ export {
18237
18154
  build
18238
18155
  };
18239
18156
 
18240
- //# debugId=075C1C8286293C6864756E2164756E21
18157
+ //# debugId=324E7F2682AE824164756E2164756E21
18241
18158
  //# sourceMappingURL=build.js.map