@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.
@@ -857,10 +857,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
857
857
  });
858
858
 
859
859
  // src/build/stylePreprocessor.ts
860
+ var exports_stylePreprocessor = {};
861
+ __export(exports_stylePreprocessor, {
862
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
863
+ isStylePath: () => isStylePath,
864
+ isStyleModulePath: () => isStyleModulePath,
865
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
866
+ getStyleBaseName: () => getStyleBaseName,
867
+ getCssOutputExtension: () => getCssOutputExtension,
868
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
869
+ createStyleTransformConfig: () => createStyleTransformConfig,
870
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
871
+ compileStyleSource: () => compileStyleSource,
872
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
873
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
874
+ });
875
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
860
876
  import { readFile } from "fs/promises";
861
877
  import { createRequire } from "module";
862
- import { dirname as dirname2, extname, join as join3, resolve as resolve4 } from "path";
863
- 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) => {
878
+ import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
879
+ import { fileURLToPath } from "url";
880
+ 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) => {
864
881
  const normalized = filePathOrLanguage.toLowerCase();
865
882
  if (normalized === "scss" || normalized.endsWith(".scss"))
866
883
  return "scss";
@@ -868,16 +885,266 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
868
885
  return "sass";
869
886
  if (normalized === "less" || normalized.endsWith(".less"))
870
887
  return "less";
888
+ if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
889
+ return "stylus";
871
890
  return null;
872
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
891
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
892
+ try {
893
+ return requireFromCwd(specifier);
894
+ } catch {
895
+ return requireOptionalPeer(specifier);
896
+ }
897
+ }, normalizeLoadPaths = (filePath, paths = []) => [
873
898
  dirname2(filePath),
874
899
  process.cwd(),
875
900
  ...paths.map((path) => resolve4(process.cwd(), path))
876
- ], getSassOptions = (config, language) => ({
901
+ ], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
902
+ pattern,
903
+ replacements: Array.isArray(value) ? value : [value]
904
+ })), readTsconfigAliases = () => {
905
+ const cwd = process.cwd();
906
+ if (tsconfigAliasCache?.cwd === cwd)
907
+ return tsconfigAliasCache;
908
+ const tsconfigPath = resolve4(cwd, "tsconfig.json");
909
+ const empty = { aliases: [], baseUrl: cwd, cwd };
910
+ if (!existsSync4(tsconfigPath)) {
911
+ tsconfigAliasCache = empty;
912
+ return empty;
913
+ }
914
+ try {
915
+ const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
916
+ const compilerOptions = parsed.compilerOptions ?? {};
917
+ const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
918
+ tsconfigAliasCache = {
919
+ aliases: normalizeAliasEntries(compilerOptions.paths),
920
+ baseUrl,
921
+ cwd
922
+ };
923
+ } catch {
924
+ tsconfigAliasCache = empty;
925
+ }
926
+ return tsconfigAliasCache;
927
+ }, getAliasEntries = (config) => {
928
+ const tsconfig = readTsconfigAliases();
929
+ return {
930
+ aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
931
+ baseUrl: tsconfig.baseUrl
932
+ };
933
+ }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
934
+ const { aliases, baseUrl } = getAliasEntries(config);
935
+ const targets = [];
936
+ for (const alias of aliases) {
937
+ const match = specifier.match(aliasPatternToRegExp(alias.pattern));
938
+ if (!match)
939
+ continue;
940
+ const wildcard = match[1] ?? "";
941
+ for (const replacement of alias.replacements) {
942
+ targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
943
+ }
944
+ }
945
+ return targets;
946
+ }, getLanguageExtensions = (language) => {
947
+ if (language === "less")
948
+ return [".less", ".css"];
949
+ if (language === "stylus")
950
+ return [".styl", ".stylus", ".css"];
951
+ return [".scss", ".sass", ".css"];
952
+ }, getCandidatePaths = (basePath, language) => {
953
+ const ext = extname(basePath);
954
+ const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
955
+ `${basePath}${extension}`,
956
+ join3(basePath, `index${extension}`)
957
+ ]);
958
+ if (language === "scss" || language === "sass") {
959
+ return paths.flatMap((path) => {
960
+ const dir = dirname2(path);
961
+ const base = path.slice(dir.length + 1);
962
+ return [path, join3(dir, `_${base}`)];
963
+ });
964
+ }
965
+ return paths;
966
+ }, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
967
+ const rawCandidates = [
968
+ ...resolveAliasTargets(specifier, config),
969
+ isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
970
+ ...loadPaths.map((path) => resolve4(path, specifier))
971
+ ];
972
+ for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
973
+ if (existsSync4(candidate))
974
+ return candidate;
975
+ }
976
+ return null;
977
+ }, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
978
+ const markerIndex = url.search(/[?#]/);
979
+ if (markerIndex === -1)
980
+ return { marker: "", path: url };
981
+ return {
982
+ marker: url.slice(markerIndex),
983
+ path: url.slice(0, markerIndex)
984
+ };
985
+ }, rebaseCssUrls = (contents, sourceFile, entryFile) => {
986
+ const sourceDir = dirname2(sourceFile);
987
+ const entryDir = dirname2(entryFile);
988
+ if (sourceDir === entryDir)
989
+ return contents;
990
+ return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
991
+ const trimmedUrl = rawUrl.trim();
992
+ if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
993
+ return match;
994
+ const { marker, path } = splitCssUrl(trimmedUrl);
995
+ const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
996
+ const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
997
+ const nextQuote = quote || '"';
998
+ return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
999
+ });
1000
+ }, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
1001
+ if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
1002
+ return match;
1003
+ const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
1004
+ return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
1005
+ }), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
1006
+ const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
1007
+ return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
1008
+ }, extractCssModuleExports = (css) => {
1009
+ const exports = {};
1010
+ const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
1011
+ for (const declaration of body.split(";")) {
1012
+ const separator = declaration.indexOf(":");
1013
+ if (separator === -1)
1014
+ continue;
1015
+ const key = declaration.slice(0, separator).trim();
1016
+ const value = declaration.slice(separator + 1).trim();
1017
+ if (key && value)
1018
+ exports[key] = value;
1019
+ }
1020
+ return "";
1021
+ });
1022
+ return { css: nextCss, exports };
1023
+ }, getSassOptions = (config, language) => ({
877
1024
  ...config?.sass ?? {},
878
1025
  ...language === "scss" ? config?.scss ?? {} : {}
879
- }), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
880
- ${contents}` : contents, compileStyleSource = async (filePath, source, languageHint, config) => {
1026
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
1027
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
1028
+ if (mod && typeof mod === "object" && "default" in mod) {
1029
+ return mod.default ?? mod;
1030
+ }
1031
+ return mod;
1032
+ }, loadPostcssConfigFile = async (configPath) => {
1033
+ const resolved = resolve4(process.cwd(), configPath);
1034
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
1035
+ const config = normalizePostcssModule(loaded);
1036
+ const value = typeof config === "function" ? await config({
1037
+ cwd: process.cwd(),
1038
+ env: "development"
1039
+ }) : config;
1040
+ return normalizePostcssModule(value) ?? {};
1041
+ }, normalizePostcssPlugins = (plugins) => {
1042
+ if (!plugins)
1043
+ return [];
1044
+ if (Array.isArray(plugins))
1045
+ return plugins.filter(Boolean);
1046
+ const resolved = [];
1047
+ for (const [specifier, options] of Object.entries(plugins)) {
1048
+ if (options === false)
1049
+ continue;
1050
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
1051
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
1052
+ if (plugin)
1053
+ resolved.push(plugin);
1054
+ }
1055
+ return resolved;
1056
+ }, resolvePostcssConfig = async (config) => {
1057
+ const inlineConfig = config?.postcss;
1058
+ if (!inlineConfig)
1059
+ return null;
1060
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
1061
+ const plugins = [
1062
+ ...normalizePostcssPlugins(fileConfig.plugins),
1063
+ ...normalizePostcssPlugins(inlineConfig.plugins)
1064
+ ];
1065
+ if (plugins.length === 0)
1066
+ return null;
1067
+ return {
1068
+ options: {
1069
+ ...fileConfig.options ?? {},
1070
+ ...inlineConfig.options ?? {}
1071
+ },
1072
+ plugins
1073
+ };
1074
+ }, runPostcss = async (css, filePath, config) => {
1075
+ const postcssConfig = await resolvePostcssConfig(config);
1076
+ if (!postcssConfig)
1077
+ return css;
1078
+ let postcssModule;
1079
+ try {
1080
+ postcssModule = await importOptionalPeer("postcss");
1081
+ } catch {
1082
+ throw missingDependencyError("postcss", filePath);
1083
+ }
1084
+ const postcss = postcssModule.default ?? postcssModule;
1085
+ const result = await postcss(postcssConfig.plugins).process(css, {
1086
+ from: filePath,
1087
+ map: false,
1088
+ ...postcssConfig.options
1089
+ });
1090
+ return result.css;
1091
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
1092
+ canonicalize(specifier, options) {
1093
+ const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
1094
+ const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
1095
+ return resolved ? new URL(`file://${resolved}`) : null;
1096
+ },
1097
+ load(canonicalUrl) {
1098
+ const filePath = fileURLToPath(canonicalUrl);
1099
+ const fileLanguage = getStyleLanguage(filePath);
1100
+ if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
1101
+ return null;
1102
+ return {
1103
+ contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
1104
+ syntax: filePath.endsWith(".sass") ? "indented" : "scss"
1105
+ };
1106
+ }
1107
+ }), createLessFileManager = (entryFile, loadPaths, config) => ({
1108
+ install(less, pluginManager) {
1109
+ const baseManager = new less.FileManager;
1110
+ const manager = Object.create(baseManager);
1111
+ manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
1112
+ manager.loadFile = async (filename, currentDirectory) => {
1113
+ const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
1114
+ if (!resolved) {
1115
+ throw new Error(`Unable to resolve Less import "${filename}"`);
1116
+ }
1117
+ return {
1118
+ contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
1119
+ filename: resolved
1120
+ };
1121
+ };
1122
+ pluginManager.addFileManager(manager);
1123
+ }
1124
+ }), renderStylus = async (contents, filePath, loadPaths, options) => {
1125
+ let stylus;
1126
+ try {
1127
+ const stylusModule = await importOptionalPeer("stylus");
1128
+ stylus = stylusModule.default ?? stylusModule;
1129
+ } catch {
1130
+ throw missingDependencyError("stylus", filePath);
1131
+ }
1132
+ return new Promise((resolveCss, reject) => {
1133
+ const renderer = stylus(contents);
1134
+ renderer.set("filename", filePath);
1135
+ for (const [key, value] of Object.entries(options.options ?? {})) {
1136
+ renderer.set(key, value);
1137
+ }
1138
+ for (const path of loadPaths)
1139
+ renderer.include(path);
1140
+ renderer.render((error, css) => {
1141
+ if (error)
1142
+ reject(error);
1143
+ else
1144
+ resolveCss(css ?? "");
1145
+ });
1146
+ });
1147
+ }, compileStyleSource = async (filePath, source, languageHint, config) => {
881
1148
  const language = getStyleLanguage(languageHint ?? filePath);
882
1149
  const rawContents = source ?? await readFile(filePath, "utf-8");
883
1150
  if (language === "scss" || language === "sass") {
@@ -890,13 +1157,17 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
890
1157
  throw missingDependencyError(packageName, filePath);
891
1158
  }
892
1159
  const contents = withAdditionalData(rawContents, options.additionalData);
1160
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
893
1161
  const result = sass.compileString(contents, {
894
- loadPaths: normalizeLoadPaths(filePath, options.loadPaths),
1162
+ importers: [
1163
+ createSassImporter(filePath, loadPaths, language, config)
1164
+ ],
1165
+ loadPaths,
895
1166
  style: "expanded",
896
1167
  syntax: language === "sass" ? "indented" : "scss",
897
1168
  url: new URL(`file://${filePath}`)
898
1169
  });
899
- return result.css;
1170
+ return runPostcss(result.css, filePath, config);
900
1171
  }
901
1172
  if (language === "less") {
902
1173
  const options = getLessOptions(config);
@@ -911,14 +1182,25 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
911
1182
  if (!render)
912
1183
  throw missingDependencyError("less", filePath);
913
1184
  const contents = withAdditionalData(rawContents, options.additionalData);
1185
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
914
1186
  const result = await render(contents, {
915
1187
  ...options.options ?? {},
916
1188
  filename: filePath,
917
- paths: normalizeLoadPaths(filePath, options.paths)
1189
+ paths: loadPaths,
1190
+ plugins: [
1191
+ ...options.options?.plugins ?? [],
1192
+ createLessFileManager(filePath, loadPaths, config)
1193
+ ]
918
1194
  });
919
- return result.css;
1195
+ return runPostcss(result.css, filePath, config);
920
1196
  }
921
- return rawContents;
1197
+ if (language === "stylus") {
1198
+ const options = getStylusOptions(config);
1199
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
1200
+ const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
1201
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
1202
+ }
1203
+ return runPostcss(rawContents, filePath, config);
922
1204
  }, createStylePreprocessorPlugin = (config) => ({
923
1205
  name: "absolute-style-preprocessor",
924
1206
  setup(build) {
@@ -928,21 +1210,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
928
1210
  path: path.slice("absolute-style-module:".length)
929
1211
  }));
930
1212
  build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
931
- const sourcePath = cssModuleSources.get(path);
932
- if (!sourcePath) {
1213
+ const source = cssModuleSources.get(path);
1214
+ if (!source) {
933
1215
  throw new Error(`Unable to resolve CSS module source for ${path}`);
934
1216
  }
935
1217
  return {
936
- contents: await compileStyleSource(sourcePath, undefined, undefined, config),
1218
+ contents: source.css,
937
1219
  loader: "css"
938
1220
  };
939
1221
  });
940
1222
  build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
941
1223
  if (isStyleModulePath(path)) {
942
1224
  const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
943
- cssModuleSources.set(cssModulePath, path);
1225
+ const compiled = await compileStyleSource(path, undefined, undefined, config);
1226
+ const { css, exports } = extractCssModuleExports(compiled);
1227
+ cssModuleSources.set(cssModulePath, { css, exports });
1228
+ 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}`)};`;
944
1229
  return {
945
- contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
1230
+ contents: exportSource,
946
1231
  loader: "js"
947
1232
  };
948
1233
  }
@@ -951,6 +1236,10 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
951
1236
  loader: "css"
952
1237
  };
953
1238
  });
1239
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
1240
+ contents: await compileStyleSource(path, undefined, undefined, config),
1241
+ loader: "css"
1242
+ }));
954
1243
  }
955
1244
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
956
1245
  style: async ({
@@ -968,14 +1257,49 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
968
1257
  }
969
1258
  }), compileStyleFileIfNeeded = async (filePath, config) => {
970
1259
  if (!isPreprocessableStylePath(filePath)) {
971
- return readFile(filePath, "utf-8");
1260
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
972
1261
  }
973
1262
  return compileStyleSource(filePath, undefined, undefined, config);
974
- };
1263
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
1264
+ const rawContents = readFileSync3(filePath, "utf-8");
1265
+ const language = getStyleLanguage(filePath);
1266
+ if (config?.postcss) {
1267
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
1268
+ }
1269
+ if (language === "scss" || language === "sass") {
1270
+ const options = getSassOptions(config, language);
1271
+ const packageName = options.implementation ?? "sass";
1272
+ let sass;
1273
+ try {
1274
+ sass = requireOptionalPeerSync(packageName);
1275
+ } catch {
1276
+ throw missingDependencyError(packageName, filePath);
1277
+ }
1278
+ const contents = withAdditionalData(rawContents, options.additionalData);
1279
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
1280
+ return sass.compileString(contents, {
1281
+ importers: [
1282
+ createSassImporter(filePath, loadPaths, language, config)
1283
+ ],
1284
+ loadPaths,
1285
+ style: "expanded",
1286
+ syntax: language === "sass" ? "indented" : "scss",
1287
+ url: new URL(`file://${filePath}`)
1288
+ }).css;
1289
+ }
1290
+ if (language === "less") {
1291
+ 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.`);
1292
+ }
1293
+ if (language === "stylus") {
1294
+ 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.`);
1295
+ }
1296
+ return rawContents;
1297
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
975
1298
  var init_stylePreprocessor = __esm(() => {
976
- STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
977
- STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
978
- STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
1299
+ CSS_EXTENSION_PATTERN = /\.css$/i;
1300
+ STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
1301
+ STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
1302
+ STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
979
1303
  importOptionalPeer = new Function("specifier", "return import(specifier)");
980
1304
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
981
1305
  requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
@@ -984,9 +1308,9 @@ var init_stylePreprocessor = __esm(() => {
984
1308
 
985
1309
  // src/core/svelteServerModule.ts
986
1310
  import { mkdir, readdir } from "fs/promises";
987
- import { basename, dirname as dirname3, extname as extname2, join as join4, relative, resolve as resolve5 } from "path";
1311
+ import { basename, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
988
1312
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
989
- const importPath = relative(dirname3(from), target).replace(/\\/g, "/");
1313
+ const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
990
1314
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
991
1315
  }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
992
1316
  for (const entry of entries) {
@@ -1050,7 +1374,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1050
1374
  const foundIndex = existResults.indexOf(true);
1051
1375
  return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
1052
1376
  }, getCachedModulePath = (sourcePath) => {
1053
- const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
1377
+ const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
1054
1378
  const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
1055
1379
  return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
1056
1380
  }, resolveSvelteImport = async (spec, from) => {
@@ -1425,5 +1749,5 @@ export {
1425
1749
  createIslandStore
1426
1750
  };
1427
1751
 
1428
- //# debugId=5850F97AA766FE9B64756E2164756E21
1752
+ //# debugId=26E37550F14CC1A964756E2164756E21
1429
1753
  //# sourceMappingURL=index.js.map