@absolutejs/absolute 0.19.0-beta.846 → 0.19.0-beta.848

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.
@@ -1418,11 +1418,53 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1418
1418
  code: await compileStyleSource(path, content, language, config)
1419
1419
  };
1420
1420
  }
1421
- }), compileStyleFileIfNeeded = async (filePath, config) => {
1421
+ }), CSS_IMPORT_PATTERN, resolveCssImportsAsync = async (content, baseDir, visited) => {
1422
+ const matches = Array.from(content.matchAll(CSS_IMPORT_PATTERN));
1423
+ if (matches.length === 0)
1424
+ return content;
1425
+ let cursor = 0;
1426
+ const parts = [];
1427
+ for (const match of matches) {
1428
+ const importPath = match[1];
1429
+ if (importPath === undefined)
1430
+ continue;
1431
+ const start = match.index ?? 0;
1432
+ const end = start + match[0].length;
1433
+ parts.push(content.slice(cursor, start));
1434
+ const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
1435
+ if (visited.has(fullPath) || !existsSync3(fullPath)) {
1436
+ parts.push(visited.has(fullPath) ? "" : match[0]);
1437
+ cursor = end;
1438
+ continue;
1439
+ }
1440
+ const nextVisited = new Set(visited);
1441
+ nextVisited.add(fullPath);
1442
+ const imported = await readFile(fullPath, "utf-8");
1443
+ parts.push(await resolveCssImportsAsync(imported, dirname(fullPath), nextVisited));
1444
+ cursor = end;
1445
+ }
1446
+ parts.push(content.slice(cursor));
1447
+ return parts.join("");
1448
+ }, compileStyleFileIfNeeded = async (filePath, config) => {
1422
1449
  if (!isPreprocessableStylePath(filePath)) {
1423
- return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
1424
- }
1425
- return compileStyleSource(filePath, undefined, undefined, config);
1450
+ const raw = await readFile(filePath, "utf-8");
1451
+ const processed = await runPostcss(raw, filePath, config);
1452
+ return resolveCssImportsAsync(processed, dirname(filePath), new Set([filePath]));
1453
+ }
1454
+ const compiled = await compileStyleSource(filePath, undefined, undefined, config);
1455
+ return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
1456
+ }, resolveCssImportsSync = (content, baseDir, visited) => {
1457
+ return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
1458
+ const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
1459
+ if (visited.has(fullPath))
1460
+ return "";
1461
+ if (!existsSync3(fullPath))
1462
+ return match;
1463
+ const nextVisited = new Set(visited);
1464
+ nextVisited.add(fullPath);
1465
+ const imported = readFileSync3(fullPath, "utf-8");
1466
+ return resolveCssImportsSync(imported, dirname(fullPath), nextVisited);
1467
+ });
1426
1468
  }, compileStyleFileIfNeededSync = (filePath, config) => {
1427
1469
  const rawContents = readFileSync3(filePath, "utf-8");
1428
1470
  const language = getStyleLanguage(filePath);
@@ -1440,7 +1482,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1440
1482
  }
1441
1483
  const contents = withAdditionalData(rawContents, options.additionalData);
1442
1484
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
1443
- return sass.compileString(contents, {
1485
+ const compiled = sass.compileString(contents, {
1444
1486
  importers: [
1445
1487
  createSassImporter(filePath, loadPaths, language, config)
1446
1488
  ],
@@ -1449,6 +1491,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1449
1491
  syntax: language === "sass" ? "indented" : "scss",
1450
1492
  url: new URL(`file://${filePath}`)
1451
1493
  }).css;
1494
+ return resolveCssImportsSync(compiled, dirname(filePath), new Set([filePath]));
1452
1495
  }
1453
1496
  if (language === "less") {
1454
1497
  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.`);
@@ -1456,7 +1499,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1456
1499
  if (language === "stylus") {
1457
1500
  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.`);
1458
1501
  }
1459
- return rawContents;
1502
+ return resolveCssImportsSync(rawContents, dirname(filePath), new Set([filePath]));
1460
1503
  }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
1461
1504
  var init_stylePreprocessor = __esm(() => {
1462
1505
  CSS_EXTENSION_PATTERN = /\.css$/i;
@@ -1469,6 +1512,7 @@ var init_stylePreprocessor = __esm(() => {
1469
1512
  styleDependencyGraph = new Map;
1470
1513
  styleOutputHashes = new Map;
1471
1514
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
1515
+ CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
1472
1516
  });
1473
1517
 
1474
1518
  // src/core/svelteServerModule.ts
@@ -1920,5 +1964,5 @@ export {
1920
1964
  createIslandStore
1921
1965
  };
1922
1966
 
1923
- //# debugId=CCC546A5B42917F264756E2164756E21
1967
+ //# debugId=A6A848154BD4BD6764756E2164756E21
1924
1968
  //# sourceMappingURL=index.js.map