@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/islands/index.js
CHANGED
|
@@ -857,10 +857,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
857
857
|
});
|
|
858
858
|
|
|
859
859
|
// src/build/stylePreprocessor.ts
|
|
860
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "fs";
|
|
860
861
|
import { readFile } from "fs/promises";
|
|
861
862
|
import { createRequire } from "module";
|
|
862
|
-
import { dirname as dirname2, extname, join as join3 } from "path";
|
|
863
|
-
|
|
863
|
+
import { dirname as dirname2, extname, isAbsolute, join as join3, relative, resolve as resolve4 } from "path";
|
|
864
|
+
import { fileURLToPath } from "url";
|
|
865
|
+
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) => {
|
|
864
866
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
865
867
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
866
868
|
return "scss";
|
|
@@ -868,19 +870,214 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
868
870
|
return "sass";
|
|
869
871
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
870
872
|
return "less";
|
|
873
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
874
|
+
return "stylus";
|
|
871
875
|
return null;
|
|
872
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
876
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
877
|
+
dirname2(filePath),
|
|
878
|
+
process.cwd(),
|
|
879
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
880
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
881
|
+
pattern,
|
|
882
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
883
|
+
})), readTsconfigAliases = () => {
|
|
884
|
+
const cwd = process.cwd();
|
|
885
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
886
|
+
return tsconfigAliasCache;
|
|
887
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
888
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
889
|
+
if (!existsSync4(tsconfigPath)) {
|
|
890
|
+
tsconfigAliasCache = empty;
|
|
891
|
+
return empty;
|
|
892
|
+
}
|
|
893
|
+
try {
|
|
894
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
895
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
896
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
897
|
+
tsconfigAliasCache = {
|
|
898
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
899
|
+
baseUrl,
|
|
900
|
+
cwd
|
|
901
|
+
};
|
|
902
|
+
} catch {
|
|
903
|
+
tsconfigAliasCache = empty;
|
|
904
|
+
}
|
|
905
|
+
return tsconfigAliasCache;
|
|
906
|
+
}, getAliasEntries = (config) => {
|
|
907
|
+
const tsconfig = readTsconfigAliases();
|
|
908
|
+
return {
|
|
909
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
910
|
+
baseUrl: tsconfig.baseUrl
|
|
911
|
+
};
|
|
912
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
913
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
914
|
+
const targets = [];
|
|
915
|
+
for (const alias of aliases) {
|
|
916
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
917
|
+
if (!match)
|
|
918
|
+
continue;
|
|
919
|
+
const wildcard = match[1] ?? "";
|
|
920
|
+
for (const replacement of alias.replacements) {
|
|
921
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return targets;
|
|
925
|
+
}, getLanguageExtensions = (language) => {
|
|
926
|
+
if (language === "less")
|
|
927
|
+
return [".less", ".css"];
|
|
928
|
+
if (language === "stylus")
|
|
929
|
+
return [".styl", ".stylus", ".css"];
|
|
930
|
+
return [".scss", ".sass", ".css"];
|
|
931
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
932
|
+
const ext = extname(basePath);
|
|
933
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
934
|
+
`${basePath}${extension}`,
|
|
935
|
+
join3(basePath, `index${extension}`)
|
|
936
|
+
]);
|
|
937
|
+
if (language === "scss" || language === "sass") {
|
|
938
|
+
return paths.flatMap((path) => {
|
|
939
|
+
const dir = dirname2(path);
|
|
940
|
+
const base = path.slice(dir.length + 1);
|
|
941
|
+
return [path, join3(dir, `_${base}`)];
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
return paths;
|
|
945
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
946
|
+
const rawCandidates = [
|
|
947
|
+
...resolveAliasTargets(specifier, config),
|
|
948
|
+
isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
949
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
950
|
+
];
|
|
951
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
952
|
+
if (existsSync4(candidate))
|
|
953
|
+
return candidate;
|
|
954
|
+
}
|
|
955
|
+
return null;
|
|
956
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
957
|
+
const markerIndex = url.search(/[?#]/);
|
|
958
|
+
if (markerIndex === -1)
|
|
959
|
+
return { marker: "", path: url };
|
|
960
|
+
return {
|
|
961
|
+
marker: url.slice(markerIndex),
|
|
962
|
+
path: url.slice(0, markerIndex)
|
|
963
|
+
};
|
|
964
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
965
|
+
const sourceDir = dirname2(sourceFile);
|
|
966
|
+
const entryDir = dirname2(entryFile);
|
|
967
|
+
if (sourceDir === entryDir)
|
|
968
|
+
return contents;
|
|
969
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
970
|
+
const trimmedUrl = rawUrl.trim();
|
|
971
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
972
|
+
return match;
|
|
973
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
974
|
+
const rebased = relative(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
975
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
976
|
+
const nextQuote = quote || '"';
|
|
977
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
978
|
+
});
|
|
979
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
980
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
981
|
+
return match;
|
|
982
|
+
const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
|
|
983
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
984
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
985
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
986
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
987
|
+
}, extractCssModuleExports = (css) => {
|
|
988
|
+
const exports = {};
|
|
989
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
990
|
+
for (const declaration of body.split(";")) {
|
|
991
|
+
const separator = declaration.indexOf(":");
|
|
992
|
+
if (separator === -1)
|
|
993
|
+
continue;
|
|
994
|
+
const key = declaration.slice(0, separator).trim();
|
|
995
|
+
const value = declaration.slice(separator + 1).trim();
|
|
996
|
+
if (key && value)
|
|
997
|
+
exports[key] = value;
|
|
998
|
+
}
|
|
999
|
+
return "";
|
|
1000
|
+
});
|
|
1001
|
+
return { css: nextCss, exports };
|
|
1002
|
+
}, getSassOptions = (config, language) => ({
|
|
1003
|
+
...config?.sass ?? {},
|
|
1004
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
1005
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
1006
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
1007
|
+
canonicalize(specifier, options) {
|
|
1008
|
+
const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
|
|
1009
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1010
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
1011
|
+
},
|
|
1012
|
+
load(canonicalUrl) {
|
|
1013
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
1014
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
1015
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
1016
|
+
return null;
|
|
1017
|
+
return {
|
|
1018
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
1019
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
1023
|
+
install(less, pluginManager) {
|
|
1024
|
+
const baseManager = new less.FileManager;
|
|
1025
|
+
const manager = Object.create(baseManager);
|
|
1026
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1027
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
1028
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1029
|
+
if (!resolved) {
|
|
1030
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1031
|
+
}
|
|
1032
|
+
return {
|
|
1033
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
1034
|
+
filename: resolved
|
|
1035
|
+
};
|
|
1036
|
+
};
|
|
1037
|
+
pluginManager.addFileManager(manager);
|
|
1038
|
+
}
|
|
1039
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
1040
|
+
let stylus;
|
|
1041
|
+
try {
|
|
1042
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
1043
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
1044
|
+
} catch {
|
|
1045
|
+
throw missingDependencyError("stylus", filePath);
|
|
1046
|
+
}
|
|
1047
|
+
return new Promise((resolveCss, reject) => {
|
|
1048
|
+
const renderer = stylus(contents);
|
|
1049
|
+
renderer.set("filename", filePath);
|
|
1050
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
1051
|
+
renderer.set(key, value);
|
|
1052
|
+
}
|
|
1053
|
+
for (const path of loadPaths)
|
|
1054
|
+
renderer.include(path);
|
|
1055
|
+
renderer.render((error, css) => {
|
|
1056
|
+
if (error)
|
|
1057
|
+
reject(error);
|
|
1058
|
+
else
|
|
1059
|
+
resolveCss(css ?? "");
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
873
1063
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
874
|
-
const
|
|
1064
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
875
1065
|
if (language === "scss" || language === "sass") {
|
|
1066
|
+
const options = getSassOptions(config, language);
|
|
1067
|
+
const packageName = options.implementation ?? "sass";
|
|
876
1068
|
let sass;
|
|
877
1069
|
try {
|
|
878
|
-
sass = await importOptionalPeer(
|
|
1070
|
+
sass = await importOptionalPeer(packageName);
|
|
879
1071
|
} catch {
|
|
880
|
-
throw missingDependencyError(
|
|
1072
|
+
throw missingDependencyError(packageName, filePath);
|
|
881
1073
|
}
|
|
1074
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1075
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
882
1076
|
const result = sass.compileString(contents, {
|
|
883
|
-
|
|
1077
|
+
importers: [
|
|
1078
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
1079
|
+
],
|
|
1080
|
+
loadPaths,
|
|
884
1081
|
style: "expanded",
|
|
885
1082
|
syntax: language === "sass" ? "indented" : "scss",
|
|
886
1083
|
url: new URL(`file://${filePath}`)
|
|
@@ -888,6 +1085,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
888
1085
|
return result.css;
|
|
889
1086
|
}
|
|
890
1087
|
if (language === "less") {
|
|
1088
|
+
const options = getLessOptions(config);
|
|
891
1089
|
let lessModule;
|
|
892
1090
|
try {
|
|
893
1091
|
lessModule = await importOptionalPeer("less");
|
|
@@ -898,14 +1096,63 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
898
1096
|
const render = less?.render;
|
|
899
1097
|
if (!render)
|
|
900
1098
|
throw missingDependencyError("less", filePath);
|
|
1099
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
1100
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
901
1101
|
const result = await render(contents, {
|
|
1102
|
+
...options.options ?? {},
|
|
902
1103
|
filename: filePath,
|
|
903
|
-
paths:
|
|
1104
|
+
paths: loadPaths,
|
|
1105
|
+
plugins: [
|
|
1106
|
+
...options.options?.plugins ?? [],
|
|
1107
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
1108
|
+
]
|
|
904
1109
|
});
|
|
905
1110
|
return result.css;
|
|
906
1111
|
}
|
|
907
|
-
|
|
908
|
-
|
|
1112
|
+
if (language === "stylus") {
|
|
1113
|
+
const options = getStylusOptions(config);
|
|
1114
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
1115
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
1116
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
1117
|
+
}
|
|
1118
|
+
return rawContents;
|
|
1119
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
1120
|
+
name: "absolute-style-preprocessor",
|
|
1121
|
+
setup(build) {
|
|
1122
|
+
const cssModuleSources = new Map;
|
|
1123
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
1124
|
+
namespace: "absolute-style-module",
|
|
1125
|
+
path: path.slice("absolute-style-module:".length)
|
|
1126
|
+
}));
|
|
1127
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
1128
|
+
const source = cssModuleSources.get(path);
|
|
1129
|
+
if (!source) {
|
|
1130
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
1131
|
+
}
|
|
1132
|
+
return {
|
|
1133
|
+
contents: source.css,
|
|
1134
|
+
loader: "css"
|
|
1135
|
+
};
|
|
1136
|
+
});
|
|
1137
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
1138
|
+
if (isStyleModulePath(path)) {
|
|
1139
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
1140
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
1141
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
1142
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
1143
|
+
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}`)};`;
|
|
1144
|
+
return {
|
|
1145
|
+
contents: exportSource,
|
|
1146
|
+
loader: "js"
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
return {
|
|
1150
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
1151
|
+
loader: "css"
|
|
1152
|
+
};
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
909
1156
|
style: async ({
|
|
910
1157
|
attributes,
|
|
911
1158
|
content,
|
|
@@ -916,63 +1163,30 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
916
1163
|
return;
|
|
917
1164
|
const path = filename ?? `style.${language}`;
|
|
918
1165
|
return {
|
|
919
|
-
code: await compileStyleSource(path, content, language)
|
|
1166
|
+
code: await compileStyleSource(path, content, language, config)
|
|
920
1167
|
};
|
|
921
1168
|
}
|
|
922
|
-
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
1169
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
923
1170
|
if (!isPreprocessableStylePath(filePath)) {
|
|
924
1171
|
return readFile(filePath, "utf-8");
|
|
925
1172
|
}
|
|
926
|
-
return compileStyleSource(filePath);
|
|
1173
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
927
1174
|
};
|
|
928
1175
|
var init_stylePreprocessor = __esm(() => {
|
|
929
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
930
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
931
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
1176
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1177
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1178
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
932
1179
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
933
1180
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
934
1181
|
requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
|
|
935
|
-
stylePreprocessorPlugin =
|
|
936
|
-
name: "absolute-style-preprocessor",
|
|
937
|
-
setup(build) {
|
|
938
|
-
const cssModuleSources = new Map;
|
|
939
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
940
|
-
namespace: "absolute-style-module",
|
|
941
|
-
path: path.slice("absolute-style-module:".length)
|
|
942
|
-
}));
|
|
943
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
944
|
-
const sourcePath = cssModuleSources.get(path);
|
|
945
|
-
if (!sourcePath) {
|
|
946
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
947
|
-
}
|
|
948
|
-
return {
|
|
949
|
-
contents: await compileStyleSource(sourcePath),
|
|
950
|
-
loader: "css"
|
|
951
|
-
};
|
|
952
|
-
});
|
|
953
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
954
|
-
if (isStyleModulePath(path)) {
|
|
955
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
956
|
-
cssModuleSources.set(cssModulePath, path);
|
|
957
|
-
return {
|
|
958
|
-
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
959
|
-
loader: "js"
|
|
960
|
-
};
|
|
961
|
-
}
|
|
962
|
-
return {
|
|
963
|
-
contents: await compileStyleSource(path),
|
|
964
|
-
loader: "css"
|
|
965
|
-
};
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
};
|
|
1182
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
969
1183
|
});
|
|
970
1184
|
|
|
971
1185
|
// src/core/svelteServerModule.ts
|
|
972
1186
|
import { mkdir, readdir } from "fs/promises";
|
|
973
|
-
import { basename, dirname as dirname3, extname as extname2, join as join4, relative, resolve as
|
|
1187
|
+
import { basename, dirname as dirname3, extname as extname2, join as join4, relative as relative2, resolve as resolve5 } from "path";
|
|
974
1188
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
975
|
-
const importPath =
|
|
1189
|
+
const importPath = relative2(dirname3(from), target).replace(/\\/g, "/");
|
|
976
1190
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
977
1191
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
978
1192
|
for (const entry of entries) {
|
|
@@ -1018,7 +1232,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1018
1232
|
if (!spec.startsWith(".")) {
|
|
1019
1233
|
return null;
|
|
1020
1234
|
}
|
|
1021
|
-
const basePath =
|
|
1235
|
+
const basePath = resolve5(dirname3(from), spec);
|
|
1022
1236
|
const candidates = [
|
|
1023
1237
|
basePath,
|
|
1024
1238
|
`${basePath}.ts`,
|
|
@@ -1036,7 +1250,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1036
1250
|
const foundIndex = existResults.indexOf(true);
|
|
1037
1251
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
1038
1252
|
}, getCachedModulePath = (sourcePath) => {
|
|
1039
|
-
const relativeSourcePath =
|
|
1253
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
1040
1254
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
1041
1255
|
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
1042
1256
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -1050,7 +1264,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
1050
1264
|
if (!spec.startsWith(".")) {
|
|
1051
1265
|
return null;
|
|
1052
1266
|
}
|
|
1053
|
-
const explicitPath =
|
|
1267
|
+
const explicitPath = resolve5(dirname3(from), spec);
|
|
1054
1268
|
if (extname2(explicitPath) === ".svelte") {
|
|
1055
1269
|
return explicitPath;
|
|
1056
1270
|
}
|
|
@@ -1411,5 +1625,5 @@ export {
|
|
|
1411
1625
|
createIslandStore
|
|
1412
1626
|
};
|
|
1413
1627
|
|
|
1414
|
-
//# debugId=
|
|
1628
|
+
//# debugId=DD3DA624C348BAAD64756E2164756E21
|
|
1415
1629
|
//# sourceMappingURL=index.js.map
|