@absolutejs/absolute 0.19.0-beta.693 → 0.19.0-beta.695

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/vue/index.js CHANGED
@@ -2566,10 +2566,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
2566
2566
  });
2567
2567
 
2568
2568
  // src/build/stylePreprocessor.ts
2569
+ var exports_stylePreprocessor = {};
2570
+ __export(exports_stylePreprocessor, {
2571
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
2572
+ isStylePath: () => isStylePath,
2573
+ isStyleModulePath: () => isStyleModulePath,
2574
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
2575
+ getStyleBaseName: () => getStyleBaseName,
2576
+ getCssOutputExtension: () => getCssOutputExtension,
2577
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
2578
+ createStyleTransformConfig: () => createStyleTransformConfig,
2579
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
2580
+ compileStyleSource: () => compileStyleSource,
2581
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
2582
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
2583
+ });
2584
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
2569
2585
  import { readFile } from "fs/promises";
2570
2586
  import { createRequire } from "module";
2571
- import { dirname as dirname3, extname, join as join3, resolve as resolve4 } from "path";
2572
- var 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)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
2587
+ import { dirname as dirname3, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
2588
+ import { fileURLToPath } from "url";
2589
+ 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) => {
2573
2590
  const normalized = filePathOrLanguage.toLowerCase();
2574
2591
  if (normalized === "scss" || normalized.endsWith(".scss"))
2575
2592
  return "scss";
@@ -2577,16 +2594,266 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2577
2594
  return "sass";
2578
2595
  if (normalized === "less" || normalized.endsWith(".less"))
2579
2596
  return "less";
2597
+ if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
2598
+ return "stylus";
2580
2599
  return null;
2581
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
2600
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
2601
+ try {
2602
+ return requireFromCwd(specifier);
2603
+ } catch {
2604
+ return requireOptionalPeer(specifier);
2605
+ }
2606
+ }, normalizeLoadPaths = (filePath, paths = []) => [
2582
2607
  dirname3(filePath),
2583
2608
  process.cwd(),
2584
2609
  ...paths.map((path) => resolve4(process.cwd(), path))
2585
- ], getSassOptions = (config, language) => ({
2610
+ ], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
2611
+ pattern,
2612
+ replacements: Array.isArray(value) ? value : [value]
2613
+ })), readTsconfigAliases = () => {
2614
+ const cwd = process.cwd();
2615
+ if (tsconfigAliasCache?.cwd === cwd)
2616
+ return tsconfigAliasCache;
2617
+ const tsconfigPath = resolve4(cwd, "tsconfig.json");
2618
+ const empty = { aliases: [], baseUrl: cwd, cwd };
2619
+ if (!existsSync4(tsconfigPath)) {
2620
+ tsconfigAliasCache = empty;
2621
+ return empty;
2622
+ }
2623
+ try {
2624
+ const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
2625
+ const compilerOptions = parsed.compilerOptions ?? {};
2626
+ const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
2627
+ tsconfigAliasCache = {
2628
+ aliases: normalizeAliasEntries(compilerOptions.paths),
2629
+ baseUrl,
2630
+ cwd
2631
+ };
2632
+ } catch {
2633
+ tsconfigAliasCache = empty;
2634
+ }
2635
+ return tsconfigAliasCache;
2636
+ }, getAliasEntries = (config) => {
2637
+ const tsconfig = readTsconfigAliases();
2638
+ return {
2639
+ aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
2640
+ baseUrl: tsconfig.baseUrl
2641
+ };
2642
+ }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
2643
+ const { aliases, baseUrl } = getAliasEntries(config);
2644
+ const targets = [];
2645
+ for (const alias of aliases) {
2646
+ const match = specifier.match(aliasPatternToRegExp(alias.pattern));
2647
+ if (!match)
2648
+ continue;
2649
+ const wildcard = match[1] ?? "";
2650
+ for (const replacement of alias.replacements) {
2651
+ targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
2652
+ }
2653
+ }
2654
+ return targets;
2655
+ }, getLanguageExtensions = (language) => {
2656
+ if (language === "less")
2657
+ return [".less", ".css"];
2658
+ if (language === "stylus")
2659
+ return [".styl", ".stylus", ".css"];
2660
+ return [".scss", ".sass", ".css"];
2661
+ }, getCandidatePaths = (basePath, language) => {
2662
+ const ext = extname(basePath);
2663
+ const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
2664
+ `${basePath}${extension}`,
2665
+ join3(basePath, `index${extension}`)
2666
+ ]);
2667
+ if (language === "scss" || language === "sass") {
2668
+ return paths.flatMap((path) => {
2669
+ const dir = dirname3(path);
2670
+ const base = path.slice(dir.length + 1);
2671
+ return [path, join3(dir, `_${base}`)];
2672
+ });
2673
+ }
2674
+ return paths;
2675
+ }, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
2676
+ const rawCandidates = [
2677
+ ...resolveAliasTargets(specifier, config),
2678
+ isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
2679
+ ...loadPaths.map((path) => resolve4(path, specifier))
2680
+ ];
2681
+ for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
2682
+ if (existsSync4(candidate))
2683
+ return candidate;
2684
+ }
2685
+ return null;
2686
+ }, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
2687
+ const markerIndex = url.search(/[?#]/);
2688
+ if (markerIndex === -1)
2689
+ return { marker: "", path: url };
2690
+ return {
2691
+ marker: url.slice(markerIndex),
2692
+ path: url.slice(0, markerIndex)
2693
+ };
2694
+ }, rebaseCssUrls = (contents, sourceFile, entryFile) => {
2695
+ const sourceDir = dirname3(sourceFile);
2696
+ const entryDir = dirname3(entryFile);
2697
+ if (sourceDir === entryDir)
2698
+ return contents;
2699
+ return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
2700
+ const trimmedUrl = rawUrl.trim();
2701
+ if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
2702
+ return match;
2703
+ const { marker, path } = splitCssUrl(trimmedUrl);
2704
+ const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
2705
+ const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
2706
+ const nextQuote = quote || '"';
2707
+ return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
2708
+ });
2709
+ }, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
2710
+ if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
2711
+ return match;
2712
+ const resolved = resolveImportPath(specifier, dirname3(sourceFile), loadPaths, language, config);
2713
+ return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
2714
+ }), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
2715
+ const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
2716
+ return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
2717
+ }, extractCssModuleExports = (css) => {
2718
+ const exports = {};
2719
+ const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
2720
+ for (const declaration of body.split(";")) {
2721
+ const separator = declaration.indexOf(":");
2722
+ if (separator === -1)
2723
+ continue;
2724
+ const key = declaration.slice(0, separator).trim();
2725
+ const value = declaration.slice(separator + 1).trim();
2726
+ if (key && value)
2727
+ exports[key] = value;
2728
+ }
2729
+ return "";
2730
+ });
2731
+ return { css: nextCss, exports };
2732
+ }, getSassOptions = (config, language) => ({
2586
2733
  ...config?.sass ?? {},
2587
2734
  ...language === "scss" ? config?.scss ?? {} : {}
2588
- }), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2589
- ${contents}` : contents, compileStyleSource = async (filePath, source, languageHint, config) => {
2735
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2736
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
2737
+ if (mod && typeof mod === "object" && "default" in mod) {
2738
+ return mod.default ?? mod;
2739
+ }
2740
+ return mod;
2741
+ }, loadPostcssConfigFile = async (configPath) => {
2742
+ const resolved = resolve4(process.cwd(), configPath);
2743
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
2744
+ const config = normalizePostcssModule(loaded);
2745
+ const value = typeof config === "function" ? await config({
2746
+ cwd: process.cwd(),
2747
+ env: "development"
2748
+ }) : config;
2749
+ return normalizePostcssModule(value) ?? {};
2750
+ }, normalizePostcssPlugins = (plugins) => {
2751
+ if (!plugins)
2752
+ return [];
2753
+ if (Array.isArray(plugins))
2754
+ return plugins.filter(Boolean);
2755
+ const resolved = [];
2756
+ for (const [specifier, options] of Object.entries(plugins)) {
2757
+ if (options === false)
2758
+ continue;
2759
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
2760
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
2761
+ if (plugin)
2762
+ resolved.push(plugin);
2763
+ }
2764
+ return resolved;
2765
+ }, resolvePostcssConfig = async (config) => {
2766
+ const inlineConfig = config?.postcss;
2767
+ if (!inlineConfig)
2768
+ return null;
2769
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
2770
+ const plugins = [
2771
+ ...normalizePostcssPlugins(fileConfig.plugins),
2772
+ ...normalizePostcssPlugins(inlineConfig.plugins)
2773
+ ];
2774
+ if (plugins.length === 0)
2775
+ return null;
2776
+ return {
2777
+ options: {
2778
+ ...fileConfig.options ?? {},
2779
+ ...inlineConfig.options ?? {}
2780
+ },
2781
+ plugins
2782
+ };
2783
+ }, runPostcss = async (css, filePath, config) => {
2784
+ const postcssConfig = await resolvePostcssConfig(config);
2785
+ if (!postcssConfig)
2786
+ return css;
2787
+ let postcssModule;
2788
+ try {
2789
+ postcssModule = await importOptionalPeer("postcss");
2790
+ } catch {
2791
+ throw missingDependencyError("postcss", filePath);
2792
+ }
2793
+ const postcss = postcssModule.default ?? postcssModule;
2794
+ const result = await postcss(postcssConfig.plugins).process(css, {
2795
+ from: filePath,
2796
+ map: false,
2797
+ ...postcssConfig.options
2798
+ });
2799
+ return result.css;
2800
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
2801
+ canonicalize(specifier, options) {
2802
+ const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
2803
+ const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
2804
+ return resolved ? new URL(`file://${resolved}`) : null;
2805
+ },
2806
+ load(canonicalUrl) {
2807
+ const filePath = fileURLToPath(canonicalUrl);
2808
+ const fileLanguage = getStyleLanguage(filePath);
2809
+ if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
2810
+ return null;
2811
+ return {
2812
+ contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
2813
+ syntax: filePath.endsWith(".sass") ? "indented" : "scss"
2814
+ };
2815
+ }
2816
+ }), createLessFileManager = (entryFile, loadPaths, config) => ({
2817
+ install(less, pluginManager) {
2818
+ const baseManager = new less.FileManager;
2819
+ const manager = Object.create(baseManager);
2820
+ manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
2821
+ manager.loadFile = async (filename, currentDirectory) => {
2822
+ const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
2823
+ if (!resolved) {
2824
+ throw new Error(`Unable to resolve Less import "${filename}"`);
2825
+ }
2826
+ return {
2827
+ contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
2828
+ filename: resolved
2829
+ };
2830
+ };
2831
+ pluginManager.addFileManager(manager);
2832
+ }
2833
+ }), renderStylus = async (contents, filePath, loadPaths, options) => {
2834
+ let stylus;
2835
+ try {
2836
+ const stylusModule = await importOptionalPeer("stylus");
2837
+ stylus = stylusModule.default ?? stylusModule;
2838
+ } catch {
2839
+ throw missingDependencyError("stylus", filePath);
2840
+ }
2841
+ return new Promise((resolveCss, reject) => {
2842
+ const renderer = stylus(contents);
2843
+ renderer.set("filename", filePath);
2844
+ for (const [key, value] of Object.entries(options.options ?? {})) {
2845
+ renderer.set(key, value);
2846
+ }
2847
+ for (const path of loadPaths)
2848
+ renderer.include(path);
2849
+ renderer.render((error, css) => {
2850
+ if (error)
2851
+ reject(error);
2852
+ else
2853
+ resolveCss(css ?? "");
2854
+ });
2855
+ });
2856
+ }, compileStyleSource = async (filePath, source, languageHint, config) => {
2590
2857
  const language = getStyleLanguage(languageHint ?? filePath);
2591
2858
  const rawContents = source ?? await readFile(filePath, "utf-8");
2592
2859
  if (language === "scss" || language === "sass") {
@@ -2599,13 +2866,17 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
2599
2866
  throw missingDependencyError(packageName, filePath);
2600
2867
  }
2601
2868
  const contents = withAdditionalData(rawContents, options.additionalData);
2869
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2602
2870
  const result = sass.compileString(contents, {
2603
- loadPaths: normalizeLoadPaths(filePath, options.loadPaths),
2871
+ importers: [
2872
+ createSassImporter(filePath, loadPaths, language, config)
2873
+ ],
2874
+ loadPaths,
2604
2875
  style: "expanded",
2605
2876
  syntax: language === "sass" ? "indented" : "scss",
2606
2877
  url: new URL(`file://${filePath}`)
2607
2878
  });
2608
- return result.css;
2879
+ return runPostcss(result.css, filePath, config);
2609
2880
  }
2610
2881
  if (language === "less") {
2611
2882
  const options = getLessOptions(config);
@@ -2620,14 +2891,25 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
2620
2891
  if (!render)
2621
2892
  throw missingDependencyError("less", filePath);
2622
2893
  const contents = withAdditionalData(rawContents, options.additionalData);
2894
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
2623
2895
  const result = await render(contents, {
2624
2896
  ...options.options ?? {},
2625
2897
  filename: filePath,
2626
- paths: normalizeLoadPaths(filePath, options.paths)
2898
+ paths: loadPaths,
2899
+ plugins: [
2900
+ ...options.options?.plugins ?? [],
2901
+ createLessFileManager(filePath, loadPaths, config)
2902
+ ]
2627
2903
  });
2628
- return result.css;
2904
+ return runPostcss(result.css, filePath, config);
2629
2905
  }
2630
- return rawContents;
2906
+ if (language === "stylus") {
2907
+ const options = getStylusOptions(config);
2908
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
2909
+ const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
2910
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
2911
+ }
2912
+ return runPostcss(rawContents, filePath, config);
2631
2913
  }, createStylePreprocessorPlugin = (config) => ({
2632
2914
  name: "absolute-style-preprocessor",
2633
2915
  setup(build) {
@@ -2637,21 +2919,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
2637
2919
  path: path.slice("absolute-style-module:".length)
2638
2920
  }));
2639
2921
  build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
2640
- const sourcePath = cssModuleSources.get(path);
2641
- if (!sourcePath) {
2922
+ const source = cssModuleSources.get(path);
2923
+ if (!source) {
2642
2924
  throw new Error(`Unable to resolve CSS module source for ${path}`);
2643
2925
  }
2644
2926
  return {
2645
- contents: await compileStyleSource(sourcePath, undefined, undefined, config),
2927
+ contents: source.css,
2646
2928
  loader: "css"
2647
2929
  };
2648
2930
  });
2649
2931
  build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
2650
2932
  if (isStyleModulePath(path)) {
2651
2933
  const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
2652
- cssModuleSources.set(cssModulePath, path);
2934
+ const compiled = await compileStyleSource(path, undefined, undefined, config);
2935
+ const { css, exports } = extractCssModuleExports(compiled);
2936
+ cssModuleSources.set(cssModulePath, { css, exports });
2937
+ const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
2653
2938
  return {
2654
- contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
2939
+ contents: exportSource,
2655
2940
  loader: "js"
2656
2941
  };
2657
2942
  }
@@ -2660,6 +2945,10 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
2660
2945
  loader: "css"
2661
2946
  };
2662
2947
  });
2948
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
2949
+ contents: await compileStyleSource(path, undefined, undefined, config),
2950
+ loader: "css"
2951
+ }));
2663
2952
  }
2664
2953
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
2665
2954
  style: async ({
@@ -2677,14 +2966,49 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
2677
2966
  }
2678
2967
  }), compileStyleFileIfNeeded = async (filePath, config) => {
2679
2968
  if (!isPreprocessableStylePath(filePath)) {
2680
- return readFile(filePath, "utf-8");
2969
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
2681
2970
  }
2682
2971
  return compileStyleSource(filePath, undefined, undefined, config);
2683
- };
2972
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
2973
+ const rawContents = readFileSync3(filePath, "utf-8");
2974
+ const language = getStyleLanguage(filePath);
2975
+ if (config?.postcss) {
2976
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
2977
+ }
2978
+ if (language === "scss" || language === "sass") {
2979
+ const options = getSassOptions(config, language);
2980
+ const packageName = options.implementation ?? "sass";
2981
+ let sass;
2982
+ try {
2983
+ sass = requireOptionalPeerSync(packageName);
2984
+ } catch {
2985
+ throw missingDependencyError(packageName, filePath);
2986
+ }
2987
+ const contents = withAdditionalData(rawContents, options.additionalData);
2988
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2989
+ return sass.compileString(contents, {
2990
+ importers: [
2991
+ createSassImporter(filePath, loadPaths, language, config)
2992
+ ],
2993
+ loadPaths,
2994
+ style: "expanded",
2995
+ syntax: language === "sass" ? "indented" : "scss",
2996
+ url: new URL(`file://${filePath}`)
2997
+ }).css;
2998
+ }
2999
+ if (language === "less") {
3000
+ throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
3001
+ }
3002
+ if (language === "stylus") {
3003
+ throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
3004
+ }
3005
+ return rawContents;
3006
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
2684
3007
  var init_stylePreprocessor = __esm(() => {
2685
- STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
2686
- STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
2687
- STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
3008
+ CSS_EXTENSION_PATTERN = /\.css$/i;
3009
+ STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
3010
+ STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
3011
+ STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
2688
3012
  importOptionalPeer = new Function("specifier", "return import(specifier)");
2689
3013
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
2690
3014
  requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
@@ -2693,9 +3017,9 @@ var init_stylePreprocessor = __esm(() => {
2693
3017
 
2694
3018
  // src/core/svelteServerModule.ts
2695
3019
  import { mkdir, readdir as readdir2 } from "fs/promises";
2696
- import { basename as basename3, dirname as dirname4, extname as extname2, join as join4, relative, resolve as resolve5 } from "path";
3020
+ import { basename as basename3, dirname as dirname4, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
2697
3021
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
2698
- const importPath = relative(dirname4(from), target).replace(/\\/g, "/");
3022
+ const importPath = relative2(dirname4(from), target).replace(/\\/g, "/");
2699
3023
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
2700
3024
  }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
2701
3025
  for (const entry of entries) {
@@ -2759,7 +3083,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2759
3083
  const foundIndex = existResults.indexOf(true);
2760
3084
  return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
2761
3085
  }, getCachedModulePath = (sourcePath) => {
2762
- const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
3086
+ const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
2763
3087
  const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2764
3088
  return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
2765
3089
  }, resolveSvelteImport = async (spec, from) => {
@@ -3730,5 +4054,5 @@ export {
3730
4054
  Image_default as Image
3731
4055
  };
3732
4056
 
3733
- //# debugId=B302B91F64F4530864756E2164756E21
4057
+ //# debugId=A6AD6AAD03EBAC0964756E2164756E21
3734
4058
  //# sourceMappingURL=index.js.map