@absolutejs/absolute 0.19.0-beta.782 → 0.19.0-beta.783

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
@@ -704,7 +704,8 @@ var indexContentCache, resolveDevClientDir = () => {
704
704
  const pagesRelPath = relative2(resolve2(reactIndexesDirectory), resolve2(reactPagesDirectory)).split(sep).join("/");
705
705
  const promises = files.map(async (file) => {
706
706
  const fileName = basename(file);
707
- const [componentName] = fileName.split(".");
707
+ const componentName = fileName.split(".")[0];
708
+ const pascalComponentName = toPascal(componentName);
708
709
  const hmrPreamble = isDev ? [
709
710
  `window.__HMR_FRAMEWORK__ = "react";`,
710
711
  `window.__REACT_COMPONENT_KEY__ = "${componentName}Index";`,
@@ -758,12 +759,25 @@ var indexContentCache, resolveDevClientDir = () => {
758
759
  const content = [
759
760
  ...hmrPreamble,
760
761
  ...reactImports,
761
- `import { ${componentName} } from '${pagesRelPath}/${componentName}';
762
+ `import * as PageModule from '${pagesRelPath}/${componentName}';
762
763
  `,
763
764
  ...errorBoundaryDef,
764
765
  `// Hydration with error handling and fallback`,
765
766
  `const isDev = ${isDev};`,
766
767
  `const componentPath = '${pagesRelPath}/${componentName}';
768
+ `,
769
+ `function resolvePageComponent(module, candidateNames) {`,
770
+ ` for (const name of candidateNames) {`,
771
+ ` const value = module[name];`,
772
+ ` if (typeof value === 'function' || (value && typeof value === 'object')) return value;`,
773
+ ` }`,
774
+ ` for (const [name, value] of Object.entries(module)) {`,
775
+ ` if (!/^[A-Z]/.test(name)) continue;`,
776
+ ` if (typeof value === 'function' || (value && typeof value === 'object')) return value;`,
777
+ ` }`,
778
+ ` throw new Error('React page module ' + componentPath + ' does not export a component. Expected default, ${pascalComponentName}, ${componentName}, or any PascalCase export.');`,
779
+ `}`,
780
+ `const PageComponent = resolvePageComponent(PageModule, ['default', '${pascalComponentName}', '${componentName}']);
767
781
  `,
768
782
  `function isHydrationError(error) {`,
769
783
  ` if (!error) return false;`,
@@ -835,7 +849,7 @@ var indexContentCache, resolveDevClientDir = () => {
835
849
  `,
836
850
  ` // Render into the same root container when falling back to client-only`,
837
851
  ` const root = createRoot(container);`,
838
- ` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(${componentName}, mergedProps))` : `createElement(${componentName}, mergedProps)`});`,
852
+ ` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,
839
853
  ` window.__REACT_ROOT__ = root;`,
840
854
  ` window.__HMR_CLIENT_ONLY_MODE__ = true;`,
841
855
  ` } catch (fallbackError) {`,
@@ -880,14 +894,14 @@ var indexContentCache, resolveDevClientDir = () => {
880
894
  ` // After HMR, SSR is skipped to avoid stale content flash \u2014 render client-only`,
881
895
  ` if (window.__SSR_DIRTY__) {`,
882
896
  ` root = createRoot(container);`,
883
- ` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(${componentName}, mergedProps))` : `createElement(${componentName}, mergedProps)`});`,
897
+ ` root.render(${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`});`,
884
898
  ` window.__REACT_ROOT__ = root;`,
885
899
  ` } else {`,
886
900
  ` try {`,
887
901
  ` // Use onRecoverableError to catch hydration errors (React 19)`,
888
902
  ` root = hydrateRoot(`,
889
903
  ` container,`,
890
- ` ${isDev ? `createElement(ErrorBoundary, null, createElement(${componentName}, mergedProps))` : `createElement(${componentName}, mergedProps)`},`,
904
+ ` ${isDev ? `createElement(ErrorBoundary, null, createElement(PageComponent, mergedProps))` : `createElement(PageComponent, mergedProps)`},`,
891
905
  ` {`,
892
906
  ` onRecoverableError: (error) => {`,
893
907
  ` // Check if this is a hydration error (isHydrationError filters out whitespace-only head mismatches)`,
@@ -2588,11 +2602,14 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
2588
2602
  var exports_stylePreprocessor = {};
2589
2603
  __export(exports_stylePreprocessor, {
2590
2604
  stylePreprocessorPlugin: () => stylePreprocessorPlugin,
2605
+ recordStyleOutput: () => recordStyleOutput,
2591
2606
  isStylePath: () => isStylePath,
2592
2607
  isStyleModulePath: () => isStyleModulePath,
2593
2608
  isPreprocessableStylePath: () => isPreprocessableStylePath,
2594
2609
  getStyleBaseName: () => getStyleBaseName,
2595
2610
  getCssOutputExtension: () => getCssOutputExtension,
2611
+ forgetStyleEntry: () => forgetStyleEntry,
2612
+ findStyleEntriesImporting: () => findStyleEntriesImporting,
2596
2613
  createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
2597
2614
  createStyleTransformConfig: () => createStyleTransformConfig,
2598
2615
  createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
@@ -2600,10 +2617,18 @@ __export(exports_stylePreprocessor, {
2600
2617
  compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
2601
2618
  compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
2602
2619
  });
2620
+ import { createHash } from "crypto";
2603
2621
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
2604
2622
  import { readFile } from "fs/promises";
2605
2623
  import { createRequire } from "module";
2606
- import { dirname as dirname3, extname as extname3, isAbsolute, join as join6, relative as relative3, resolve as resolve5 } from "path";
2624
+ import {
2625
+ dirname as dirname3,
2626
+ extname as extname3,
2627
+ isAbsolute,
2628
+ join as join6,
2629
+ relative as relative3,
2630
+ resolve as resolve5
2631
+ } from "path";
2607
2632
  import { fileURLToPath } from "url";
2608
2633
  var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
2609
2634
  const normalized = filePathOrLanguage.toLowerCase();
@@ -2616,7 +2641,22 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
2616
2641
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
2617
2642
  return "stylus";
2618
2643
  return null;
2619
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
2644
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), throwPreprocessorError = (error, filePath, language) => {
2645
+ if (!(error instanceof Error)) {
2646
+ throw new Error(`${language} compile failed in ${filePath}: ${String(error)}`);
2647
+ }
2648
+ const detail = error;
2649
+ const sassLine = detail.span?.start?.line;
2650
+ const sassCol = detail.span?.start?.column;
2651
+ const line = detail.line ?? sassLine;
2652
+ const column = detail.column ?? sassCol;
2653
+ const location = typeof line === "number" ? `:${line}${typeof column === "number" ? `:${column}` : ""}` : "";
2654
+ const message = detail.formatted ?? detail.message;
2655
+ const wrapped = new Error(`${language} compile failed in ${filePath}${location}
2656
+ ${message}`);
2657
+ wrapped.cause = error;
2658
+ throw wrapped;
2659
+ }, requireOptionalPeerSync = (specifier) => {
2620
2660
  try {
2621
2661
  return requireFromCwd(specifier);
2622
2662
  } catch {
@@ -2655,7 +2695,10 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
2655
2695
  }, getAliasEntries = (config) => {
2656
2696
  const tsconfig = readTsconfigAliases();
2657
2697
  return {
2658
- aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
2698
+ aliases: [
2699
+ ...normalizeAliasEntries(config?.aliases),
2700
+ ...tsconfig.aliases
2701
+ ],
2659
2702
  baseUrl: tsconfig.baseUrl
2660
2703
  };
2661
2704
  }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
@@ -2816,7 +2859,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2816
2859
  ...postcssConfig.options
2817
2860
  });
2818
2861
  return result.css;
2819
- }, createSassImporter = (entryFile, loadPaths, language, config) => ({
2862
+ }, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
2820
2863
  canonicalize(specifier, options) {
2821
2864
  const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
2822
2865
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -2824,6 +2867,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2824
2867
  },
2825
2868
  load(canonicalUrl) {
2826
2869
  const filePath = fileURLToPath(canonicalUrl);
2870
+ deps?.add(filePath);
2827
2871
  const fileLanguage = getStyleLanguage(filePath);
2828
2872
  if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
2829
2873
  return null;
@@ -2832,7 +2876,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2832
2876
  syntax: filePath.endsWith(".sass") ? "indented" : "scss"
2833
2877
  };
2834
2878
  }
2835
- }), createLessFileManager = (entryFile, loadPaths, config) => ({
2879
+ }), createLessFileManager = (entryFile, loadPaths, config, deps) => ({
2836
2880
  install(less, pluginManager) {
2837
2881
  const baseManager = new less.FileManager;
2838
2882
  const manager = Object.create(baseManager);
@@ -2842,6 +2886,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2842
2886
  if (!resolved) {
2843
2887
  throw new Error(`Unable to resolve Less import "${filename}"`);
2844
2888
  }
2889
+ deps?.add(resolved);
2845
2890
  return {
2846
2891
  contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
2847
2892
  filename: resolved
@@ -2849,7 +2894,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2849
2894
  };
2850
2895
  pluginManager.addFileManager(manager);
2851
2896
  }
2852
- }), renderStylus = async (contents, filePath, loadPaths, options) => {
2897
+ }), renderStylus = async (contents, filePath, loadPaths, options, deps) => {
2853
2898
  let stylus;
2854
2899
  try {
2855
2900
  const stylusModule = await importOptionalPeer("stylus");
@@ -2866,15 +2911,51 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2866
2911
  for (const path of loadPaths)
2867
2912
  renderer.include(path);
2868
2913
  renderer.render((error, css) => {
2869
- if (error)
2914
+ if (error) {
2870
2915
  reject(error);
2871
- else
2872
- resolveCss(css ?? "");
2916
+ return;
2917
+ }
2918
+ if (deps) {
2919
+ const stylusDeps = renderer.deps?.();
2920
+ if (Array.isArray(stylusDeps)) {
2921
+ for (const dep of stylusDeps)
2922
+ deps.add(resolve5(dep));
2923
+ }
2924
+ }
2925
+ resolveCss(css ?? "");
2873
2926
  });
2874
2927
  });
2928
+ }, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
2929
+ const key = resolve5(entry);
2930
+ const stripped = new Set;
2931
+ for (const dep of deps) {
2932
+ const resolved = resolve5(dep);
2933
+ if (resolved !== key)
2934
+ stripped.add(resolved);
2935
+ }
2936
+ styleDependencyGraph.set(key, stripped);
2937
+ }, findStyleEntriesImporting = (changedPath) => {
2938
+ const target = resolve5(changedPath);
2939
+ const importers = [];
2940
+ for (const [entry, deps] of styleDependencyGraph) {
2941
+ if (deps.has(target))
2942
+ importers.push(entry);
2943
+ }
2944
+ return importers;
2945
+ }, recordStyleOutput = (entry, css) => {
2946
+ const key = resolve5(entry);
2947
+ const hash = createHash("sha1").update(css).digest("hex");
2948
+ const previous = styleOutputHashes.get(key);
2949
+ styleOutputHashes.set(key, hash);
2950
+ return previous !== hash;
2951
+ }, forgetStyleEntry = (entry) => {
2952
+ const key = resolve5(entry);
2953
+ styleDependencyGraph.delete(key);
2954
+ styleOutputHashes.delete(key);
2875
2955
  }, compileStyleSource = async (filePath, source, languageHint, config) => {
2876
2956
  const language = getStyleLanguage(languageHint ?? filePath);
2877
2957
  const rawContents = source ?? await readFile(filePath, "utf-8");
2958
+ const deps = new Set;
2878
2959
  if (language === "scss" || language === "sass") {
2879
2960
  const options = getSassOptions(config, language);
2880
2961
  const packageName = options.implementation ?? "sass";
@@ -2886,16 +2967,22 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2886
2967
  }
2887
2968
  const contents = withAdditionalData(rawContents, options.additionalData);
2888
2969
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2889
- const result = sass.compileString(contents, {
2890
- importers: [
2891
- createSassImporter(filePath, loadPaths, language, config)
2892
- ],
2893
- loadPaths,
2894
- style: "expanded",
2895
- syntax: language === "sass" ? "indented" : "scss",
2896
- url: new URL(`file://${filePath}`)
2897
- });
2898
- return runPostcss(result.css, filePath, config);
2970
+ try {
2971
+ const result = sass.compileString(contents, {
2972
+ importers: [
2973
+ createSassImporter(filePath, loadPaths, language, config, deps)
2974
+ ],
2975
+ loadPaths,
2976
+ style: "expanded",
2977
+ syntax: language === "sass" ? "indented" : "scss",
2978
+ url: new URL(`file://${filePath}`)
2979
+ });
2980
+ const css = await runPostcss(result.css, filePath, config);
2981
+ recordStyleDeps(filePath, deps);
2982
+ return css;
2983
+ } catch (error) {
2984
+ throwPreprocessorError(error, filePath, language);
2985
+ }
2899
2986
  }
2900
2987
  if (language === "less") {
2901
2988
  const options = getLessOptions(config);
@@ -2911,22 +2998,34 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2911
2998
  throw missingDependencyError("less", filePath);
2912
2999
  const contents = withAdditionalData(rawContents, options.additionalData);
2913
3000
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2914
- const result = await render(contents, {
2915
- ...options.options ?? {},
2916
- filename: filePath,
2917
- paths: loadPaths,
2918
- plugins: [
2919
- ...options.options?.plugins ?? [],
2920
- createLessFileManager(filePath, loadPaths, config)
2921
- ]
2922
- });
2923
- return runPostcss(result.css, filePath, config);
3001
+ try {
3002
+ const result = await render(contents, {
3003
+ ...options.options ?? {},
3004
+ filename: filePath,
3005
+ paths: loadPaths,
3006
+ plugins: [
3007
+ ...options.options?.plugins ?? [],
3008
+ createLessFileManager(filePath, loadPaths, config, deps)
3009
+ ]
3010
+ });
3011
+ const css = await runPostcss(result.css, filePath, config);
3012
+ recordStyleDeps(filePath, deps);
3013
+ return css;
3014
+ } catch (error) {
3015
+ throwPreprocessorError(error, filePath, "less");
3016
+ }
2924
3017
  }
2925
3018
  if (language === "stylus") {
2926
3019
  const options = getStylusOptions(config);
2927
3020
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
2928
3021
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
2929
- return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
3022
+ try {
3023
+ const css = await runPostcss(await renderStylus(contents, filePath, loadPaths, options, deps), filePath, config);
3024
+ recordStyleDeps(filePath, deps);
3025
+ return css;
3026
+ } catch (error) {
3027
+ throwPreprocessorError(error, filePath, "stylus");
3028
+ }
2930
3029
  }
2931
3030
  return runPostcss(rawContents, filePath, config);
2932
3031
  }, createStylePreprocessorPlugin = (config) => ({
@@ -3031,6 +3130,8 @@ var init_stylePreprocessor = __esm(() => {
3031
3130
  importOptionalPeer = new Function("specifier", "return import(specifier)");
3032
3131
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
3033
3132
  requireFromCwd = createRequire(join6(process.cwd(), "package.json"));
3133
+ styleDependencyGraph = new Map;
3134
+ styleOutputHashes = new Map;
3034
3135
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
3035
3136
  });
3036
3137
 
@@ -8582,7 +8683,7 @@ __export(exports_tailwindCompiler, {
8582
8683
  extractCandidates: () => extractCandidates,
8583
8684
  disposeTailwindCompiler: () => disposeTailwindCompiler
8584
8685
  });
8585
- import { createHash } from "crypto";
8686
+ import { createHash as createHash2 } from "crypto";
8586
8687
  import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
8587
8688
  import { readFile as readFile2, stat } from "fs/promises";
8588
8689
  import { dirname as dirname5, isAbsolute as isAbsolute2, resolve as resolve7 } from "path";
@@ -8674,7 +8775,7 @@ var compilerCache, cachedTailwindCompile = null, loadTailwindCompile = async ()
8674
8775
  out.add(match[0]);
8675
8776
  }
8676
8777
  return out;
8677
- }, hashCss = (css) => createHash("sha1").update(css).digest("hex"), fileMatchesSources = (file, sources) => {
8778
+ }, hashCss = (css) => createHash2("sha1").update(css).digest("hex"), fileMatchesSources = (file, sources) => {
8678
8779
  if (sources.length === 0)
8679
8780
  return true;
8680
8781
  const absFile = resolve7(file);
@@ -9390,7 +9491,7 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
9390
9491
  // src/build/angularLinkerPlugin.ts
9391
9492
  import { existsSync as existsSync14, mkdirSync as mkdirSync5, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "fs";
9392
9493
  import { dirname as dirname8, join as join12, relative as relative5, resolve as resolve11 } from "path";
9393
- import { createHash as createHash2 } from "crypto";
9494
+ import { createHash as createHash3 } from "crypto";
9394
9495
  var CACHE_ROOT, createAngularLinkerPlugin = (linkerJitMode) => ({
9395
9496
  name: "angular-linker",
9396
9497
  setup(bld) {
@@ -9409,7 +9510,7 @@ var CACHE_ROOT, createAngularLinkerPlugin = (linkerJitMode) => ({
9409
9510
  if (!checkLink || !checkLink(args.path, source)) {
9410
9511
  return;
9411
9512
  }
9412
- const hash = createHash2("md5").update(source).digest("hex");
9513
+ const hash = createHash3("md5").update(source).digest("hex");
9413
9514
  const cachePath = join12(cacheDir, `${hash}.js`);
9414
9515
  if (existsSync14(cachePath)) {
9415
9516
  return {
@@ -15961,6 +16062,21 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
15961
16062
  await waitRound(round + 1);
15962
16063
  };
15963
16064
  await waitRound(0);
16065
+ }, enqueueImporter = (state, importer) => {
16066
+ const importerFramework = detectFramework(importer, state.resolvedPaths);
16067
+ if (importerFramework === "ignored")
16068
+ return;
16069
+ if (!state.fileChangeQueue.has(importerFramework)) {
16070
+ state.fileChangeQueue.set(importerFramework, []);
16071
+ }
16072
+ const importerQueue = state.fileChangeQueue.get(importerFramework);
16073
+ if (importerQueue && !importerQueue.includes(importer)) {
16074
+ importerQueue.push(importer);
16075
+ }
16076
+ }, enqueueStyleImporters = (state, changedStylePath) => {
16077
+ for (const importer of findStyleEntriesImporting(changedStylePath)) {
16078
+ enqueueImporter(state, importer);
16079
+ }
15964
16080
  }, queueFileChange = async (state, filePath, config, onRebuildComplete) => {
15965
16081
  const framework = detectFramework(filePath, state.resolvedPaths);
15966
16082
  if (framework === "ignored") {
@@ -15983,6 +16099,9 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, runSequent
15983
16099
  if (queue && !queue.includes(filePath)) {
15984
16100
  queue.push(filePath);
15985
16101
  }
16102
+ if (isStylePath(filePath)) {
16103
+ enqueueStyleImporters(state, filePath);
16104
+ }
15986
16105
  if (state.isRebuilding) {
15987
16106
  return;
15988
16107
  }
@@ -17906,5 +18025,5 @@ export {
17906
18025
  build
17907
18026
  };
17908
18027
 
17909
- //# debugId=3AAA82D7EC0F5B9564756E2164756E21
18028
+ //# debugId=CE8C325B0B1EAD2564756E2164756E21
17910
18029
  //# sourceMappingURL=build.js.map