@absolutejs/absolute 0.15.13 → 0.15.15

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
@@ -459,6 +459,58 @@ var init_renderToReadableStream = __esm(() => {
459
459
  init_escapeScriptContent();
460
460
  });
461
461
 
462
+ // src/utils/ssrErrorPage.ts
463
+ var ssrErrorPage = (framework, error) => {
464
+ const frameworkColors2 = {
465
+ angular: "#dd0031",
466
+ html: "#e34c26",
467
+ htmx: "#1a365d",
468
+ react: "#61dafb",
469
+ svelte: "#ff3e00",
470
+ vue: "#42b883"
471
+ };
472
+ const accent = frameworkColors2[framework] ?? "#94a3b8";
473
+ const label = framework.charAt(0).toUpperCase() + framework.slice(1);
474
+ const message = error instanceof Error ? error.message : String(error);
475
+ return `<!DOCTYPE html>
476
+ <html>
477
+ <head>
478
+ <meta charset="utf-8">
479
+ <meta name="viewport" content="width=device-width, initial-scale=1">
480
+ <title>SSR Error - AbsoluteJS</title>
481
+ <style>
482
+ *{margin:0;padding:0;box-sizing:border-box}
483
+ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:"JetBrains Mono","Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}
484
+ .card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}
485
+ .header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px 24px;background:rgba(15,23,42,0.5);border-bottom:1px solid rgba(71,85,105,0.4)}
486
+ .brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
487
+ .badge{padding:5px 10px;border-radius:8px;font-size:12px;font-weight:600;background:${accent};color:#fff;opacity:0.95;box-shadow:0 2px 4px rgba(0,0,0,0.2)}
488
+ .kind{color:#94a3b8;font-size:13px;font-weight:500}
489
+ .content{padding:24px}
490
+ .label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
491
+ .message{margin:0;padding:16px 20px;background:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.25);border-radius:10px;overflow-x:auto;white-space:pre-wrap;word-break:break-word;color:#fca5a5;font-size:13px;line-height:1.5}
492
+ .hint{margin-top:20px;padding:12px 20px;background:rgba(71,85,105,0.3);border-radius:10px;border:1px solid rgba(71,85,105,0.4);color:#cbd5e1;font-size:13px}
493
+ </style>
494
+ </head>
495
+ <body>
496
+ <div class="card">
497
+ <div class="header">
498
+ <div style="display:flex;align-items:center;gap:12px">
499
+ <span class="brand">AbsoluteJS</span>
500
+ <span class="badge">${label}</span>
501
+ </div>
502
+ <span class="kind">Server Render Error</span>
503
+ </div>
504
+ <div class="content">
505
+ <div class="label">What went wrong</div>
506
+ <pre class="message">${message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</pre>
507
+ <div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
508
+ </div>
509
+ </div>
510
+ </body>
511
+ </html>`;
512
+ };
513
+
462
514
  // src/core/pageHandlers.ts
463
515
  var exports_pageHandlers = {};
464
516
  __export(exports_pageHandlers, {
@@ -475,46 +527,73 @@ import { renderToReadableStream as renderReactToReadableStream } from "react-dom
475
527
  import { createSSRApp, h } from "vue";
476
528
  import { renderToWebStream as renderVueToWebStream } from "vue/server-renderer";
477
529
  var handleReactPageRequest = async (PageComponent, index, ...props) => {
478
- const [maybeProps] = props;
479
- const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
480
- const stream = await renderReactToReadableStream(element, {
481
- bootstrapModules: [index],
482
- bootstrapScriptContent: maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : undefined
483
- });
484
- return new Response(stream, {
485
- headers: { "Content-Type": "text/html" }
486
- });
530
+ try {
531
+ const [maybeProps] = props;
532
+ const element = maybeProps !== undefined ? createElement(PageComponent, maybeProps) : createElement(PageComponent);
533
+ const stream = await renderReactToReadableStream(element, {
534
+ bootstrapModules: [index],
535
+ bootstrapScriptContent: maybeProps ? `window.__INITIAL_PROPS__=${JSON.stringify(maybeProps)}` : undefined,
536
+ onError(error) {
537
+ console.error("[SSR] React streaming error:", error);
538
+ }
539
+ });
540
+ return new Response(stream, {
541
+ headers: { "Content-Type": "text/html" }
542
+ });
543
+ } catch (error) {
544
+ console.error("[SSR] React render error:", error);
545
+ return new Response(ssrErrorPage("react", error), {
546
+ status: 500,
547
+ headers: { "Content-Type": "text/html" }
548
+ });
549
+ }
487
550
  }, handleSveltePageRequest = async (_PageComponent, pagePath, indexPath, props) => {
488
- const { default: ImportedPageComponent } = await import(pagePath);
489
- const stream = await renderToReadableStream(ImportedPageComponent, props, {
490
- bootstrapModules: indexPath ? [indexPath] : [],
491
- bootstrapScriptContent: `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
492
- });
493
- return new Response(stream, {
494
- headers: { "Content-Type": "text/html" }
495
- });
551
+ try {
552
+ const { default: ImportedPageComponent } = await import(pagePath);
553
+ const stream = await renderToReadableStream(ImportedPageComponent, props, {
554
+ bootstrapModules: indexPath ? [indexPath] : [],
555
+ bootstrapScriptContent: `window.__INITIAL_PROPS__=${JSON.stringify(props)}`
556
+ });
557
+ return new Response(stream, {
558
+ headers: { "Content-Type": "text/html" }
559
+ });
560
+ } catch (error) {
561
+ console.error("[SSR] Svelte render error:", error);
562
+ return new Response(ssrErrorPage("svelte", error), {
563
+ status: 500,
564
+ headers: { "Content-Type": "text/html" }
565
+ });
566
+ }
496
567
  }, handleVuePageRequest = async (_PageComponent, pagePath, indexPath, headTag = "<head></head>", ...props) => {
497
- const [maybeProps] = props;
498
- const { default: ImportedPageComponent } = await import(pagePath);
499
- const app = createSSRApp({
500
- render: () => h(ImportedPageComponent, maybeProps ?? null)
501
- });
502
- const bodyStream = renderVueToWebStream(app);
503
- const head = `<!DOCTYPE html><html>${headTag}<body><div id="root">`;
504
- const tail = `</div><script>window.__INITIAL_PROPS__=${JSON.stringify(maybeProps ?? {})}</script><script type="module" src="${indexPath}"></script></body></html>`;
505
- const stream = new ReadableStream({
506
- start(controller) {
507
- controller.enqueue(head);
508
- const reader = bodyStream.getReader();
509
- const pumpLoop = () => {
510
- reader.read().then(({ done, value }) => done ? (controller.enqueue(tail), controller.close()) : (controller.enqueue(value), pumpLoop())).catch((err) => controller.error(err));
511
- };
512
- pumpLoop();
513
- }
514
- });
515
- return new Response(stream, {
516
- headers: { "Content-Type": "text/html" }
517
- });
568
+ try {
569
+ const [maybeProps] = props;
570
+ const { default: ImportedPageComponent } = await import(pagePath);
571
+ const app = createSSRApp({
572
+ render: () => h(ImportedPageComponent, maybeProps ?? null)
573
+ });
574
+ const bodyStream = renderVueToWebStream(app);
575
+ const head = `<!DOCTYPE html><html>${headTag}<body><div id="root">`;
576
+ const tail = `</div><script>window.__INITIAL_PROPS__=${JSON.stringify(maybeProps ?? {})}</script><script type="module" src="${indexPath}"></script></body></html>`;
577
+ const stream = new ReadableStream({
578
+ start(controller) {
579
+ controller.enqueue(head);
580
+ const reader = bodyStream.getReader();
581
+ const pumpLoop = () => {
582
+ reader.read().then(({ done, value }) => done ? (controller.enqueue(tail), controller.close()) : (controller.enqueue(value), pumpLoop())).catch((err) => controller.error(err));
583
+ };
584
+ pumpLoop();
585
+ }
586
+ });
587
+ return new Response(stream, {
588
+ headers: { "Content-Type": "text/html" }
589
+ });
590
+ } catch (error) {
591
+ console.error("[SSR] Vue render error:", error);
592
+ return new Response(ssrErrorPage("vue", error), {
593
+ status: 500,
594
+ headers: { "Content-Type": "text/html" }
595
+ });
596
+ }
518
597
  }, handleHTMLPageRequest = (pagePath) => file3(pagePath), handleHTMXPageRequest = (pagePath) => file3(pagePath), handlePageRequest = (PageComponent, ...props) => {
519
598
  console.log("handlePageRequest coming soon.", PageComponent, props);
520
599
  };
@@ -1405,14 +1484,14 @@ var cleanup = async ({
1405
1484
  vueDir,
1406
1485
  reactIndexesPath
1407
1486
  }) => {
1408
- if (svelteDir) {
1409
- await rm2(join4(svelteDir, "compiled"), { force: true, recursive: true });
1410
- }
1411
- if (vueDir) {
1412
- await rm2(join4(vueDir, "compiled"), { force: true, recursive: true });
1413
- }
1414
- if (reactIndexesPath)
1415
- await rm2(reactIndexesPath, { force: true, recursive: true });
1487
+ await Promise.all([
1488
+ svelteDir ? rm2(join4(svelteDir, "compiled"), {
1489
+ force: true,
1490
+ recursive: true
1491
+ }) : undefined,
1492
+ vueDir ? rm2(join4(vueDir, "compiled"), { force: true, recursive: true }) : undefined,
1493
+ reactIndexesPath ? rm2(reactIndexesPath, { force: true, recursive: true }) : undefined
1494
+ ]);
1416
1495
  };
1417
1496
 
1418
1497
  // src/utils/commonAncestor.ts
@@ -1662,18 +1741,30 @@ var build2 = async ({
1662
1741
  recursive: true
1663
1742
  });
1664
1743
  }
1665
- if (tailwind && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.endsWith(".css")))) {
1666
- await $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join5(buildPath, tailwind.output)}`;
1667
- }
1668
- const allReactEntries = reactIndexesPath ? await scanEntryPoints(reactIndexesPath, "*.tsx") : [];
1669
- const allHtmlEntries = htmlScriptsPath ? await scanEntryPoints(htmlScriptsPath, "*.{js,ts}") : [];
1670
- const allSvelteEntries = sveltePagesPath ? await scanEntryPoints(sveltePagesPath, "*.svelte") : [];
1671
- const allVueEntries = vuePagesPath ? await scanEntryPoints(vuePagesPath, "*.vue") : [];
1672
- const allAngularEntries = angularPagesPath ? await scanEntryPoints(angularPagesPath, "*.ts") : [];
1673
- const allHtmlCssEntries = htmlDir ? await scanEntryPoints(join5(htmlDir, "styles"), "*.css") : [];
1674
- const allHtmxCssEntries = htmxDir ? await scanEntryPoints(join5(htmxDir, "styles"), "*.css") : [];
1675
- const allReactCssEntries = reactDir ? await scanEntryPoints(join5(reactDir, "styles"), "*.css") : [];
1676
- const allSvelteCssEntries = svelteDir ? await scanEntryPoints(join5(svelteDir, "styles"), "*.css") : [];
1744
+ const tailwindPromise = tailwind && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.endsWith(".css"))) ? $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join5(buildPath, tailwind.output)}` : undefined;
1745
+ const [
1746
+ ,
1747
+ allReactEntries,
1748
+ allHtmlEntries,
1749
+ allSvelteEntries,
1750
+ allVueEntries,
1751
+ allAngularEntries,
1752
+ allHtmlCssEntries,
1753
+ allHtmxCssEntries,
1754
+ allReactCssEntries,
1755
+ allSvelteCssEntries
1756
+ ] = await Promise.all([
1757
+ tailwindPromise,
1758
+ reactIndexesPath ? scanEntryPoints(reactIndexesPath, "*.tsx") : [],
1759
+ htmlScriptsPath ? scanEntryPoints(htmlScriptsPath, "*.{js,ts}") : [],
1760
+ sveltePagesPath ? scanEntryPoints(sveltePagesPath, "*.svelte") : [],
1761
+ vuePagesPath ? scanEntryPoints(vuePagesPath, "*.vue") : [],
1762
+ angularPagesPath ? scanEntryPoints(angularPagesPath, "*.ts") : [],
1763
+ htmlDir ? scanEntryPoints(join5(htmlDir, "styles"), "*.css") : [],
1764
+ htmxDir ? scanEntryPoints(join5(htmxDir, "styles"), "*.css") : [],
1765
+ reactDir ? scanEntryPoints(join5(reactDir, "styles"), "*.css") : [],
1766
+ svelteDir ? scanEntryPoints(join5(svelteDir, "styles"), "*.css") : []
1767
+ ]);
1677
1768
  const shouldIncludeHtmlAssets = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/html/") && (f.endsWith(".html") || f.endsWith(".css")));
1678
1769
  const shouldIncludeHtmxAssets = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/htmx/") && (f.endsWith(".html") || f.endsWith(".css")));
1679
1770
  const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
@@ -1691,17 +1782,23 @@ var build2 = async ({
1691
1782
  const htmxCssEntries = isIncremental && !shouldIncludeHtmxAssets ? filterToIncrementalEntries(allHtmxCssEntries, (entry) => entry) : allHtmxCssEntries;
1692
1783
  const reactCssEntries = isIncremental ? filterToIncrementalEntries(allReactCssEntries, (entry) => entry) : allReactCssEntries;
1693
1784
  const svelteCssEntries = isIncremental ? filterToIncrementalEntries(allSvelteCssEntries, (entry) => entry) : allSvelteCssEntries;
1694
- const { svelteServerPaths, svelteIndexPaths, svelteClientPaths } = svelteDir ? await compileSvelte(svelteEntries, svelteDir, new Map, hmr) : {
1695
- svelteClientPaths: [],
1696
- svelteIndexPaths: [],
1697
- svelteServerPaths: []
1698
- };
1699
- const { vueServerPaths, vueIndexPaths, vueClientPaths, vueCssPaths } = vueDir ? await compileVue(vueEntries, vueDir, hmr) : {
1700
- vueClientPaths: [],
1701
- vueCssPaths: [],
1702
- vueIndexPaths: [],
1703
- vueServerPaths: []
1704
- };
1785
+ const hmrClientBundlePromise = hmr && (htmlDir || htmxDir) ? buildHMRClient() : undefined;
1786
+ const [
1787
+ { svelteServerPaths, svelteIndexPaths, svelteClientPaths },
1788
+ { vueServerPaths, vueIndexPaths, vueClientPaths, vueCssPaths }
1789
+ ] = await Promise.all([
1790
+ svelteDir ? compileSvelte(svelteEntries, svelteDir, new Map, hmr) : {
1791
+ svelteClientPaths: [],
1792
+ svelteIndexPaths: [],
1793
+ svelteServerPaths: []
1794
+ },
1795
+ vueDir ? compileVue(vueEntries, vueDir, hmr) : {
1796
+ vueClientPaths: [],
1797
+ vueCssPaths: [],
1798
+ vueIndexPaths: [],
1799
+ vueServerPaths: []
1800
+ }
1801
+ ]);
1705
1802
  const serverEntryPoints = [...svelteServerPaths, ...vueServerPaths];
1706
1803
  const reactClientEntryPoints = [...reactEntries];
1707
1804
  const nonReactClientEntryPoints = [
@@ -1722,32 +1819,6 @@ var build2 = async ({
1722
1819
  logger.warn("No entry points found, manifest will be empty");
1723
1820
  return {};
1724
1821
  }
1725
- let serverLogs = [];
1726
- let serverOutputs = [];
1727
- if (serverEntryPoints.length > 0) {
1728
- const result = await bunBuild2({
1729
- entrypoints: serverEntryPoints,
1730
- format: "esm",
1731
- naming: `[dir]/[name].[hash].[ext]`,
1732
- outdir: serverOutDir,
1733
- root: serverRoot,
1734
- target: "bun",
1735
- throw: false
1736
- });
1737
- serverLogs = result.logs;
1738
- serverOutputs = result.outputs;
1739
- if (!result.success && result.logs.length > 0) {
1740
- const errLog = result.logs.find((l) => l.level === "error") ?? result.logs[0];
1741
- const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
1742
- err.logs = result.logs;
1743
- logger.error("Server build failed", err);
1744
- if (throwOnError)
1745
- throw err;
1746
- exit(1);
1747
- }
1748
- }
1749
- let reactClientLogs = [];
1750
- let reactClientOutputs = [];
1751
1822
  if (hmr && reactIndexesPath && reactClientEntryPoints.length > 0) {
1752
1823
  const refreshEntry = join5(reactIndexesPath, "_refresh.tsx");
1753
1824
  if (!reactClientEntryPoints.includes(refreshEntry)) {
@@ -1755,8 +1826,9 @@ var build2 = async ({
1755
1826
  }
1756
1827
  }
1757
1828
  const vendorPaths = getDevVendorPaths();
1758
- if (reactClientEntryPoints.length > 0) {
1759
- const reactBuildConfig = {
1829
+ const htmlScriptPlugin = hmr ? createHTMLScriptHMRPlugin(htmlDir, htmxDir) : undefined;
1830
+ const reactBuildConfig = reactClientEntryPoints.length > 0 ? (() => {
1831
+ const cfg = {
1760
1832
  entrypoints: reactClientEntryPoints,
1761
1833
  format: "esm",
1762
1834
  minify: !isDev,
@@ -1768,12 +1840,63 @@ var build2 = async ({
1768
1840
  throw: false
1769
1841
  };
1770
1842
  if (vendorPaths) {
1771
- reactBuildConfig.external = Object.keys(vendorPaths);
1843
+ cfg.external = Object.keys(vendorPaths);
1772
1844
  }
1773
1845
  if (hmr) {
1774
- reactBuildConfig.reactFastRefresh = true;
1846
+ cfg.reactFastRefresh = true;
1775
1847
  }
1776
- const reactClientResult = await bunBuild2(reactBuildConfig);
1848
+ return cfg;
1849
+ })() : undefined;
1850
+ const [serverResult, reactClientResult, nonReactClientResult, cssResult] = await Promise.all([
1851
+ serverEntryPoints.length > 0 ? bunBuild2({
1852
+ entrypoints: serverEntryPoints,
1853
+ format: "esm",
1854
+ naming: `[dir]/[name].[hash].[ext]`,
1855
+ outdir: serverOutDir,
1856
+ root: serverRoot,
1857
+ target: "bun",
1858
+ throw: false
1859
+ }) : undefined,
1860
+ reactBuildConfig ? bunBuild2(reactBuildConfig) : undefined,
1861
+ nonReactClientEntryPoints.length > 0 ? bunBuild2({
1862
+ define: vueDirectory ? vueFeatureFlags : undefined,
1863
+ entrypoints: nonReactClientEntryPoints,
1864
+ format: "esm",
1865
+ minify: !isDev,
1866
+ naming: `[dir]/[name].[hash].[ext]`,
1867
+ outdir: buildPath,
1868
+ plugins: htmlScriptPlugin ? [htmlScriptPlugin] : undefined,
1869
+ root: clientRoot,
1870
+ target: "browser",
1871
+ splitting: !isDev,
1872
+ throw: false
1873
+ }) : undefined,
1874
+ cssEntryPoints.length > 0 ? bunBuild2({
1875
+ entrypoints: cssEntryPoints,
1876
+ naming: `[name].[hash].[ext]`,
1877
+ outdir: join5(buildPath, assetsPath ? basename4(assetsPath) : "assets", "css"),
1878
+ target: "browser",
1879
+ throw: false
1880
+ }) : undefined
1881
+ ]);
1882
+ let serverLogs = [];
1883
+ let serverOutputs = [];
1884
+ if (serverResult) {
1885
+ serverLogs = serverResult.logs;
1886
+ serverOutputs = serverResult.outputs;
1887
+ if (!serverResult.success && serverResult.logs.length > 0) {
1888
+ const errLog = serverResult.logs.find((l) => l.level === "error") ?? serverResult.logs[0];
1889
+ const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
1890
+ err.logs = serverResult.logs;
1891
+ logger.error("Server build failed", err);
1892
+ if (throwOnError)
1893
+ throw err;
1894
+ exit(1);
1895
+ }
1896
+ }
1897
+ let reactClientLogs = [];
1898
+ let reactClientOutputs = [];
1899
+ if (reactClientResult) {
1777
1900
  reactClientLogs = reactClientResult.logs;
1778
1901
  reactClientOutputs = reactClientResult.outputs;
1779
1902
  if (!reactClientResult.success && reactClientResult.logs.length > 0) {
@@ -1791,21 +1914,7 @@ var build2 = async ({
1791
1914
  }
1792
1915
  let nonReactClientLogs = [];
1793
1916
  let nonReactClientOutputs = [];
1794
- if (nonReactClientEntryPoints.length > 0) {
1795
- const htmlScriptPlugin = hmr ? createHTMLScriptHMRPlugin(htmlDir, htmxDir) : undefined;
1796
- const nonReactClientResult = await bunBuild2({
1797
- define: vueDirectory ? vueFeatureFlags : undefined,
1798
- entrypoints: nonReactClientEntryPoints,
1799
- format: "esm",
1800
- minify: !isDev,
1801
- naming: `[dir]/[name].[hash].[ext]`,
1802
- outdir: buildPath,
1803
- plugins: htmlScriptPlugin ? [htmlScriptPlugin] : undefined,
1804
- root: clientRoot,
1805
- target: "browser",
1806
- splitting: !isDev,
1807
- throw: false
1808
- });
1917
+ if (nonReactClientResult) {
1809
1918
  nonReactClientLogs = nonReactClientResult.logs;
1810
1919
  nonReactClientOutputs = nonReactClientResult.outputs;
1811
1920
  if (!nonReactClientResult.success && nonReactClientResult.logs.length > 0) {
@@ -1820,14 +1929,7 @@ var build2 = async ({
1820
1929
  }
1821
1930
  let cssLogs = [];
1822
1931
  let cssOutputs = [];
1823
- if (cssEntryPoints.length > 0) {
1824
- const cssResult = await bunBuild2({
1825
- entrypoints: cssEntryPoints,
1826
- naming: `[name].[hash].[ext]`,
1827
- outdir: join5(buildPath, assetsPath ? basename4(assetsPath) : "assets", "css"),
1828
- target: "browser",
1829
- throw: false
1830
- });
1932
+ if (cssResult) {
1831
1933
  cssLogs = cssResult.logs;
1832
1934
  cssOutputs = cssResult.outputs;
1833
1935
  if (!cssResult.success && cssResult.logs.length > 0) {
@@ -1866,7 +1968,7 @@ var build2 = async ({
1866
1968
  const shouldCopyHtmx = htmxOrHtmxCssChanged;
1867
1969
  const shouldUpdateHtmlAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/html/") && (f.endsWith(".html") || f.endsWith(".css")));
1868
1970
  const shouldUpdateHtmxAssetPaths = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/htmx/") && (f.endsWith(".html") || f.endsWith(".css")));
1869
- const hmrClientBundle = hmr && (htmlDir || htmxDir) ? await buildHMRClient() : null;
1971
+ const hmrClientBundle = hmrClientBundlePromise ? await hmrClientBundlePromise : null;
1870
1972
  const injectHMRIntoHTMLFile = (filePath, framework) => {
1871
1973
  if (!hmrClientBundle)
1872
1974
  return;
@@ -1878,57 +1980,63 @@ var build2 = async ({
1878
1980
  html = bodyClose ? html.slice(0, bodyClose.index) + tag + html.slice(bodyClose.index) : html + tag;
1879
1981
  writeFileSync(filePath, html);
1880
1982
  };
1881
- if (htmlDir && htmlPagesPath) {
1882
- const outputHtmlPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmlDir), "pages");
1883
- if (shouldCopyHtml) {
1884
- mkdirSync(outputHtmlPages, { recursive: true });
1885
- cpSync(htmlPagesPath, outputHtmlPages, {
1886
- force: true,
1887
- recursive: true
1888
- });
1889
- }
1890
- if (shouldUpdateHtmlAssetPaths) {
1891
- await updateAssetPaths(manifest, outputHtmlPages);
1892
- }
1893
- const htmlPageFiles = await scanEntryPoints(outputHtmlPages, "*.html");
1894
- for (const htmlFile of htmlPageFiles) {
1895
- if (hmr)
1896
- injectHMRIntoHTMLFile(htmlFile, "html");
1897
- const fileName = basename4(htmlFile, ".html");
1898
- manifest[fileName] = htmlFile;
1899
- }
1900
- }
1901
- if (htmxDir && htmxPagesPath) {
1902
- const outputHtmxPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmxDir), "pages");
1903
- if (shouldCopyHtmx) {
1904
- mkdirSync(outputHtmxPages, { recursive: true });
1905
- cpSync(htmxPagesPath, outputHtmxPages, {
1906
- force: true,
1907
- recursive: true
1908
- });
1909
- }
1910
- if (shouldCopyHtmx) {
1911
- const htmxDestDir = isSingle ? buildPath : join5(buildPath, basename4(htmxDir));
1912
- mkdirSync(htmxDestDir, { recursive: true });
1913
- const glob = new Glob3("htmx*.min.js");
1914
- for (const relPath of glob.scanSync({ cwd: htmxDir })) {
1915
- const src = join5(htmxDir, relPath);
1916
- const dest = join5(htmxDestDir, "htmx.min.js");
1917
- copyFileSync(src, dest);
1918
- break;
1983
+ await Promise.all([
1984
+ (async () => {
1985
+ if (!(htmlDir && htmlPagesPath))
1986
+ return;
1987
+ const outputHtmlPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmlDir), "pages");
1988
+ if (shouldCopyHtml) {
1989
+ mkdirSync(outputHtmlPages, { recursive: true });
1990
+ cpSync(htmlPagesPath, outputHtmlPages, {
1991
+ force: true,
1992
+ recursive: true
1993
+ });
1919
1994
  }
1920
- }
1921
- if (shouldUpdateHtmxAssetPaths) {
1922
- await updateAssetPaths(manifest, outputHtmxPages);
1923
- }
1924
- const htmxPageFiles = await scanEntryPoints(outputHtmxPages, "*.html");
1925
- for (const htmxFile of htmxPageFiles) {
1926
- if (hmr)
1927
- injectHMRIntoHTMLFile(htmxFile, "htmx");
1928
- const fileName = basename4(htmxFile, ".html");
1929
- manifest[fileName] = htmxFile;
1930
- }
1931
- }
1995
+ if (shouldUpdateHtmlAssetPaths) {
1996
+ await updateAssetPaths(manifest, outputHtmlPages);
1997
+ }
1998
+ const htmlPageFiles = await scanEntryPoints(outputHtmlPages, "*.html");
1999
+ for (const htmlFile of htmlPageFiles) {
2000
+ if (hmr)
2001
+ injectHMRIntoHTMLFile(htmlFile, "html");
2002
+ const fileName = basename4(htmlFile, ".html");
2003
+ manifest[fileName] = htmlFile;
2004
+ }
2005
+ })(),
2006
+ (async () => {
2007
+ if (!(htmxDir && htmxPagesPath))
2008
+ return;
2009
+ const outputHtmxPages = isSingle ? join5(buildPath, "pages") : join5(buildPath, basename4(htmxDir), "pages");
2010
+ if (shouldCopyHtmx) {
2011
+ mkdirSync(outputHtmxPages, { recursive: true });
2012
+ cpSync(htmxPagesPath, outputHtmxPages, {
2013
+ force: true,
2014
+ recursive: true
2015
+ });
2016
+ }
2017
+ if (shouldCopyHtmx) {
2018
+ const htmxDestDir = isSingle ? buildPath : join5(buildPath, basename4(htmxDir));
2019
+ mkdirSync(htmxDestDir, { recursive: true });
2020
+ const glob = new Glob3("htmx*.min.js");
2021
+ for (const relPath of glob.scanSync({ cwd: htmxDir })) {
2022
+ const src = join5(htmxDir, relPath);
2023
+ const dest = join5(htmxDestDir, "htmx.min.js");
2024
+ copyFileSync(src, dest);
2025
+ break;
2026
+ }
2027
+ }
2028
+ if (shouldUpdateHtmxAssetPaths) {
2029
+ await updateAssetPaths(manifest, outputHtmxPages);
2030
+ }
2031
+ const htmxPageFiles = await scanEntryPoints(outputHtmxPages, "*.html");
2032
+ for (const htmxFile of htmxPageFiles) {
2033
+ if (hmr)
2034
+ injectHMRIntoHTMLFile(htmxFile, "htmx");
2035
+ const fileName = basename4(htmxFile, ".html");
2036
+ manifest[fileName] = htmxFile;
2037
+ }
2038
+ })()
2039
+ ]);
1932
2040
  if (!options?.preserveIntermediateFiles)
1933
2041
  await cleanup({
1934
2042
  reactIndexesPath,
@@ -3656,5 +3764,5 @@ export {
3656
3764
  BUN_BUILD_WARNING_SUPPRESSION
3657
3765
  };
3658
3766
 
3659
- //# debugId=D632BA6ED9E5CC8464756E2164756E21
3767
+ //# debugId=642AFCA25CB4FBDB64756E2164756E21
3660
3768
  //# sourceMappingURL=index.js.map