@absolutejs/absolute 0.19.0-beta.847 → 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,12 +2401,42 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2401
2401
  code: await compileStyleSource(path, content, language, config)
2402
2402
  };
2403
2403
  }
2404
- }), compileStyleFileIfNeeded = async (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;
2428
+ }
2429
+ parts.push(content.slice(cursor));
2430
+ return parts.join("");
2431
+ }, compileStyleFileIfNeeded = async (filePath, config) => {
2405
2432
  if (!isPreprocessableStylePath(filePath)) {
2406
- return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
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]));
2407
2436
  }
2408
- return compileStyleSource(filePath, undefined, undefined, config);
2409
- }, CSS_IMPORT_PATTERN, resolveCssImportsSync = (content, baseDir, visited) => {
2437
+ const compiled = await compileStyleSource(filePath, undefined, undefined, config);
2438
+ return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
2439
+ }, resolveCssImportsSync = (content, baseDir, visited) => {
2410
2440
  return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
2411
2441
  const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
2412
2442
  if (visited.has(fullPath))
@@ -3706,5 +3736,5 @@ export {
3706
3736
  Island
3707
3737
  };
3708
3738
 
3709
- //# debugId=877059AEC7DD35C064756E2164756E21
3739
+ //# debugId=9EFB2B06AFE0F78B64756E2164756E21
3710
3740
  //# sourceMappingURL=index.js.map