@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.
@@ -749,12 +749,42 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
749
749
  code: await compileStyleSource(path, content, language, config)
750
750
  };
751
751
  }
752
- }), compileStyleFileIfNeeded = async (filePath, config) => {
752
+ }), CSS_IMPORT_PATTERN, resolveCssImportsAsync = async (content, baseDir, visited) => {
753
+ const matches = Array.from(content.matchAll(CSS_IMPORT_PATTERN));
754
+ if (matches.length === 0)
755
+ return content;
756
+ let cursor = 0;
757
+ const parts = [];
758
+ for (const match of matches) {
759
+ const importPath = match[1];
760
+ if (importPath === undefined)
761
+ continue;
762
+ const start = match.index ?? 0;
763
+ const end = start + match[0].length;
764
+ parts.push(content.slice(cursor, start));
765
+ const fullPath = isAbsolute(importPath) ? importPath : resolve2(baseDir, importPath);
766
+ if (visited.has(fullPath) || !existsSync2(fullPath)) {
767
+ parts.push(visited.has(fullPath) ? "" : match[0]);
768
+ cursor = end;
769
+ continue;
770
+ }
771
+ const nextVisited = new Set(visited);
772
+ nextVisited.add(fullPath);
773
+ const imported = await readFile(fullPath, "utf-8");
774
+ parts.push(await resolveCssImportsAsync(imported, dirname(fullPath), nextVisited));
775
+ cursor = end;
776
+ }
777
+ parts.push(content.slice(cursor));
778
+ return parts.join("");
779
+ }, compileStyleFileIfNeeded = async (filePath, config) => {
753
780
  if (!isPreprocessableStylePath(filePath)) {
754
- return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
781
+ const raw = await readFile(filePath, "utf-8");
782
+ const processed = await runPostcss(raw, filePath, config);
783
+ return resolveCssImportsAsync(processed, dirname(filePath), new Set([filePath]));
755
784
  }
756
- return compileStyleSource(filePath, undefined, undefined, config);
757
- }, CSS_IMPORT_PATTERN, resolveCssImportsSync = (content, baseDir, visited) => {
785
+ const compiled = await compileStyleSource(filePath, undefined, undefined, config);
786
+ return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
787
+ }, resolveCssImportsSync = (content, baseDir, visited) => {
758
788
  return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
759
789
  const fullPath = isAbsolute(importPath) ? importPath : resolve2(baseDir, importPath);
760
790
  if (visited.has(fullPath))
@@ -2830,5 +2860,5 @@ export {
2830
2860
  handleSveltePageRequest
2831
2861
  };
2832
2862
 
2833
- //# debugId=A65ABB988C23244964756E2164756E21
2863
+ //# debugId=461B6DF8F6184EA764756E2164756E21
2834
2864
  //# sourceMappingURL=server.js.map