@absolutejs/absolute 0.19.0-beta.692 → 0.19.0-beta.694
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 +354 -140
- package/dist/angular/index.js.map +4 -4
- package/dist/angular/server.js +336 -122
- package/dist/angular/server.js.map +4 -4
- package/dist/build.js +667 -442
- package/dist/build.js.map +11 -11
- package/dist/index.js +736 -510
- package/dist/index.js.map +12 -12
- package/dist/islands/index.js +270 -56
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +270 -56
- package/dist/react/index.js.map +3 -3
- package/dist/src/build/compileAngular.d.ts +4 -3
- package/dist/src/build/compileSvelte.d.ts +2 -1
- package/dist/src/build/compileVue.d.ts +2 -1
- package/dist/src/build/stylePreprocessor.d.ts +6 -4
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/dev/moduleServer.d.ts +2 -0
- package/dist/svelte/index.js +284 -70
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +275 -61
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +45 -0
- package/dist/vue/index.js +270 -56
- package/dist/vue/index.js.map +3 -3
- package/package.json +12 -7
package/dist/vue/index.js
CHANGED
|
@@ -2566,10 +2566,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2566
2566
|
});
|
|
2567
2567
|
|
|
2568
2568
|
// src/build/stylePreprocessor.ts
|
|
2569
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
2569
2570
|
import { readFile } from "fs/promises";
|
|
2570
2571
|
import { createRequire } from "module";
|
|
2571
|
-
import { dirname as dirname3, extname, join as join3 } from "path";
|
|
2572
|
-
|
|
2572
|
+
import { dirname as dirname3, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
2573
|
+
import { fileURLToPath } from "url";
|
|
2574
|
+
var 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) => {
|
|
2573
2575
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2574
2576
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2575
2577
|
return "scss";
|
|
@@ -2577,19 +2579,214 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2577
2579
|
return "sass";
|
|
2578
2580
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
2579
2581
|
return "less";
|
|
2582
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2583
|
+
return "stylus";
|
|
2580
2584
|
return null;
|
|
2581
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
2585
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
2586
|
+
dirname3(filePath),
|
|
2587
|
+
process.cwd(),
|
|
2588
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
2589
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
2590
|
+
pattern,
|
|
2591
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
2592
|
+
})), readTsconfigAliases = () => {
|
|
2593
|
+
const cwd = process.cwd();
|
|
2594
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
2595
|
+
return tsconfigAliasCache;
|
|
2596
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
2597
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
2598
|
+
if (!existsSync4(tsconfigPath)) {
|
|
2599
|
+
tsconfigAliasCache = empty;
|
|
2600
|
+
return empty;
|
|
2601
|
+
}
|
|
2602
|
+
try {
|
|
2603
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
2604
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
2605
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
2606
|
+
tsconfigAliasCache = {
|
|
2607
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
2608
|
+
baseUrl,
|
|
2609
|
+
cwd
|
|
2610
|
+
};
|
|
2611
|
+
} catch {
|
|
2612
|
+
tsconfigAliasCache = empty;
|
|
2613
|
+
}
|
|
2614
|
+
return tsconfigAliasCache;
|
|
2615
|
+
}, getAliasEntries = (config) => {
|
|
2616
|
+
const tsconfig = readTsconfigAliases();
|
|
2617
|
+
return {
|
|
2618
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
2619
|
+
baseUrl: tsconfig.baseUrl
|
|
2620
|
+
};
|
|
2621
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
2622
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
2623
|
+
const targets = [];
|
|
2624
|
+
for (const alias of aliases) {
|
|
2625
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
2626
|
+
if (!match)
|
|
2627
|
+
continue;
|
|
2628
|
+
const wildcard = match[1] ?? "";
|
|
2629
|
+
for (const replacement of alias.replacements) {
|
|
2630
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
return targets;
|
|
2634
|
+
}, getLanguageExtensions = (language) => {
|
|
2635
|
+
if (language === "less")
|
|
2636
|
+
return [".less", ".css"];
|
|
2637
|
+
if (language === "stylus")
|
|
2638
|
+
return [".styl", ".stylus", ".css"];
|
|
2639
|
+
return [".scss", ".sass", ".css"];
|
|
2640
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
2641
|
+
const ext = extname(basePath);
|
|
2642
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
2643
|
+
`${basePath}${extension}`,
|
|
2644
|
+
join3(basePath, `index${extension}`)
|
|
2645
|
+
]);
|
|
2646
|
+
if (language === "scss" || language === "sass") {
|
|
2647
|
+
return paths.flatMap((path) => {
|
|
2648
|
+
const dir = dirname3(path);
|
|
2649
|
+
const base = path.slice(dir.length + 1);
|
|
2650
|
+
return [path, join3(dir, `_${base}`)];
|
|
2651
|
+
});
|
|
2652
|
+
}
|
|
2653
|
+
return paths;
|
|
2654
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
2655
|
+
const rawCandidates = [
|
|
2656
|
+
...resolveAliasTargets(specifier, config),
|
|
2657
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
2658
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
2659
|
+
];
|
|
2660
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
2661
|
+
if (existsSync4(candidate))
|
|
2662
|
+
return candidate;
|
|
2663
|
+
}
|
|
2664
|
+
return null;
|
|
2665
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
2666
|
+
const markerIndex = url.search(/[?#]/);
|
|
2667
|
+
if (markerIndex === -1)
|
|
2668
|
+
return { marker: "", path: url };
|
|
2669
|
+
return {
|
|
2670
|
+
marker: url.slice(markerIndex),
|
|
2671
|
+
path: url.slice(0, markerIndex)
|
|
2672
|
+
};
|
|
2673
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
2674
|
+
const sourceDir = dirname3(sourceFile);
|
|
2675
|
+
const entryDir = dirname3(entryFile);
|
|
2676
|
+
if (sourceDir === entryDir)
|
|
2677
|
+
return contents;
|
|
2678
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
2679
|
+
const trimmedUrl = rawUrl.trim();
|
|
2680
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
2681
|
+
return match;
|
|
2682
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
2683
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
2684
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
2685
|
+
const nextQuote = quote || '"';
|
|
2686
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
2687
|
+
});
|
|
2688
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
2689
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
2690
|
+
return match;
|
|
2691
|
+
const resolved = resolveImportPath(specifier, dirname3(sourceFile), loadPaths, language, config);
|
|
2692
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
2693
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
2694
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
2695
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
2696
|
+
}, extractCssModuleExports = (css) => {
|
|
2697
|
+
const exports = {};
|
|
2698
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
2699
|
+
for (const declaration of body.split(";")) {
|
|
2700
|
+
const separator = declaration.indexOf(":");
|
|
2701
|
+
if (separator === -1)
|
|
2702
|
+
continue;
|
|
2703
|
+
const key = declaration.slice(0, separator).trim();
|
|
2704
|
+
const value = declaration.slice(separator + 1).trim();
|
|
2705
|
+
if (key && value)
|
|
2706
|
+
exports[key] = value;
|
|
2707
|
+
}
|
|
2708
|
+
return "";
|
|
2709
|
+
});
|
|
2710
|
+
return { css: nextCss, exports };
|
|
2711
|
+
}, getSassOptions = (config, language) => ({
|
|
2712
|
+
...config?.sass ?? {},
|
|
2713
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
2714
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2715
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2716
|
+
canonicalize(specifier, options) {
|
|
2717
|
+
const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
|
|
2718
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
2719
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
2720
|
+
},
|
|
2721
|
+
load(canonicalUrl) {
|
|
2722
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
2723
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
2724
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
2725
|
+
return null;
|
|
2726
|
+
return {
|
|
2727
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
2728
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
2732
|
+
install(less, pluginManager) {
|
|
2733
|
+
const baseManager = new less.FileManager;
|
|
2734
|
+
const manager = Object.create(baseManager);
|
|
2735
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
2736
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
2737
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
2738
|
+
if (!resolved) {
|
|
2739
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
2740
|
+
}
|
|
2741
|
+
return {
|
|
2742
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
2743
|
+
filename: resolved
|
|
2744
|
+
};
|
|
2745
|
+
};
|
|
2746
|
+
pluginManager.addFileManager(manager);
|
|
2747
|
+
}
|
|
2748
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
2749
|
+
let stylus;
|
|
2750
|
+
try {
|
|
2751
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
2752
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
2753
|
+
} catch {
|
|
2754
|
+
throw missingDependencyError("stylus", filePath);
|
|
2755
|
+
}
|
|
2756
|
+
return new Promise((resolveCss, reject) => {
|
|
2757
|
+
const renderer = stylus(contents);
|
|
2758
|
+
renderer.set("filename", filePath);
|
|
2759
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
2760
|
+
renderer.set(key, value);
|
|
2761
|
+
}
|
|
2762
|
+
for (const path of loadPaths)
|
|
2763
|
+
renderer.include(path);
|
|
2764
|
+
renderer.render((error, css) => {
|
|
2765
|
+
if (error)
|
|
2766
|
+
reject(error);
|
|
2767
|
+
else
|
|
2768
|
+
resolveCss(css ?? "");
|
|
2769
|
+
});
|
|
2770
|
+
});
|
|
2771
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
2582
2772
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2583
|
-
const
|
|
2773
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
2584
2774
|
if (language === "scss" || language === "sass") {
|
|
2775
|
+
const options = getSassOptions(config, language);
|
|
2776
|
+
const packageName = options.implementation ?? "sass";
|
|
2585
2777
|
let sass;
|
|
2586
2778
|
try {
|
|
2587
|
-
sass = await importOptionalPeer(
|
|
2779
|
+
sass = await importOptionalPeer(packageName);
|
|
2588
2780
|
} catch {
|
|
2589
|
-
throw missingDependencyError(
|
|
2781
|
+
throw missingDependencyError(packageName, filePath);
|
|
2590
2782
|
}
|
|
2783
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2784
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2591
2785
|
const result = sass.compileString(contents, {
|
|
2592
|
-
|
|
2786
|
+
importers: [
|
|
2787
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2788
|
+
],
|
|
2789
|
+
loadPaths,
|
|
2593
2790
|
style: "expanded",
|
|
2594
2791
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2595
2792
|
url: new URL(`file://${filePath}`)
|
|
@@ -2597,6 +2794,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2597
2794
|
return result.css;
|
|
2598
2795
|
}
|
|
2599
2796
|
if (language === "less") {
|
|
2797
|
+
const options = getLessOptions(config);
|
|
2600
2798
|
let lessModule;
|
|
2601
2799
|
try {
|
|
2602
2800
|
lessModule = await importOptionalPeer("less");
|
|
@@ -2607,14 +2805,63 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2607
2805
|
const render = less?.render;
|
|
2608
2806
|
if (!render)
|
|
2609
2807
|
throw missingDependencyError("less", filePath);
|
|
2808
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2809
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2610
2810
|
const result = await render(contents, {
|
|
2811
|
+
...options.options ?? {},
|
|
2611
2812
|
filename: filePath,
|
|
2612
|
-
paths:
|
|
2813
|
+
paths: loadPaths,
|
|
2814
|
+
plugins: [
|
|
2815
|
+
...options.options?.plugins ?? [],
|
|
2816
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
2817
|
+
]
|
|
2613
2818
|
});
|
|
2614
2819
|
return result.css;
|
|
2615
2820
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2821
|
+
if (language === "stylus") {
|
|
2822
|
+
const options = getStylusOptions(config);
|
|
2823
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2824
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2825
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
2826
|
+
}
|
|
2827
|
+
return rawContents;
|
|
2828
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
2829
|
+
name: "absolute-style-preprocessor",
|
|
2830
|
+
setup(build) {
|
|
2831
|
+
const cssModuleSources = new Map;
|
|
2832
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2833
|
+
namespace: "absolute-style-module",
|
|
2834
|
+
path: path.slice("absolute-style-module:".length)
|
|
2835
|
+
}));
|
|
2836
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2837
|
+
const source = cssModuleSources.get(path);
|
|
2838
|
+
if (!source) {
|
|
2839
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2840
|
+
}
|
|
2841
|
+
return {
|
|
2842
|
+
contents: source.css,
|
|
2843
|
+
loader: "css"
|
|
2844
|
+
};
|
|
2845
|
+
});
|
|
2846
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2847
|
+
if (isStyleModulePath(path)) {
|
|
2848
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2849
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
2850
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
2851
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
2852
|
+
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}`)};`;
|
|
2853
|
+
return {
|
|
2854
|
+
contents: exportSource,
|
|
2855
|
+
loader: "js"
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
return {
|
|
2859
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
2860
|
+
loader: "css"
|
|
2861
|
+
};
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
2618
2865
|
style: async ({
|
|
2619
2866
|
attributes,
|
|
2620
2867
|
content,
|
|
@@ -2625,63 +2872,30 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2625
2872
|
return;
|
|
2626
2873
|
const path = filename ?? `style.${language}`;
|
|
2627
2874
|
return {
|
|
2628
|
-
code: await compileStyleSource(path, content, language)
|
|
2875
|
+
code: await compileStyleSource(path, content, language, config)
|
|
2629
2876
|
};
|
|
2630
2877
|
}
|
|
2631
|
-
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
2878
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2632
2879
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2633
2880
|
return readFile(filePath, "utf-8");
|
|
2634
2881
|
}
|
|
2635
|
-
return compileStyleSource(filePath);
|
|
2882
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2636
2883
|
};
|
|
2637
2884
|
var init_stylePreprocessor = __esm(() => {
|
|
2638
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
2639
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
2640
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
2885
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2886
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2887
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2641
2888
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2642
2889
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2643
2890
|
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
2644
|
-
stylePreprocessorPlugin =
|
|
2645
|
-
name: "absolute-style-preprocessor",
|
|
2646
|
-
setup(build) {
|
|
2647
|
-
const cssModuleSources = new Map;
|
|
2648
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2649
|
-
namespace: "absolute-style-module",
|
|
2650
|
-
path: path.slice("absolute-style-module:".length)
|
|
2651
|
-
}));
|
|
2652
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2653
|
-
const sourcePath = cssModuleSources.get(path);
|
|
2654
|
-
if (!sourcePath) {
|
|
2655
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2656
|
-
}
|
|
2657
|
-
return {
|
|
2658
|
-
contents: await compileStyleSource(sourcePath),
|
|
2659
|
-
loader: "css"
|
|
2660
|
-
};
|
|
2661
|
-
});
|
|
2662
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2663
|
-
if (isStyleModulePath(path)) {
|
|
2664
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2665
|
-
cssModuleSources.set(cssModulePath, path);
|
|
2666
|
-
return {
|
|
2667
|
-
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
2668
|
-
loader: "js"
|
|
2669
|
-
};
|
|
2670
|
-
}
|
|
2671
|
-
return {
|
|
2672
|
-
contents: await compileStyleSource(path),
|
|
2673
|
-
loader: "css"
|
|
2674
|
-
};
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
};
|
|
2891
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
2678
2892
|
});
|
|
2679
2893
|
|
|
2680
2894
|
// src/core/svelteServerModule.ts
|
|
2681
2895
|
import { mkdir, readdir as readdir2 } from "fs/promises";
|
|
2682
|
-
import { basename as basename3, dirname as dirname4, extname as extname2, join as join4, relative, resolve as
|
|
2896
|
+
import { basename as basename3, dirname as dirname4, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
2683
2897
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2684
|
-
const importPath =
|
|
2898
|
+
const importPath = relative2(dirname4(from), target).replace(/\\/g, "/");
|
|
2685
2899
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2686
2900
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2687
2901
|
for (const entry of entries) {
|
|
@@ -2727,7 +2941,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2727
2941
|
if (!spec.startsWith(".")) {
|
|
2728
2942
|
return null;
|
|
2729
2943
|
}
|
|
2730
|
-
const basePath =
|
|
2944
|
+
const basePath = resolve5(dirname4(from), spec);
|
|
2731
2945
|
const candidates = [
|
|
2732
2946
|
basePath,
|
|
2733
2947
|
`${basePath}.ts`,
|
|
@@ -2745,7 +2959,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2745
2959
|
const foundIndex = existResults.indexOf(true);
|
|
2746
2960
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
2747
2961
|
}, getCachedModulePath = (sourcePath) => {
|
|
2748
|
-
const relativeSourcePath =
|
|
2962
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2749
2963
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2750
2964
|
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
2751
2965
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -2759,7 +2973,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2759
2973
|
if (!spec.startsWith(".")) {
|
|
2760
2974
|
return null;
|
|
2761
2975
|
}
|
|
2762
|
-
const explicitPath =
|
|
2976
|
+
const explicitPath = resolve5(dirname4(from), spec);
|
|
2763
2977
|
if (extname2(explicitPath) === ".svelte") {
|
|
2764
2978
|
return explicitPath;
|
|
2765
2979
|
}
|
|
@@ -3716,5 +3930,5 @@ export {
|
|
|
3716
3930
|
Image_default as Image
|
|
3717
3931
|
};
|
|
3718
3932
|
|
|
3719
|
-
//# debugId=
|
|
3933
|
+
//# debugId=07750B0C39CFEF9564756E2164756E21
|
|
3720
3934
|
//# sourceMappingURL=index.js.map
|