@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.
@@ -1352,10 +1352,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
1352
1352
  });
1353
1353
 
1354
1354
  // src/build/stylePreprocessor.ts
1355
+ var exports_stylePreprocessor = {};
1356
+ __export(exports_stylePreprocessor, {
1357
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
1358
+ isStylePath: () => isStylePath,
1359
+ isStyleModulePath: () => isStyleModulePath,
1360
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
1361
+ getStyleBaseName: () => getStyleBaseName,
1362
+ getCssOutputExtension: () => getCssOutputExtension,
1363
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
1364
+ createStyleTransformConfig: () => createStyleTransformConfig,
1365
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
1366
+ compileStyleSource: () => compileStyleSource,
1367
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
1368
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
1369
+ });
1370
+ import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
1355
1371
  import { readFile } from "fs/promises";
1356
1372
  import { createRequire } from "module";
1357
- import { dirname as dirname2, extname, join as join3, resolve as resolve4 } from "path";
1358
- 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) => {
1373
+ import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
1374
+ import { fileURLToPath } from "url";
1375
+ 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) => {
1359
1376
  const normalized = filePathOrLanguage.toLowerCase();
1360
1377
  if (normalized === "scss" || normalized.endsWith(".scss"))
1361
1378
  return "scss";
@@ -1363,16 +1380,266 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
1363
1380
  return "sass";
1364
1381
  if (normalized === "less" || normalized.endsWith(".less"))
1365
1382
  return "less";
1383
+ if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
1384
+ return "stylus";
1366
1385
  return null;
1367
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
1386
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
1387
+ try {
1388
+ return requireFromCwd(specifier);
1389
+ } catch {
1390
+ return requireOptionalPeer(specifier);
1391
+ }
1392
+ }, normalizeLoadPaths = (filePath, paths = []) => [
1368
1393
  dirname2(filePath),
1369
1394
  process.cwd(),
1370
1395
  ...paths.map((path) => resolve4(process.cwd(), path))
1371
- ], getSassOptions = (config, language) => ({
1396
+ ], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
1397
+ pattern,
1398
+ replacements: Array.isArray(value) ? value : [value]
1399
+ })), readTsconfigAliases = () => {
1400
+ const cwd = process.cwd();
1401
+ if (tsconfigAliasCache?.cwd === cwd)
1402
+ return tsconfigAliasCache;
1403
+ const tsconfigPath = resolve4(cwd, "tsconfig.json");
1404
+ const empty = { aliases: [], baseUrl: cwd, cwd };
1405
+ if (!existsSync4(tsconfigPath)) {
1406
+ tsconfigAliasCache = empty;
1407
+ return empty;
1408
+ }
1409
+ try {
1410
+ const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
1411
+ const compilerOptions = parsed.compilerOptions ?? {};
1412
+ const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
1413
+ tsconfigAliasCache = {
1414
+ aliases: normalizeAliasEntries(compilerOptions.paths),
1415
+ baseUrl,
1416
+ cwd
1417
+ };
1418
+ } catch {
1419
+ tsconfigAliasCache = empty;
1420
+ }
1421
+ return tsconfigAliasCache;
1422
+ }, getAliasEntries = (config) => {
1423
+ const tsconfig = readTsconfigAliases();
1424
+ return {
1425
+ aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
1426
+ baseUrl: tsconfig.baseUrl
1427
+ };
1428
+ }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
1429
+ const { aliases, baseUrl } = getAliasEntries(config);
1430
+ const targets = [];
1431
+ for (const alias of aliases) {
1432
+ const match = specifier.match(aliasPatternToRegExp(alias.pattern));
1433
+ if (!match)
1434
+ continue;
1435
+ const wildcard = match[1] ?? "";
1436
+ for (const replacement of alias.replacements) {
1437
+ targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
1438
+ }
1439
+ }
1440
+ return targets;
1441
+ }, getLanguageExtensions = (language) => {
1442
+ if (language === "less")
1443
+ return [".less", ".css"];
1444
+ if (language === "stylus")
1445
+ return [".styl", ".stylus", ".css"];
1446
+ return [".scss", ".sass", ".css"];
1447
+ }, getCandidatePaths = (basePath, language) => {
1448
+ const ext = extname(basePath);
1449
+ const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
1450
+ `${basePath}${extension}`,
1451
+ join3(basePath, `index${extension}`)
1452
+ ]);
1453
+ if (language === "scss" || language === "sass") {
1454
+ return paths.flatMap((path) => {
1455
+ const dir = dirname2(path);
1456
+ const base = path.slice(dir.length + 1);
1457
+ return [path, join3(dir, `_${base}`)];
1458
+ });
1459
+ }
1460
+ return paths;
1461
+ }, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
1462
+ const rawCandidates = [
1463
+ ...resolveAliasTargets(specifier, config),
1464
+ isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
1465
+ ...loadPaths.map((path) => resolve4(path, specifier))
1466
+ ];
1467
+ for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
1468
+ if (existsSync4(candidate))
1469
+ return candidate;
1470
+ }
1471
+ return null;
1472
+ }, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
1473
+ const markerIndex = url.search(/[?#]/);
1474
+ if (markerIndex === -1)
1475
+ return { marker: "", path: url };
1476
+ return {
1477
+ marker: url.slice(markerIndex),
1478
+ path: url.slice(0, markerIndex)
1479
+ };
1480
+ }, rebaseCssUrls = (contents, sourceFile, entryFile) => {
1481
+ const sourceDir = dirname2(sourceFile);
1482
+ const entryDir = dirname2(entryFile);
1483
+ if (sourceDir === entryDir)
1484
+ return contents;
1485
+ return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
1486
+ const trimmedUrl = rawUrl.trim();
1487
+ if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
1488
+ return match;
1489
+ const { marker, path } = splitCssUrl(trimmedUrl);
1490
+ const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
1491
+ const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
1492
+ const nextQuote = quote || '"';
1493
+ return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
1494
+ });
1495
+ }, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
1496
+ if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
1497
+ return match;
1498
+ const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
1499
+ return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
1500
+ }), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
1501
+ const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
1502
+ return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
1503
+ }, extractCssModuleExports = (css) => {
1504
+ const exports = {};
1505
+ const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
1506
+ for (const declaration of body.split(";")) {
1507
+ const separator = declaration.indexOf(":");
1508
+ if (separator === -1)
1509
+ continue;
1510
+ const key = declaration.slice(0, separator).trim();
1511
+ const value = declaration.slice(separator + 1).trim();
1512
+ if (key && value)
1513
+ exports[key] = value;
1514
+ }
1515
+ return "";
1516
+ });
1517
+ return { css: nextCss, exports };
1518
+ }, getSassOptions = (config, language) => ({
1372
1519
  ...config?.sass ?? {},
1373
1520
  ...language === "scss" ? config?.scss ?? {} : {}
1374
- }), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
1375
- ${contents}` : contents, compileStyleSource = async (filePath, source, languageHint, config) => {
1521
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
1522
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
1523
+ if (mod && typeof mod === "object" && "default" in mod) {
1524
+ return mod.default ?? mod;
1525
+ }
1526
+ return mod;
1527
+ }, loadPostcssConfigFile = async (configPath) => {
1528
+ const resolved = resolve4(process.cwd(), configPath);
1529
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
1530
+ const config = normalizePostcssModule(loaded);
1531
+ const value = typeof config === "function" ? await config({
1532
+ cwd: process.cwd(),
1533
+ env: "development"
1534
+ }) : config;
1535
+ return normalizePostcssModule(value) ?? {};
1536
+ }, normalizePostcssPlugins = (plugins) => {
1537
+ if (!plugins)
1538
+ return [];
1539
+ if (Array.isArray(plugins))
1540
+ return plugins.filter(Boolean);
1541
+ const resolved = [];
1542
+ for (const [specifier, options] of Object.entries(plugins)) {
1543
+ if (options === false)
1544
+ continue;
1545
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
1546
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
1547
+ if (plugin)
1548
+ resolved.push(plugin);
1549
+ }
1550
+ return resolved;
1551
+ }, resolvePostcssConfig = async (config) => {
1552
+ const inlineConfig = config?.postcss;
1553
+ if (!inlineConfig)
1554
+ return null;
1555
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
1556
+ const plugins = [
1557
+ ...normalizePostcssPlugins(fileConfig.plugins),
1558
+ ...normalizePostcssPlugins(inlineConfig.plugins)
1559
+ ];
1560
+ if (plugins.length === 0)
1561
+ return null;
1562
+ return {
1563
+ options: {
1564
+ ...fileConfig.options ?? {},
1565
+ ...inlineConfig.options ?? {}
1566
+ },
1567
+ plugins
1568
+ };
1569
+ }, runPostcss = async (css, filePath, config) => {
1570
+ const postcssConfig = await resolvePostcssConfig(config);
1571
+ if (!postcssConfig)
1572
+ return css;
1573
+ let postcssModule;
1574
+ try {
1575
+ postcssModule = await importOptionalPeer("postcss");
1576
+ } catch {
1577
+ throw missingDependencyError("postcss", filePath);
1578
+ }
1579
+ const postcss = postcssModule.default ?? postcssModule;
1580
+ const result = await postcss(postcssConfig.plugins).process(css, {
1581
+ from: filePath,
1582
+ map: false,
1583
+ ...postcssConfig.options
1584
+ });
1585
+ return result.css;
1586
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
1587
+ canonicalize(specifier, options) {
1588
+ const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
1589
+ const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
1590
+ return resolved ? new URL(`file://${resolved}`) : null;
1591
+ },
1592
+ load(canonicalUrl) {
1593
+ const filePath = fileURLToPath(canonicalUrl);
1594
+ const fileLanguage = getStyleLanguage(filePath);
1595
+ if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
1596
+ return null;
1597
+ return {
1598
+ contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
1599
+ syntax: filePath.endsWith(".sass") ? "indented" : "scss"
1600
+ };
1601
+ }
1602
+ }), createLessFileManager = (entryFile, loadPaths, config) => ({
1603
+ install(less, pluginManager) {
1604
+ const baseManager = new less.FileManager;
1605
+ const manager = Object.create(baseManager);
1606
+ manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
1607
+ manager.loadFile = async (filename, currentDirectory) => {
1608
+ const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
1609
+ if (!resolved) {
1610
+ throw new Error(`Unable to resolve Less import "${filename}"`);
1611
+ }
1612
+ return {
1613
+ contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
1614
+ filename: resolved
1615
+ };
1616
+ };
1617
+ pluginManager.addFileManager(manager);
1618
+ }
1619
+ }), renderStylus = async (contents, filePath, loadPaths, options) => {
1620
+ let stylus;
1621
+ try {
1622
+ const stylusModule = await importOptionalPeer("stylus");
1623
+ stylus = stylusModule.default ?? stylusModule;
1624
+ } catch {
1625
+ throw missingDependencyError("stylus", filePath);
1626
+ }
1627
+ return new Promise((resolveCss, reject) => {
1628
+ const renderer = stylus(contents);
1629
+ renderer.set("filename", filePath);
1630
+ for (const [key, value] of Object.entries(options.options ?? {})) {
1631
+ renderer.set(key, value);
1632
+ }
1633
+ for (const path of loadPaths)
1634
+ renderer.include(path);
1635
+ renderer.render((error, css) => {
1636
+ if (error)
1637
+ reject(error);
1638
+ else
1639
+ resolveCss(css ?? "");
1640
+ });
1641
+ });
1642
+ }, compileStyleSource = async (filePath, source, languageHint, config) => {
1376
1643
  const language = getStyleLanguage(languageHint ?? filePath);
1377
1644
  const rawContents = source ?? await readFile(filePath, "utf-8");
1378
1645
  if (language === "scss" || language === "sass") {
@@ -1385,13 +1652,17 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
1385
1652
  throw missingDependencyError(packageName, filePath);
1386
1653
  }
1387
1654
  const contents = withAdditionalData(rawContents, options.additionalData);
1655
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
1388
1656
  const result = sass.compileString(contents, {
1389
- loadPaths: normalizeLoadPaths(filePath, options.loadPaths),
1657
+ importers: [
1658
+ createSassImporter(filePath, loadPaths, language, config)
1659
+ ],
1660
+ loadPaths,
1390
1661
  style: "expanded",
1391
1662
  syntax: language === "sass" ? "indented" : "scss",
1392
1663
  url: new URL(`file://${filePath}`)
1393
1664
  });
1394
- return result.css;
1665
+ return runPostcss(result.css, filePath, config);
1395
1666
  }
1396
1667
  if (language === "less") {
1397
1668
  const options = getLessOptions(config);
@@ -1406,14 +1677,25 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
1406
1677
  if (!render)
1407
1678
  throw missingDependencyError("less", filePath);
1408
1679
  const contents = withAdditionalData(rawContents, options.additionalData);
1680
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
1409
1681
  const result = await render(contents, {
1410
1682
  ...options.options ?? {},
1411
1683
  filename: filePath,
1412
- paths: normalizeLoadPaths(filePath, options.paths)
1684
+ paths: loadPaths,
1685
+ plugins: [
1686
+ ...options.options?.plugins ?? [],
1687
+ createLessFileManager(filePath, loadPaths, config)
1688
+ ]
1413
1689
  });
1414
- return result.css;
1690
+ return runPostcss(result.css, filePath, config);
1415
1691
  }
1416
- return rawContents;
1692
+ if (language === "stylus") {
1693
+ const options = getStylusOptions(config);
1694
+ const loadPaths = normalizeLoadPaths(filePath, options.paths);
1695
+ const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
1696
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
1697
+ }
1698
+ return runPostcss(rawContents, filePath, config);
1417
1699
  }, createStylePreprocessorPlugin = (config) => ({
1418
1700
  name: "absolute-style-preprocessor",
1419
1701
  setup(build) {
@@ -1423,21 +1705,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
1423
1705
  path: path.slice("absolute-style-module:".length)
1424
1706
  }));
1425
1707
  build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
1426
- const sourcePath = cssModuleSources.get(path);
1427
- if (!sourcePath) {
1708
+ const source = cssModuleSources.get(path);
1709
+ if (!source) {
1428
1710
  throw new Error(`Unable to resolve CSS module source for ${path}`);
1429
1711
  }
1430
1712
  return {
1431
- contents: await compileStyleSource(sourcePath, undefined, undefined, config),
1713
+ contents: source.css,
1432
1714
  loader: "css"
1433
1715
  };
1434
1716
  });
1435
1717
  build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
1436
1718
  if (isStyleModulePath(path)) {
1437
1719
  const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
1438
- cssModuleSources.set(cssModulePath, path);
1720
+ const compiled = await compileStyleSource(path, undefined, undefined, config);
1721
+ const { css, exports } = extractCssModuleExports(compiled);
1722
+ cssModuleSources.set(cssModulePath, { css, exports });
1723
+ 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}`)};`;
1439
1724
  return {
1440
- contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
1725
+ contents: exportSource,
1441
1726
  loader: "js"
1442
1727
  };
1443
1728
  }
@@ -1446,6 +1731,10 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
1446
1731
  loader: "css"
1447
1732
  };
1448
1733
  });
1734
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
1735
+ contents: await compileStyleSource(path, undefined, undefined, config),
1736
+ loader: "css"
1737
+ }));
1449
1738
  }
1450
1739
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
1451
1740
  style: async ({
@@ -1463,14 +1752,49 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
1463
1752
  }
1464
1753
  }), compileStyleFileIfNeeded = async (filePath, config) => {
1465
1754
  if (!isPreprocessableStylePath(filePath)) {
1466
- return readFile(filePath, "utf-8");
1755
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
1467
1756
  }
1468
1757
  return compileStyleSource(filePath, undefined, undefined, config);
1469
- };
1758
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
1759
+ const rawContents = readFileSync3(filePath, "utf-8");
1760
+ const language = getStyleLanguage(filePath);
1761
+ if (config?.postcss) {
1762
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
1763
+ }
1764
+ if (language === "scss" || language === "sass") {
1765
+ const options = getSassOptions(config, language);
1766
+ const packageName = options.implementation ?? "sass";
1767
+ let sass;
1768
+ try {
1769
+ sass = requireOptionalPeerSync(packageName);
1770
+ } catch {
1771
+ throw missingDependencyError(packageName, filePath);
1772
+ }
1773
+ const contents = withAdditionalData(rawContents, options.additionalData);
1774
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
1775
+ return sass.compileString(contents, {
1776
+ importers: [
1777
+ createSassImporter(filePath, loadPaths, language, config)
1778
+ ],
1779
+ loadPaths,
1780
+ style: "expanded",
1781
+ syntax: language === "sass" ? "indented" : "scss",
1782
+ url: new URL(`file://${filePath}`)
1783
+ }).css;
1784
+ }
1785
+ if (language === "less") {
1786
+ 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.`);
1787
+ }
1788
+ if (language === "stylus") {
1789
+ 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.`);
1790
+ }
1791
+ return rawContents;
1792
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
1470
1793
  var init_stylePreprocessor = __esm(() => {
1471
- STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
1472
- STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
1473
- STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
1794
+ CSS_EXTENSION_PATTERN = /\.css$/i;
1795
+ STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
1796
+ STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
1797
+ STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
1474
1798
  importOptionalPeer = new Function("specifier", "return import(specifier)");
1475
1799
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
1476
1800
  requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
@@ -1479,9 +1803,9 @@ var init_stylePreprocessor = __esm(() => {
1479
1803
 
1480
1804
  // src/core/svelteServerModule.ts
1481
1805
  import { mkdir, readdir } from "fs/promises";
1482
- import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as resolve5 } from "path";
1806
+ import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
1483
1807
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
1484
- const importPath = relative(dirname3(from), target).replace(/\\/g, "/");
1808
+ const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
1485
1809
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
1486
1810
  }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
1487
1811
  for (const entry of entries) {
@@ -1545,7 +1869,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
1545
1869
  const foundIndex = existResults.indexOf(true);
1546
1870
  return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
1547
1871
  }, getCachedModulePath = (sourcePath) => {
1548
- const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
1872
+ const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
1549
1873
  const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
1550
1874
  return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
1551
1875
  }, resolveSvelteImport = async (spec, from) => {
@@ -2865,12 +3189,12 @@ var init_startupBanner = __esm(() => {
2865
3189
  // src/utils/logger.ts
2866
3190
  var colors2, frameworkColors, formatPath = (filePath) => {
2867
3191
  const cwd = process.cwd();
2868
- let relative2 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
2869
- relative2 = relative2.replace(/\\/g, "/");
2870
- if (!relative2.startsWith("/")) {
2871
- relative2 = `/${relative2}`;
3192
+ let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
3193
+ relative3 = relative3.replace(/\\/g, "/");
3194
+ if (!relative3.startsWith("/")) {
3195
+ relative3 = `/${relative3}`;
2872
3196
  }
2873
- return relative2;
3197
+ return relative3;
2874
3198
  }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
2875
3199
  const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
2876
3200
  const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
@@ -3532,13 +3856,13 @@ __export(exports_compileAngular, {
3532
3856
  compileAngularFile: () => compileAngularFile,
3533
3857
  compileAngular: () => compileAngular
3534
3858
  });
3535
- import { existsSync as existsSync4, readFileSync as readFileSync3, promises as fs } from "fs";
3536
- import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative2 } from "path";
3859
+ import { existsSync as existsSync5, readFileSync as readFileSync4, promises as fs } from "fs";
3860
+ import { join as join5, basename as basename3, sep, dirname as dirname4, resolve as resolve6, relative as relative3 } from "path";
3537
3861
  import ts from "typescript";
3538
3862
  import { createHash } from "crypto";
3539
3863
  var computeConfigHash = () => {
3540
3864
  try {
3541
- const content = readFileSync3("./tsconfig.json", "utf-8");
3865
+ const content = readFileSync4("./tsconfig.json", "utf-8");
3542
3866
  return createHash("md5").update(content).digest("hex");
3543
3867
  } catch {
3544
3868
  return "";
@@ -3546,11 +3870,11 @@ var computeConfigHash = () => {
3546
3870
  }, resolveDevClientDir = () => {
3547
3871
  const projectRoot = process.cwd();
3548
3872
  const fromSource = resolve6(import.meta.dir, "../dev/client");
3549
- if (existsSync4(fromSource) && fromSource.startsWith(projectRoot)) {
3873
+ if (existsSync5(fromSource) && fromSource.startsWith(projectRoot)) {
3550
3874
  return fromSource;
3551
3875
  }
3552
3876
  const fromNodeModules = resolve6(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
3553
- if (existsSync4(fromNodeModules))
3877
+ if (existsSync5(fromNodeModules))
3554
3878
  return fromNodeModules;
3555
3879
  return resolve6(import.meta.dir, "./dev/client");
3556
3880
  }, devClientDir, hmrClientPath, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
@@ -3629,7 +3953,7 @@ ${registrations}
3629
3953
  join5(basePath, "index.mts"),
3630
3954
  join5(basePath, "index.cts")
3631
3955
  ];
3632
- return candidates.map((candidate) => resolve6(candidate)).find((candidate) => existsSync4(candidate) && !candidate.endsWith(".d.ts")) ?? null;
3956
+ return candidates.map((candidate) => resolve6(candidate)).find((candidate) => existsSync5(candidate) && !candidate.endsWith(".d.ts")) ?? null;
3633
3957
  }, readFileForAotTransform = async (fileName, readFile2) => {
3634
3958
  const hostSource = readFile2?.(fileName);
3635
3959
  if (typeof hostSource === "string")
@@ -3643,7 +3967,7 @@ ${registrations}
3643
3967
  if (visited.has(resolvedPath))
3644
3968
  return;
3645
3969
  visited.add(resolvedPath);
3646
- if (!existsSync4(resolvedPath) || resolvedPath.endsWith(".d.ts"))
3970
+ if (!existsSync5(resolvedPath) || resolvedPath.endsWith(".d.ts"))
3647
3971
  return;
3648
3972
  const source = await readFileForAotTransform(resolvedPath, readFile2);
3649
3973
  const transformed = await inlineResources(source, dirname4(resolvedPath), stylePreprocessors);
@@ -3658,7 +3982,7 @@ ${registrations}
3658
3982
  await transformFile(inputPath);
3659
3983
  return transformedSources;
3660
3984
  }, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
3661
- const islandMetadataExports = buildIslandMetadataExports(readFileSync3(inputPath, "utf-8"));
3985
+ const islandMetadataExports = buildIslandMetadataExports(readFileSync4(inputPath, "utf-8"));
3662
3986
  const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
3663
3987
  const configHash = computeConfigHash();
3664
3988
  const cached = globalThis.__angularCompilerCache;
@@ -3780,7 +4104,7 @@ ${registrations}
3780
4104
  return entries.map(({ target }) => target);
3781
4105
  }, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), resolveAngularDeferImportSpecifier = () => {
3782
4106
  const sourceEntry = resolve6(import.meta.dir, "../angular/components/index.ts");
3783
- if (existsSync4(sourceEntry)) {
4107
+ if (existsSync5(sourceEntry)) {
3784
4108
  return sourceEntry.replace(/\\/g, "/");
3785
4109
  }
3786
4110
  return "@absolutejs/absolute/angular/components";
@@ -3908,7 +4232,7 @@ ${slot.resolvedBindings.map((binding) => ` "${binding.key}": this.__absoluteDef
3908
4232
  ${fields}
3909
4233
  `);
3910
4234
  }, readAndEscapeFile = async (filePath, stylePreprocessors) => {
3911
- if (!existsSync4(filePath))
4235
+ if (!existsSync5(filePath))
3912
4236
  return null;
3913
4237
  const content = await compileStyleFileIfNeeded(filePath, stylePreprocessors);
3914
4238
  return escapeTemplateContent(content);
@@ -3916,7 +4240,7 @@ ${fields}
3916
4240
  const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
3917
4241
  if (templateUrlMatch?.[1]) {
3918
4242
  const templatePath = join5(fileDir, templateUrlMatch[1]);
3919
- if (!existsSync4(templatePath)) {
4243
+ if (!existsSync5(templatePath)) {
3920
4244
  return { deferSlots: [], source };
3921
4245
  }
3922
4246
  const templateRaw2 = await fs.readFile(templatePath, "utf-8");
@@ -3947,10 +4271,10 @@ ${fields}
3947
4271
  const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
3948
4272
  if (templateUrlMatch?.[1]) {
3949
4273
  const templatePath = join5(fileDir, templateUrlMatch[1]);
3950
- if (!existsSync4(templatePath)) {
4274
+ if (!existsSync5(templatePath)) {
3951
4275
  return { deferSlots: [], source };
3952
4276
  }
3953
- const templateRaw2 = readFileSync3(templatePath, "utf-8");
4277
+ const templateRaw2 = readFileSync4(templatePath, "utf-8");
3954
4278
  const lowered2 = lowerAngularDeferSyntax(templateRaw2);
3955
4279
  const escaped2 = escapeTemplateContent(lowered2.template);
3956
4280
  const replacedSource2 = source.replace(/templateUrl\s*:\s*['"][^'"]+['"]/, `template: \`${escaped2}\``);
@@ -4061,7 +4385,7 @@ ${fields}
4061
4385
  let actualPath = resolved;
4062
4386
  if (!actualPath.endsWith(".ts"))
4063
4387
  actualPath += ".ts";
4064
- if (!existsSync4(actualPath))
4388
+ if (!existsSync5(actualPath))
4065
4389
  return;
4066
4390
  let sourceCode = await fs.readFile(actualPath, "utf-8");
4067
4391
  const inlined = await inlineResources(sourceCode, dirname4(actualPath), stylePreprocessors);
@@ -4085,7 +4409,7 @@ ${fields}
4085
4409
  }
4086
4410
  const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
4087
4411
  const cacheKey = actualPath;
4088
- if (jitContentCache.get(cacheKey) === contentHash && existsSync4(targetPath)) {
4412
+ if (jitContentCache.get(cacheKey) === contentHash && existsSync5(targetPath)) {
4089
4413
  allOutputs.push(targetPath);
4090
4414
  } else {
4091
4415
  const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath);
@@ -4113,7 +4437,7 @@ ${fields}
4113
4437
  await fs.mkdir(indexesDir, { recursive: true });
4114
4438
  const compileTasks = entryPoints.map(async (entry) => {
4115
4439
  const resolvedEntry = resolve6(entry);
4116
- const relativeEntry = relative2(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
4440
+ const relativeEntry = relative3(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
4117
4441
  const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors) : compileAngularFile(resolvedEntry, compiledRoot, stylePreprocessors);
4118
4442
  let outputs = await compileEntry();
4119
4443
  const fileBase = basename3(resolvedEntry).replace(/\.[tj]s$/, "");
@@ -4128,12 +4452,12 @@ ${fields}
4128
4452
  ...candidatePaths.map((file) => resolve6(file)),
4129
4453
  ...compiledFallbackPaths
4130
4454
  ];
4131
- let candidate = normalizedCandidates.find((file) => existsSync4(file) && file.endsWith(`${sep}pages${sep}${jsName}`));
4455
+ let candidate = normalizedCandidates.find((file) => existsSync5(file) && file.endsWith(`${sep}pages${sep}${jsName}`));
4132
4456
  if (!candidate) {
4133
- candidate = normalizedCandidates.find((file) => existsSync4(file) && file.endsWith(`${sep}${jsName}`));
4457
+ candidate = normalizedCandidates.find((file) => existsSync5(file) && file.endsWith(`${sep}${jsName}`));
4134
4458
  }
4135
4459
  if (!candidate) {
4136
- candidate = normalizedCandidates.find((file) => existsSync4(file));
4460
+ candidate = normalizedCandidates.find((file) => existsSync5(file));
4137
4461
  }
4138
4462
  return candidate;
4139
4463
  };
@@ -4141,11 +4465,11 @@ ${fields}
4141
4465
  if (!rawServerFile) {
4142
4466
  rawServerFile = resolveRawServerFile([]);
4143
4467
  }
4144
- if (rawServerFile && !existsSync4(rawServerFile)) {
4468
+ if (rawServerFile && !existsSync5(rawServerFile)) {
4145
4469
  outputs = await compileEntry();
4146
4470
  rawServerFile = resolveRawServerFile(outputs);
4147
4471
  }
4148
- if (!rawServerFile || !existsSync4(rawServerFile)) {
4472
+ if (!rawServerFile || !existsSync5(rawServerFile)) {
4149
4473
  throw new Error(`Compiled output not found for ${entry}. Looking for: ${jsName}. Available: ${[
4150
4474
  ...outputs,
4151
4475
  ...compiledFallbackPaths
@@ -4156,7 +4480,7 @@ ${fields}
4156
4480
  const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
4157
4481
  const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
4158
4482
  const clientFile = join5(indexesDir, jsName);
4159
- if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync4(clientFile)) {
4483
+ if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync5(clientFile)) {
4160
4484
  return {
4161
4485
  clientPath: clientFile,
4162
4486
  indexUnchanged: true,
@@ -4190,7 +4514,7 @@ export default ${componentClassName};
4190
4514
  await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
4191
4515
  }
4192
4516
  await fs.writeFile(rawServerFile, rewritten, "utf-8");
4193
- const relativePath = relative2(indexesDir, rawServerFile).replace(/\\/g, "/");
4517
+ const relativePath = relative3(indexesDir, rawServerFile).replace(/\\/g, "/");
4194
4518
  const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
4195
4519
  const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
4196
4520
  import "${hmrRuntimePath}";
@@ -13736,5 +14060,5 @@ export {
13736
14060
  Island
13737
14061
  };
13738
14062
 
13739
- //# debugId=616C70E79D1443DD64756E2164756E21
14063
+ //# debugId=7891B9A2E603847264756E2164756E21
13740
14064
  //# sourceMappingURL=index.js.map