@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.
@@ -2401,11 +2401,53 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2401
2401
  code: await compileStyleSource(path, content, language, config)
2402
2402
  };
2403
2403
  }
2404
- }), compileStyleFileIfNeeded = async (filePath, config) => {
2405
- if (!isPreprocessableStylePath(filePath)) {
2406
- return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
2404
+ }), CSS_IMPORT_PATTERN, resolveCssImportsAsync = async (content, baseDir, visited) => {
2405
+ const matches = Array.from(content.matchAll(CSS_IMPORT_PATTERN));
2406
+ if (matches.length === 0)
2407
+ return content;
2408
+ let cursor = 0;
2409
+ const parts = [];
2410
+ for (const match of matches) {
2411
+ const importPath = match[1];
2412
+ if (importPath === undefined)
2413
+ continue;
2414
+ const start = match.index ?? 0;
2415
+ const end = start + match[0].length;
2416
+ parts.push(content.slice(cursor, start));
2417
+ const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
2418
+ if (visited.has(fullPath) || !existsSync3(fullPath)) {
2419
+ parts.push(visited.has(fullPath) ? "" : match[0]);
2420
+ cursor = end;
2421
+ continue;
2422
+ }
2423
+ const nextVisited = new Set(visited);
2424
+ nextVisited.add(fullPath);
2425
+ const imported = await readFile(fullPath, "utf-8");
2426
+ parts.push(await resolveCssImportsAsync(imported, dirname(fullPath), nextVisited));
2427
+ cursor = end;
2407
2428
  }
2408
- return compileStyleSource(filePath, undefined, undefined, config);
2429
+ parts.push(content.slice(cursor));
2430
+ return parts.join("");
2431
+ }, compileStyleFileIfNeeded = async (filePath, config) => {
2432
+ if (!isPreprocessableStylePath(filePath)) {
2433
+ const raw = await readFile(filePath, "utf-8");
2434
+ const processed = await runPostcss(raw, filePath, config);
2435
+ return resolveCssImportsAsync(processed, dirname(filePath), new Set([filePath]));
2436
+ }
2437
+ const compiled = await compileStyleSource(filePath, undefined, undefined, config);
2438
+ return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
2439
+ }, resolveCssImportsSync = (content, baseDir, visited) => {
2440
+ return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
2441
+ const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
2442
+ if (visited.has(fullPath))
2443
+ return "";
2444
+ if (!existsSync3(fullPath))
2445
+ return match;
2446
+ const nextVisited = new Set(visited);
2447
+ nextVisited.add(fullPath);
2448
+ const imported = readFileSync3(fullPath, "utf-8");
2449
+ return resolveCssImportsSync(imported, dirname(fullPath), nextVisited);
2450
+ });
2409
2451
  }, compileStyleFileIfNeededSync = (filePath, config) => {
2410
2452
  const rawContents = readFileSync3(filePath, "utf-8");
2411
2453
  const language = getStyleLanguage(filePath);
@@ -2423,7 +2465,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2423
2465
  }
2424
2466
  const contents = withAdditionalData(rawContents, options.additionalData);
2425
2467
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
2426
- return sass.compileString(contents, {
2468
+ const compiled = sass.compileString(contents, {
2427
2469
  importers: [
2428
2470
  createSassImporter(filePath, loadPaths, language, config)
2429
2471
  ],
@@ -2432,6 +2474,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2432
2474
  syntax: language === "sass" ? "indented" : "scss",
2433
2475
  url: new URL(`file://${filePath}`)
2434
2476
  }).css;
2477
+ return resolveCssImportsSync(compiled, dirname(filePath), new Set([filePath]));
2435
2478
  }
2436
2479
  if (language === "less") {
2437
2480
  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.`);
@@ -2439,7 +2482,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2439
2482
  if (language === "stylus") {
2440
2483
  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.`);
2441
2484
  }
2442
- return rawContents;
2485
+ return resolveCssImportsSync(rawContents, dirname(filePath), new Set([filePath]));
2443
2486
  }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
2444
2487
  var init_stylePreprocessor = __esm(() => {
2445
2488
  CSS_EXTENSION_PATTERN = /\.css$/i;
@@ -2452,6 +2495,7 @@ var init_stylePreprocessor = __esm(() => {
2452
2495
  styleDependencyGraph = new Map;
2453
2496
  styleOutputHashes = new Map;
2454
2497
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
2498
+ CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
2455
2499
  });
2456
2500
 
2457
2501
  // src/core/svelteServerModule.ts
@@ -3692,5 +3736,5 @@ export {
3692
3736
  Island
3693
3737
  };
3694
3738
 
3695
- //# debugId=373BA0E0A092E99664756E2164756E21
3739
+ //# debugId=9EFB2B06AFE0F78B64756E2164756E21
3696
3740
  //# sourceMappingURL=index.js.map