@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/react/index.js
CHANGED
|
@@ -2502,10 +2502,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2502
2502
|
});
|
|
2503
2503
|
|
|
2504
2504
|
// src/build/stylePreprocessor.ts
|
|
2505
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
2505
2506
|
import { readFile } from "fs/promises";
|
|
2506
2507
|
import { createRequire } from "module";
|
|
2507
|
-
import { dirname as dirname2, extname, join as join3 } from "path";
|
|
2508
|
-
|
|
2508
|
+
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
2509
|
+
import { fileURLToPath } from "url";
|
|
2510
|
+
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) => {
|
|
2509
2511
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2510
2512
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2511
2513
|
return "scss";
|
|
@@ -2513,19 +2515,214 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2513
2515
|
return "sass";
|
|
2514
2516
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
2515
2517
|
return "less";
|
|
2518
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2519
|
+
return "stylus";
|
|
2516
2520
|
return null;
|
|
2517
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
2521
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
2522
|
+
dirname2(filePath),
|
|
2523
|
+
process.cwd(),
|
|
2524
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
2525
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
2526
|
+
pattern,
|
|
2527
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
2528
|
+
})), readTsconfigAliases = () => {
|
|
2529
|
+
const cwd = process.cwd();
|
|
2530
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
2531
|
+
return tsconfigAliasCache;
|
|
2532
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
2533
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
2534
|
+
if (!existsSync4(tsconfigPath)) {
|
|
2535
|
+
tsconfigAliasCache = empty;
|
|
2536
|
+
return empty;
|
|
2537
|
+
}
|
|
2538
|
+
try {
|
|
2539
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
2540
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
2541
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
2542
|
+
tsconfigAliasCache = {
|
|
2543
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
2544
|
+
baseUrl,
|
|
2545
|
+
cwd
|
|
2546
|
+
};
|
|
2547
|
+
} catch {
|
|
2548
|
+
tsconfigAliasCache = empty;
|
|
2549
|
+
}
|
|
2550
|
+
return tsconfigAliasCache;
|
|
2551
|
+
}, getAliasEntries = (config) => {
|
|
2552
|
+
const tsconfig = readTsconfigAliases();
|
|
2553
|
+
return {
|
|
2554
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
2555
|
+
baseUrl: tsconfig.baseUrl
|
|
2556
|
+
};
|
|
2557
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
2558
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
2559
|
+
const targets = [];
|
|
2560
|
+
for (const alias of aliases) {
|
|
2561
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
2562
|
+
if (!match)
|
|
2563
|
+
continue;
|
|
2564
|
+
const wildcard = match[1] ?? "";
|
|
2565
|
+
for (const replacement of alias.replacements) {
|
|
2566
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
return targets;
|
|
2570
|
+
}, getLanguageExtensions = (language) => {
|
|
2571
|
+
if (language === "less")
|
|
2572
|
+
return [".less", ".css"];
|
|
2573
|
+
if (language === "stylus")
|
|
2574
|
+
return [".styl", ".stylus", ".css"];
|
|
2575
|
+
return [".scss", ".sass", ".css"];
|
|
2576
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
2577
|
+
const ext = extname(basePath);
|
|
2578
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
2579
|
+
`${basePath}${extension}`,
|
|
2580
|
+
join3(basePath, `index${extension}`)
|
|
2581
|
+
]);
|
|
2582
|
+
if (language === "scss" || language === "sass") {
|
|
2583
|
+
return paths.flatMap((path) => {
|
|
2584
|
+
const dir = dirname2(path);
|
|
2585
|
+
const base = path.slice(dir.length + 1);
|
|
2586
|
+
return [path, join3(dir, `_${base}`)];
|
|
2587
|
+
});
|
|
2588
|
+
}
|
|
2589
|
+
return paths;
|
|
2590
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
2591
|
+
const rawCandidates = [
|
|
2592
|
+
...resolveAliasTargets(specifier, config),
|
|
2593
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
2594
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
2595
|
+
];
|
|
2596
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
2597
|
+
if (existsSync4(candidate))
|
|
2598
|
+
return candidate;
|
|
2599
|
+
}
|
|
2600
|
+
return null;
|
|
2601
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
2602
|
+
const markerIndex = url.search(/[?#]/);
|
|
2603
|
+
if (markerIndex === -1)
|
|
2604
|
+
return { marker: "", path: url };
|
|
2605
|
+
return {
|
|
2606
|
+
marker: url.slice(markerIndex),
|
|
2607
|
+
path: url.slice(0, markerIndex)
|
|
2608
|
+
};
|
|
2609
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
2610
|
+
const sourceDir = dirname2(sourceFile);
|
|
2611
|
+
const entryDir = dirname2(entryFile);
|
|
2612
|
+
if (sourceDir === entryDir)
|
|
2613
|
+
return contents;
|
|
2614
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
2615
|
+
const trimmedUrl = rawUrl.trim();
|
|
2616
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
2617
|
+
return match;
|
|
2618
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
2619
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
2620
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
2621
|
+
const nextQuote = quote || '"';
|
|
2622
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
2623
|
+
});
|
|
2624
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
2625
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
2626
|
+
return match;
|
|
2627
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
2628
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
2629
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
2630
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
2631
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
2632
|
+
}, extractCssModuleExports = (css) => {
|
|
2633
|
+
const exports = {};
|
|
2634
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
2635
|
+
for (const declaration of body.split(";")) {
|
|
2636
|
+
const separator = declaration.indexOf(":");
|
|
2637
|
+
if (separator === -1)
|
|
2638
|
+
continue;
|
|
2639
|
+
const key = declaration.slice(0, separator).trim();
|
|
2640
|
+
const value = declaration.slice(separator + 1).trim();
|
|
2641
|
+
if (key && value)
|
|
2642
|
+
exports[key] = value;
|
|
2643
|
+
}
|
|
2644
|
+
return "";
|
|
2645
|
+
});
|
|
2646
|
+
return { css: nextCss, exports };
|
|
2647
|
+
}, getSassOptions = (config, language) => ({
|
|
2648
|
+
...config?.sass ?? {},
|
|
2649
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
2650
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2651
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2652
|
+
canonicalize(specifier, options) {
|
|
2653
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
2654
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
2655
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
2656
|
+
},
|
|
2657
|
+
load(canonicalUrl) {
|
|
2658
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
2659
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
2660
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
2661
|
+
return null;
|
|
2662
|
+
return {
|
|
2663
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
2664
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
2668
|
+
install(less, pluginManager) {
|
|
2669
|
+
const baseManager = new less.FileManager;
|
|
2670
|
+
const manager = Object.create(baseManager);
|
|
2671
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
2672
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
2673
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
2674
|
+
if (!resolved) {
|
|
2675
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
2676
|
+
}
|
|
2677
|
+
return {
|
|
2678
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
2679
|
+
filename: resolved
|
|
2680
|
+
};
|
|
2681
|
+
};
|
|
2682
|
+
pluginManager.addFileManager(manager);
|
|
2683
|
+
}
|
|
2684
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
2685
|
+
let stylus;
|
|
2686
|
+
try {
|
|
2687
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
2688
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
2689
|
+
} catch {
|
|
2690
|
+
throw missingDependencyError("stylus", filePath);
|
|
2691
|
+
}
|
|
2692
|
+
return new Promise((resolveCss, reject) => {
|
|
2693
|
+
const renderer = stylus(contents);
|
|
2694
|
+
renderer.set("filename", filePath);
|
|
2695
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
2696
|
+
renderer.set(key, value);
|
|
2697
|
+
}
|
|
2698
|
+
for (const path of loadPaths)
|
|
2699
|
+
renderer.include(path);
|
|
2700
|
+
renderer.render((error, css) => {
|
|
2701
|
+
if (error)
|
|
2702
|
+
reject(error);
|
|
2703
|
+
else
|
|
2704
|
+
resolveCss(css ?? "");
|
|
2705
|
+
});
|
|
2706
|
+
});
|
|
2707
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
2518
2708
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2519
|
-
const
|
|
2709
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
2520
2710
|
if (language === "scss" || language === "sass") {
|
|
2711
|
+
const options = getSassOptions(config, language);
|
|
2712
|
+
const packageName = options.implementation ?? "sass";
|
|
2521
2713
|
let sass;
|
|
2522
2714
|
try {
|
|
2523
|
-
sass = await importOptionalPeer(
|
|
2715
|
+
sass = await importOptionalPeer(packageName);
|
|
2524
2716
|
} catch {
|
|
2525
|
-
throw missingDependencyError(
|
|
2717
|
+
throw missingDependencyError(packageName, filePath);
|
|
2526
2718
|
}
|
|
2719
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2720
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2527
2721
|
const result = sass.compileString(contents, {
|
|
2528
|
-
|
|
2722
|
+
importers: [
|
|
2723
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2724
|
+
],
|
|
2725
|
+
loadPaths,
|
|
2529
2726
|
style: "expanded",
|
|
2530
2727
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2531
2728
|
url: new URL(`file://${filePath}`)
|
|
@@ -2533,6 +2730,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2533
2730
|
return result.css;
|
|
2534
2731
|
}
|
|
2535
2732
|
if (language === "less") {
|
|
2733
|
+
const options = getLessOptions(config);
|
|
2536
2734
|
let lessModule;
|
|
2537
2735
|
try {
|
|
2538
2736
|
lessModule = await importOptionalPeer("less");
|
|
@@ -2543,14 +2741,63 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2543
2741
|
const render = less?.render;
|
|
2544
2742
|
if (!render)
|
|
2545
2743
|
throw missingDependencyError("less", filePath);
|
|
2744
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2745
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2546
2746
|
const result = await render(contents, {
|
|
2747
|
+
...options.options ?? {},
|
|
2547
2748
|
filename: filePath,
|
|
2548
|
-
paths:
|
|
2749
|
+
paths: loadPaths,
|
|
2750
|
+
plugins: [
|
|
2751
|
+
...options.options?.plugins ?? [],
|
|
2752
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
2753
|
+
]
|
|
2549
2754
|
});
|
|
2550
2755
|
return result.css;
|
|
2551
2756
|
}
|
|
2552
|
-
|
|
2553
|
-
|
|
2757
|
+
if (language === "stylus") {
|
|
2758
|
+
const options = getStylusOptions(config);
|
|
2759
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2760
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2761
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
2762
|
+
}
|
|
2763
|
+
return rawContents;
|
|
2764
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
2765
|
+
name: "absolute-style-preprocessor",
|
|
2766
|
+
setup(build) {
|
|
2767
|
+
const cssModuleSources = new Map;
|
|
2768
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2769
|
+
namespace: "absolute-style-module",
|
|
2770
|
+
path: path.slice("absolute-style-module:".length)
|
|
2771
|
+
}));
|
|
2772
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2773
|
+
const source = cssModuleSources.get(path);
|
|
2774
|
+
if (!source) {
|
|
2775
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2776
|
+
}
|
|
2777
|
+
return {
|
|
2778
|
+
contents: source.css,
|
|
2779
|
+
loader: "css"
|
|
2780
|
+
};
|
|
2781
|
+
});
|
|
2782
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2783
|
+
if (isStyleModulePath(path)) {
|
|
2784
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2785
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
2786
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
2787
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
2788
|
+
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}`)};`;
|
|
2789
|
+
return {
|
|
2790
|
+
contents: exportSource,
|
|
2791
|
+
loader: "js"
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2794
|
+
return {
|
|
2795
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
2796
|
+
loader: "css"
|
|
2797
|
+
};
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
2554
2801
|
style: async ({
|
|
2555
2802
|
attributes,
|
|
2556
2803
|
content,
|
|
@@ -2561,63 +2808,30 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2561
2808
|
return;
|
|
2562
2809
|
const path = filename ?? `style.${language}`;
|
|
2563
2810
|
return {
|
|
2564
|
-
code: await compileStyleSource(path, content, language)
|
|
2811
|
+
code: await compileStyleSource(path, content, language, config)
|
|
2565
2812
|
};
|
|
2566
2813
|
}
|
|
2567
|
-
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
2814
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
2568
2815
|
if (!isPreprocessableStylePath(filePath)) {
|
|
2569
2816
|
return readFile(filePath, "utf-8");
|
|
2570
2817
|
}
|
|
2571
|
-
return compileStyleSource(filePath);
|
|
2818
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2572
2819
|
};
|
|
2573
2820
|
var init_stylePreprocessor = __esm(() => {
|
|
2574
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
2575
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
2576
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
2821
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2822
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2823
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2577
2824
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2578
2825
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2579
2826
|
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
2580
|
-
stylePreprocessorPlugin =
|
|
2581
|
-
name: "absolute-style-preprocessor",
|
|
2582
|
-
setup(build) {
|
|
2583
|
-
const cssModuleSources = new Map;
|
|
2584
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
2585
|
-
namespace: "absolute-style-module",
|
|
2586
|
-
path: path.slice("absolute-style-module:".length)
|
|
2587
|
-
}));
|
|
2588
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2589
|
-
const sourcePath = cssModuleSources.get(path);
|
|
2590
|
-
if (!sourcePath) {
|
|
2591
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2592
|
-
}
|
|
2593
|
-
return {
|
|
2594
|
-
contents: await compileStyleSource(sourcePath),
|
|
2595
|
-
loader: "css"
|
|
2596
|
-
};
|
|
2597
|
-
});
|
|
2598
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2599
|
-
if (isStyleModulePath(path)) {
|
|
2600
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2601
|
-
cssModuleSources.set(cssModulePath, path);
|
|
2602
|
-
return {
|
|
2603
|
-
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
2604
|
-
loader: "js"
|
|
2605
|
-
};
|
|
2606
|
-
}
|
|
2607
|
-
return {
|
|
2608
|
-
contents: await compileStyleSource(path),
|
|
2609
|
-
loader: "css"
|
|
2610
|
-
};
|
|
2611
|
-
});
|
|
2612
|
-
}
|
|
2613
|
-
};
|
|
2827
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
2614
2828
|
});
|
|
2615
2829
|
|
|
2616
2830
|
// src/core/svelteServerModule.ts
|
|
2617
2831
|
import { mkdir, readdir } from "fs/promises";
|
|
2618
|
-
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as
|
|
2832
|
+
import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
2619
2833
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2620
|
-
const importPath =
|
|
2834
|
+
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
2621
2835
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2622
2836
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2623
2837
|
for (const entry of entries) {
|
|
@@ -2663,7 +2877,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2663
2877
|
if (!spec.startsWith(".")) {
|
|
2664
2878
|
return null;
|
|
2665
2879
|
}
|
|
2666
|
-
const basePath =
|
|
2880
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
2667
2881
|
const candidates = [
|
|
2668
2882
|
basePath,
|
|
2669
2883
|
`${basePath}.ts`,
|
|
@@ -2681,7 +2895,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2681
2895
|
const foundIndex = existResults.indexOf(true);
|
|
2682
2896
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
2683
2897
|
}, getCachedModulePath = (sourcePath) => {
|
|
2684
|
-
const relativeSourcePath =
|
|
2898
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2685
2899
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2686
2900
|
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
2687
2901
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -2695,7 +2909,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2695
2909
|
if (!spec.startsWith(".")) {
|
|
2696
2910
|
return null;
|
|
2697
2911
|
}
|
|
2698
|
-
const explicitPath =
|
|
2912
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
2699
2913
|
if (extname2(explicitPath) === ".svelte") {
|
|
2700
2914
|
return explicitPath;
|
|
2701
2915
|
}
|
|
@@ -3088,5 +3302,5 @@ export {
|
|
|
3088
3302
|
Island
|
|
3089
3303
|
};
|
|
3090
3304
|
|
|
3091
|
-
//# debugId=
|
|
3305
|
+
//# debugId=93D61437E7D290D564756E2164756E21
|
|
3092
3306
|
//# sourceMappingURL=index.js.map
|