@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.
- package/dist/angular/index.js +377 -53
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +377 -53
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +539 -208
- package/dist/build.js.map +7 -7
- package/dist/cli/index.js +1 -0
- package/dist/index.js +2004 -1828
- package/dist/index.js.map +28 -35
- package/dist/islands/index.js +349 -25
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +354 -25
- package/dist/react/index.js.map +3 -3
- package/dist/react/server.js +6 -1
- package/dist/react/server.js.map +2 -2
- package/dist/src/build/stylePreprocessor.d.ts +2 -1
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/core/pageHandlers.d.ts +2 -1
- package/dist/svelte/index.js +359 -35
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +354 -30
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +30 -0
- package/dist/vue/index.js +349 -25
- package/dist/vue/index.js.map +3 -3
- package/package.json +16 -7
package/dist/react/index.js
CHANGED
|
@@ -1640,6 +1640,11 @@ var init_resolveConvention = __esm(() => {
|
|
|
1640
1640
|
});
|
|
1641
1641
|
|
|
1642
1642
|
// src/react/pageHandler.ts
|
|
1643
|
+
var exports_pageHandler = {};
|
|
1644
|
+
__export(exports_pageHandler, {
|
|
1645
|
+
invalidateReactSsrCache: () => invalidateReactSsrCache,
|
|
1646
|
+
handleReactPageRequest: () => handleReactPageRequest
|
|
1647
|
+
});
|
|
1643
1648
|
var ssrDirty = false, buildRefreshSetup = () => {
|
|
1644
1649
|
if (false) {}
|
|
1645
1650
|
return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
|
|
@@ -2502,10 +2507,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2502
2507
|
});
|
|
2503
2508
|
|
|
2504
2509
|
// src/build/stylePreprocessor.ts
|
|
2510
|
+
var exports_stylePreprocessor = {};
|
|
2511
|
+
__export(exports_stylePreprocessor, {
|
|
2512
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
2513
|
+
isStylePath: () => isStylePath,
|
|
2514
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
2515
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
2516
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
2517
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
2518
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
2519
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
2520
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
2521
|
+
compileStyleSource: () => compileStyleSource,
|
|
2522
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
2523
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
|
|
2524
|
+
});
|
|
2525
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
2505
2526
|
import { readFile } from "fs/promises";
|
|
2506
2527
|
import { createRequire } from "module";
|
|
2507
|
-
import { dirname as dirname2, extname, join as join3, resolve as resolve4 } from "path";
|
|
2508
|
-
|
|
2528
|
+
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
2529
|
+
import { fileURLToPath } from "url";
|
|
2530
|
+
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) => {
|
|
2509
2531
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2510
2532
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2511
2533
|
return "scss";
|
|
@@ -2513,16 +2535,266 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2513
2535
|
return "sass";
|
|
2514
2536
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
2515
2537
|
return "less";
|
|
2538
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2539
|
+
return "stylus";
|
|
2516
2540
|
return null;
|
|
2517
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
2541
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
|
|
2542
|
+
try {
|
|
2543
|
+
return requireFromCwd(specifier);
|
|
2544
|
+
} catch {
|
|
2545
|
+
return requireOptionalPeer(specifier);
|
|
2546
|
+
}
|
|
2547
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
2518
2548
|
dirname2(filePath),
|
|
2519
2549
|
process.cwd(),
|
|
2520
2550
|
...paths.map((path) => resolve4(process.cwd(), path))
|
|
2521
|
-
],
|
|
2551
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
2552
|
+
pattern,
|
|
2553
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
2554
|
+
})), readTsconfigAliases = () => {
|
|
2555
|
+
const cwd = process.cwd();
|
|
2556
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
2557
|
+
return tsconfigAliasCache;
|
|
2558
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
2559
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
2560
|
+
if (!existsSync4(tsconfigPath)) {
|
|
2561
|
+
tsconfigAliasCache = empty;
|
|
2562
|
+
return empty;
|
|
2563
|
+
}
|
|
2564
|
+
try {
|
|
2565
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
2566
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
2567
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
2568
|
+
tsconfigAliasCache = {
|
|
2569
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
2570
|
+
baseUrl,
|
|
2571
|
+
cwd
|
|
2572
|
+
};
|
|
2573
|
+
} catch {
|
|
2574
|
+
tsconfigAliasCache = empty;
|
|
2575
|
+
}
|
|
2576
|
+
return tsconfigAliasCache;
|
|
2577
|
+
}, getAliasEntries = (config) => {
|
|
2578
|
+
const tsconfig = readTsconfigAliases();
|
|
2579
|
+
return {
|
|
2580
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
2581
|
+
baseUrl: tsconfig.baseUrl
|
|
2582
|
+
};
|
|
2583
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
2584
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
2585
|
+
const targets = [];
|
|
2586
|
+
for (const alias of aliases) {
|
|
2587
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
2588
|
+
if (!match)
|
|
2589
|
+
continue;
|
|
2590
|
+
const wildcard = match[1] ?? "";
|
|
2591
|
+
for (const replacement of alias.replacements) {
|
|
2592
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
return targets;
|
|
2596
|
+
}, getLanguageExtensions = (language) => {
|
|
2597
|
+
if (language === "less")
|
|
2598
|
+
return [".less", ".css"];
|
|
2599
|
+
if (language === "stylus")
|
|
2600
|
+
return [".styl", ".stylus", ".css"];
|
|
2601
|
+
return [".scss", ".sass", ".css"];
|
|
2602
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
2603
|
+
const ext = extname(basePath);
|
|
2604
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
2605
|
+
`${basePath}${extension}`,
|
|
2606
|
+
join3(basePath, `index${extension}`)
|
|
2607
|
+
]);
|
|
2608
|
+
if (language === "scss" || language === "sass") {
|
|
2609
|
+
return paths.flatMap((path) => {
|
|
2610
|
+
const dir = dirname2(path);
|
|
2611
|
+
const base = path.slice(dir.length + 1);
|
|
2612
|
+
return [path, join3(dir, `_${base}`)];
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
return paths;
|
|
2616
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
2617
|
+
const rawCandidates = [
|
|
2618
|
+
...resolveAliasTargets(specifier, config),
|
|
2619
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
2620
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
2621
|
+
];
|
|
2622
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
2623
|
+
if (existsSync4(candidate))
|
|
2624
|
+
return candidate;
|
|
2625
|
+
}
|
|
2626
|
+
return null;
|
|
2627
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
2628
|
+
const markerIndex = url.search(/[?#]/);
|
|
2629
|
+
if (markerIndex === -1)
|
|
2630
|
+
return { marker: "", path: url };
|
|
2631
|
+
return {
|
|
2632
|
+
marker: url.slice(markerIndex),
|
|
2633
|
+
path: url.slice(0, markerIndex)
|
|
2634
|
+
};
|
|
2635
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
2636
|
+
const sourceDir = dirname2(sourceFile);
|
|
2637
|
+
const entryDir = dirname2(entryFile);
|
|
2638
|
+
if (sourceDir === entryDir)
|
|
2639
|
+
return contents;
|
|
2640
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
2641
|
+
const trimmedUrl = rawUrl.trim();
|
|
2642
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
2643
|
+
return match;
|
|
2644
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
2645
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
2646
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
2647
|
+
const nextQuote = quote || '"';
|
|
2648
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
2649
|
+
});
|
|
2650
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
2651
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
2652
|
+
return match;
|
|
2653
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
2654
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
2655
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
2656
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
2657
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
2658
|
+
}, extractCssModuleExports = (css) => {
|
|
2659
|
+
const exports = {};
|
|
2660
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
2661
|
+
for (const declaration of body.split(";")) {
|
|
2662
|
+
const separator = declaration.indexOf(":");
|
|
2663
|
+
if (separator === -1)
|
|
2664
|
+
continue;
|
|
2665
|
+
const key = declaration.slice(0, separator).trim();
|
|
2666
|
+
const value = declaration.slice(separator + 1).trim();
|
|
2667
|
+
if (key && value)
|
|
2668
|
+
exports[key] = value;
|
|
2669
|
+
}
|
|
2670
|
+
return "";
|
|
2671
|
+
});
|
|
2672
|
+
return { css: nextCss, exports };
|
|
2673
|
+
}, getSassOptions = (config, language) => ({
|
|
2522
2674
|
...config?.sass ?? {},
|
|
2523
2675
|
...language === "scss" ? config?.scss ?? {} : {}
|
|
2524
|
-
}), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2525
|
-
${contents}` : contents,
|
|
2676
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2677
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
2678
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
2679
|
+
return mod.default ?? mod;
|
|
2680
|
+
}
|
|
2681
|
+
return mod;
|
|
2682
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
2683
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
2684
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
2685
|
+
const config = normalizePostcssModule(loaded);
|
|
2686
|
+
const value = typeof config === "function" ? await config({
|
|
2687
|
+
cwd: process.cwd(),
|
|
2688
|
+
env: "development"
|
|
2689
|
+
}) : config;
|
|
2690
|
+
return normalizePostcssModule(value) ?? {};
|
|
2691
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
2692
|
+
if (!plugins)
|
|
2693
|
+
return [];
|
|
2694
|
+
if (Array.isArray(plugins))
|
|
2695
|
+
return plugins.filter(Boolean);
|
|
2696
|
+
const resolved = [];
|
|
2697
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
2698
|
+
if (options === false)
|
|
2699
|
+
continue;
|
|
2700
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
2701
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
2702
|
+
if (plugin)
|
|
2703
|
+
resolved.push(plugin);
|
|
2704
|
+
}
|
|
2705
|
+
return resolved;
|
|
2706
|
+
}, resolvePostcssConfig = async (config) => {
|
|
2707
|
+
const inlineConfig = config?.postcss;
|
|
2708
|
+
if (!inlineConfig)
|
|
2709
|
+
return null;
|
|
2710
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
2711
|
+
const plugins = [
|
|
2712
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
2713
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
2714
|
+
];
|
|
2715
|
+
if (plugins.length === 0)
|
|
2716
|
+
return null;
|
|
2717
|
+
return {
|
|
2718
|
+
options: {
|
|
2719
|
+
...fileConfig.options ?? {},
|
|
2720
|
+
...inlineConfig.options ?? {}
|
|
2721
|
+
},
|
|
2722
|
+
plugins
|
|
2723
|
+
};
|
|
2724
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
2725
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
2726
|
+
if (!postcssConfig)
|
|
2727
|
+
return css;
|
|
2728
|
+
let postcssModule;
|
|
2729
|
+
try {
|
|
2730
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
2731
|
+
} catch {
|
|
2732
|
+
throw missingDependencyError("postcss", filePath);
|
|
2733
|
+
}
|
|
2734
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
2735
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
2736
|
+
from: filePath,
|
|
2737
|
+
map: false,
|
|
2738
|
+
...postcssConfig.options
|
|
2739
|
+
});
|
|
2740
|
+
return result.css;
|
|
2741
|
+
}, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2742
|
+
canonicalize(specifier, options) {
|
|
2743
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
2744
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
2745
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
2746
|
+
},
|
|
2747
|
+
load(canonicalUrl) {
|
|
2748
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
2749
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
2750
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
2751
|
+
return null;
|
|
2752
|
+
return {
|
|
2753
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
2754
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
2755
|
+
};
|
|
2756
|
+
}
|
|
2757
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
2758
|
+
install(less, pluginManager) {
|
|
2759
|
+
const baseManager = new less.FileManager;
|
|
2760
|
+
const manager = Object.create(baseManager);
|
|
2761
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
2762
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
2763
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
2764
|
+
if (!resolved) {
|
|
2765
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
2766
|
+
}
|
|
2767
|
+
return {
|
|
2768
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
2769
|
+
filename: resolved
|
|
2770
|
+
};
|
|
2771
|
+
};
|
|
2772
|
+
pluginManager.addFileManager(manager);
|
|
2773
|
+
}
|
|
2774
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
2775
|
+
let stylus;
|
|
2776
|
+
try {
|
|
2777
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
2778
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
2779
|
+
} catch {
|
|
2780
|
+
throw missingDependencyError("stylus", filePath);
|
|
2781
|
+
}
|
|
2782
|
+
return new Promise((resolveCss, reject) => {
|
|
2783
|
+
const renderer = stylus(contents);
|
|
2784
|
+
renderer.set("filename", filePath);
|
|
2785
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
2786
|
+
renderer.set(key, value);
|
|
2787
|
+
}
|
|
2788
|
+
for (const path of loadPaths)
|
|
2789
|
+
renderer.include(path);
|
|
2790
|
+
renderer.render((error, css) => {
|
|
2791
|
+
if (error)
|
|
2792
|
+
reject(error);
|
|
2793
|
+
else
|
|
2794
|
+
resolveCss(css ?? "");
|
|
2795
|
+
});
|
|
2796
|
+
});
|
|
2797
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
2526
2798
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2527
2799
|
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
2528
2800
|
if (language === "scss" || language === "sass") {
|
|
@@ -2535,13 +2807,17 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2535
2807
|
throw missingDependencyError(packageName, filePath);
|
|
2536
2808
|
}
|
|
2537
2809
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2810
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2538
2811
|
const result = sass.compileString(contents, {
|
|
2539
|
-
|
|
2812
|
+
importers: [
|
|
2813
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2814
|
+
],
|
|
2815
|
+
loadPaths,
|
|
2540
2816
|
style: "expanded",
|
|
2541
2817
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2542
2818
|
url: new URL(`file://${filePath}`)
|
|
2543
2819
|
});
|
|
2544
|
-
return result.css;
|
|
2820
|
+
return runPostcss(result.css, filePath, config);
|
|
2545
2821
|
}
|
|
2546
2822
|
if (language === "less") {
|
|
2547
2823
|
const options = getLessOptions(config);
|
|
@@ -2556,14 +2832,25 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2556
2832
|
if (!render)
|
|
2557
2833
|
throw missingDependencyError("less", filePath);
|
|
2558
2834
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2835
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2559
2836
|
const result = await render(contents, {
|
|
2560
2837
|
...options.options ?? {},
|
|
2561
2838
|
filename: filePath,
|
|
2562
|
-
paths:
|
|
2839
|
+
paths: loadPaths,
|
|
2840
|
+
plugins: [
|
|
2841
|
+
...options.options?.plugins ?? [],
|
|
2842
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
2843
|
+
]
|
|
2563
2844
|
});
|
|
2564
|
-
return result.css;
|
|
2845
|
+
return runPostcss(result.css, filePath, config);
|
|
2565
2846
|
}
|
|
2566
|
-
|
|
2847
|
+
if (language === "stylus") {
|
|
2848
|
+
const options = getStylusOptions(config);
|
|
2849
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2850
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2851
|
+
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
2852
|
+
}
|
|
2853
|
+
return runPostcss(rawContents, filePath, config);
|
|
2567
2854
|
}, createStylePreprocessorPlugin = (config) => ({
|
|
2568
2855
|
name: "absolute-style-preprocessor",
|
|
2569
2856
|
setup(build) {
|
|
@@ -2573,21 +2860,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2573
2860
|
path: path.slice("absolute-style-module:".length)
|
|
2574
2861
|
}));
|
|
2575
2862
|
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2576
|
-
const
|
|
2577
|
-
if (!
|
|
2863
|
+
const source = cssModuleSources.get(path);
|
|
2864
|
+
if (!source) {
|
|
2578
2865
|
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2579
2866
|
}
|
|
2580
2867
|
return {
|
|
2581
|
-
contents:
|
|
2868
|
+
contents: source.css,
|
|
2582
2869
|
loader: "css"
|
|
2583
2870
|
};
|
|
2584
2871
|
});
|
|
2585
2872
|
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2586
2873
|
if (isStyleModulePath(path)) {
|
|
2587
2874
|
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2588
|
-
|
|
2875
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
2876
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
2877
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
2878
|
+
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}`)};`;
|
|
2589
2879
|
return {
|
|
2590
|
-
contents:
|
|
2880
|
+
contents: exportSource,
|
|
2591
2881
|
loader: "js"
|
|
2592
2882
|
};
|
|
2593
2883
|
}
|
|
@@ -2596,6 +2886,10 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2596
2886
|
loader: "css"
|
|
2597
2887
|
};
|
|
2598
2888
|
});
|
|
2889
|
+
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
2890
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
2891
|
+
loader: "css"
|
|
2892
|
+
}));
|
|
2599
2893
|
}
|
|
2600
2894
|
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
2601
2895
|
style: async ({
|
|
@@ -2613,14 +2907,49 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2613
2907
|
}
|
|
2614
2908
|
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2615
2909
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2616
|
-
return readFile(filePath, "utf-8");
|
|
2910
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
2617
2911
|
}
|
|
2618
2912
|
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2619
|
-
}
|
|
2913
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
2914
|
+
const rawContents = readFileSync3(filePath, "utf-8");
|
|
2915
|
+
const language = getStyleLanguage(filePath);
|
|
2916
|
+
if (config?.postcss) {
|
|
2917
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
2918
|
+
}
|
|
2919
|
+
if (language === "scss" || language === "sass") {
|
|
2920
|
+
const options = getSassOptions(config, language);
|
|
2921
|
+
const packageName = options.implementation ?? "sass";
|
|
2922
|
+
let sass;
|
|
2923
|
+
try {
|
|
2924
|
+
sass = requireOptionalPeerSync(packageName);
|
|
2925
|
+
} catch {
|
|
2926
|
+
throw missingDependencyError(packageName, filePath);
|
|
2927
|
+
}
|
|
2928
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2929
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2930
|
+
return sass.compileString(contents, {
|
|
2931
|
+
importers: [
|
|
2932
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2933
|
+
],
|
|
2934
|
+
loadPaths,
|
|
2935
|
+
style: "expanded",
|
|
2936
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
2937
|
+
url: new URL(`file://${filePath}`)
|
|
2938
|
+
}).css;
|
|
2939
|
+
}
|
|
2940
|
+
if (language === "less") {
|
|
2941
|
+
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.`);
|
|
2942
|
+
}
|
|
2943
|
+
if (language === "stylus") {
|
|
2944
|
+
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.`);
|
|
2945
|
+
}
|
|
2946
|
+
return rawContents;
|
|
2947
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
2620
2948
|
var init_stylePreprocessor = __esm(() => {
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2949
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
2950
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2951
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2952
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2624
2953
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2625
2954
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2626
2955
|
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
@@ -2629,9 +2958,9 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
2629
2958
|
|
|
2630
2959
|
// src/core/svelteServerModule.ts
|
|
2631
2960
|
import { mkdir, readdir } from "fs/promises";
|
|
2632
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as resolve5 } from "path";
|
|
2961
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
2633
2962
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2634
|
-
const importPath =
|
|
2963
|
+
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
2635
2964
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2636
2965
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2637
2966
|
for (const entry of entries) {
|
|
@@ -2695,7 +3024,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2695
3024
|
const foundIndex = existResults.indexOf(true);
|
|
2696
3025
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
2697
3026
|
}, getCachedModulePath = (sourcePath) => {
|
|
2698
|
-
const relativeSourcePath =
|
|
3027
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2699
3028
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2700
3029
|
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
2701
3030
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -3102,5 +3431,5 @@ export {
|
|
|
3102
3431
|
Island
|
|
3103
3432
|
};
|
|
3104
3433
|
|
|
3105
|
-
//# debugId=
|
|
3434
|
+
//# debugId=25DC64FB167A008E64756E2164756E21
|
|
3106
3435
|
//# sourceMappingURL=index.js.map
|