@absolutejs/absolute 0.20.0-beta.172 → 0.20.0-beta.173
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/CHANGELOG.md +32 -0
- package/README.md +3 -2
- package/changelog.json +57 -0
- package/dist/angular/browser.js +12 -12
- package/dist/angular/browser.js.map +6 -7
- package/dist/angular/components/core/streamingSlotRegistrar.js +2 -6
- package/dist/angular/components/core/streamingSlotRegistry.js +3 -7
- package/dist/angular/components/defer-slot.component.js +12 -7
- package/dist/angular/components/stream-slot.component.js +3 -1
- package/dist/angular/index.js +40 -13
- package/dist/angular/index.js.map +7 -7
- package/dist/angular/server.js +39 -12
- package/dist/angular/server.js.map +6 -6
- package/dist/build/buildWorker.js +135 -57
- package/dist/build.js +1183 -1011
- package/dist/build.js.map +16 -15
- package/dist/cli/config/server.js +43 -12
- package/dist/cli/{doctor-repprx92.js → doctor-m36tmx4d.js} +70 -15
- package/dist/cli/index.js +1 -1
- package/dist/core/streamingSlotRegistrar.js +2 -5
- package/dist/core/streamingSlotRegistrar.js.map +4 -5
- package/dist/core/streamingSlotRegistry.js +2 -5
- package/dist/core/streamingSlotRegistry.js.map +4 -5
- package/dist/dev/serverBootstrap.js +2 -1
- package/dist/index.js +1116 -940
- package/dist/index.js.map +18 -17
- package/dist/islands/index.js +2 -2
- package/dist/islands/index.js.map +3 -3
- package/dist/mobile/browser.js +2 -2
- package/dist/mobile/browser.js.map +3 -3
- package/dist/mobile/index.js +2 -2
- package/dist/mobile/index.js.map +3 -3
- package/dist/react/components/index.js +2 -5
- package/dist/react/components/index.js.map +5 -6
- package/dist/react/index.js +45 -16
- package/dist/react/index.js.map +8 -8
- package/dist/react/router/browser.js.map +2 -2
- package/dist/react/router/index.js.map +2 -2
- package/dist/react/server.js +45 -16
- package/dist/react/server.js.map +8 -8
- package/dist/src/angular/components/defer-slot.component.d.ts +1 -0
- package/dist/src/build/missingReactRouter.d.ts +8 -0
- package/dist/src/build/vueModuleOutputPath.d.ts +10 -6
- package/dist/src/cli/scripts/doctor.d.ts +10 -0
- package/dist/src/core/streamingSlotWarningScope.d.ts +3 -0
- package/dist/src/dev/hot/reload.d.ts +5 -0
- package/dist/src/dev/hot/runtime.d.ts +2 -0
- package/dist/src/dev/srcPath.d.ts +2 -1
- package/dist/src/react/pageHandler.d.ts +5 -0
- package/dist/src/react/router/Link.d.ts +6 -1
- package/dist/src/react/serverComponents/pageHandler.d.ts +2 -0
- package/dist/src/utils/portInUse.d.ts +16 -0
- package/dist/svelte/index.js +39 -12
- package/dist/svelte/index.js.map +6 -6
- package/dist/svelte/server.js +39 -12
- package/dist/svelte/server.js.map +6 -6
- package/dist/vue/components/index.js +2 -5
- package/dist/vue/components/index.js.map +4 -5
- package/dist/vue/index.js +39 -12
- package/dist/vue/index.js.map +6 -6
- package/dist/vue/server.js +39 -12
- package/dist/vue/server.js.map +6 -6
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ var inlineSourceMapComment = (map) => [
|
|
|
33
33
|
`);
|
|
34
34
|
|
|
35
35
|
// src/constants.ts
|
|
36
|
-
var HOURS_IN_DAY = 24, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, TWO_THIRDS;
|
|
36
|
+
var BASE_36_RADIX = 36, HOURS_IN_DAY = 24, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, TWO_THIRDS;
|
|
37
37
|
var init_constants = __esm(() => {
|
|
38
38
|
MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
|
|
39
39
|
MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
|
|
@@ -772,26 +772,65 @@ var vueCompileCacheEnabled = () => process.env.ABSOLUTE_COMPILE_CACHE !== "0", h
|
|
|
772
772
|
};
|
|
773
773
|
var init_vueCompileCache = () => {};
|
|
774
774
|
|
|
775
|
+
// src/build/vueModuleOutputPath.ts
|
|
776
|
+
import {
|
|
777
|
+
dirname as dirname2,
|
|
778
|
+
isAbsolute,
|
|
779
|
+
join as join3,
|
|
780
|
+
parse,
|
|
781
|
+
relative,
|
|
782
|
+
resolve as resolve2,
|
|
783
|
+
sep
|
|
784
|
+
} from "path";
|
|
785
|
+
var EXTERNAL_DIR = "_external", UNRELATED_PREFIX = "h-", HASH_LENGTH = 13, toOutputName = (path) => path.replace(/\.(vue|ts)$/, ".js"), unrelatedMirrorPath = (absolutePath) => {
|
|
786
|
+
const directory = dirname2(absolutePath);
|
|
787
|
+
const directoryHash = Bun.hash(directory).toString(BASE_36_RADIX).padStart(HASH_LENGTH, "0");
|
|
788
|
+
return join3(EXTERNAL_DIR, `${UNRELATED_PREFIX}${directoryHash}`, toOutputName(relative(directory, absolutePath)));
|
|
789
|
+
}, sourceMirrorPath = (sourcePath, projectRoot) => {
|
|
790
|
+
const absolutePath = resolve2(sourcePath);
|
|
791
|
+
const root = resolve2(projectRoot);
|
|
792
|
+
const fromRoot = relative(root, absolutePath);
|
|
793
|
+
if (isAbsolute(fromRoot))
|
|
794
|
+
return unrelatedMirrorPath(absolutePath);
|
|
795
|
+
const segments = fromRoot.split(sep);
|
|
796
|
+
const levelsUp = segments.findIndex((segment) => segment !== "..");
|
|
797
|
+
if (levelsUp === 0)
|
|
798
|
+
return toOutputName(fromRoot);
|
|
799
|
+
const sharedAncestor = join3(root, ...segments.slice(0, levelsUp));
|
|
800
|
+
if (levelsUp < 0 || parse(sharedAncestor).root === sharedAncestor)
|
|
801
|
+
return unrelatedMirrorPath(absolutePath);
|
|
802
|
+
return join3(EXTERNAL_DIR, String(levelsUp), toOutputName(segments.slice(levelsUp).join(sep)));
|
|
803
|
+
}, vueRelativeOutputImport = (importerSource, targetSource, projectRoot = process.cwd()) => {
|
|
804
|
+
const specifier = relative(dirname2(sourceMirrorPath(importerSource, projectRoot)), sourceMirrorPath(targetSource, projectRoot)).replace(/\\/g, "/");
|
|
805
|
+
return specifier.startsWith("../") ? specifier : `./${specifier}`;
|
|
806
|
+
}, mirrorRegion = (sourcePath, projectRoot) => {
|
|
807
|
+
const [first, second] = sourceMirrorPath(sourcePath, projectRoot).split(sep);
|
|
808
|
+
return first === EXTERNAL_DIR ? `${EXTERNAL_DIR}/${second}` : "";
|
|
809
|
+
}, vueMirrorImport = (importerSource, specifier, targetSource, projectRoot = process.cwd()) => mirrorRegion(importerSource, projectRoot) === mirrorRegion(targetSource, projectRoot) ? specifier : vueRelativeOutputImport(importerSource, targetSource, projectRoot);
|
|
810
|
+
var init_vueModuleOutputPath = __esm(() => {
|
|
811
|
+
init_constants();
|
|
812
|
+
});
|
|
813
|
+
|
|
775
814
|
// src/build/emitTsHelpers.ts
|
|
776
815
|
var exports_emitTsHelpers = {};
|
|
777
816
|
__export(exports_emitTsHelpers, {
|
|
778
817
|
emitTsHelpers: () => emitTsHelpers
|
|
779
818
|
});
|
|
780
819
|
var {file, Transpiler, write } = globalThis.Bun;
|
|
781
|
-
import { copyFileSync, existsSync as existsSync3, readdirSync } from "fs";
|
|
820
|
+
import { copyFileSync, existsSync as existsSync3, readdirSync, statSync } from "fs";
|
|
782
821
|
import { mkdir, rename, writeFile } from "fs/promises";
|
|
783
|
-
import { dirname as
|
|
784
|
-
var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION =
|
|
822
|
+
import { dirname as dirname3, join as join4, resolve as resolve3, sep as sep2 } from "path";
|
|
823
|
+
var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION = 2, HASH_LENGTH2 = 24, transpiler, cacheDir = () => join4(process.cwd(), ".absolutejs", "compile-cache", CACHE_DIR_NAME), cacheKey = (sourcePath, sourceCode) => {
|
|
785
824
|
const frameworkVersion = frameworkVersionForCache();
|
|
786
825
|
if (!frameworkVersion || !vueCompileCacheEnabled())
|
|
787
826
|
return null;
|
|
788
827
|
return {
|
|
789
|
-
content: hashContent(sourceCode).slice(0,
|
|
828
|
+
content: hashContent(sourceCode).slice(0, HASH_LENGTH2),
|
|
790
829
|
path: hashParts([
|
|
791
830
|
String(CACHE_FORMAT_VERSION),
|
|
792
831
|
frameworkVersion,
|
|
793
832
|
sourcePath
|
|
794
|
-
]).slice(0,
|
|
833
|
+
]).slice(0, HASH_LENGTH2)
|
|
795
834
|
};
|
|
796
835
|
}, existingEntries, listCacheDir = (directory) => {
|
|
797
836
|
try {
|
|
@@ -814,20 +853,20 @@ var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION = 1, HASH_LENGTH = 24,
|
|
|
814
853
|
}, publishCacheEntry = async (directory, fileName, pathHash, content) => {
|
|
815
854
|
try {
|
|
816
855
|
await mkdir(directory, { recursive: true });
|
|
817
|
-
const target =
|
|
856
|
+
const target = join4(directory, fileName);
|
|
818
857
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
819
858
|
await writeFile(temporary, content);
|
|
820
859
|
await rename(temporary, target);
|
|
821
860
|
const superseded = entriesForPath(directory, pathHash).filter((name) => name !== fileName);
|
|
822
861
|
existingEntries?.set(pathHash, [fileName]);
|
|
823
|
-
await Promise.all(superseded.map((name) => Bun.file(
|
|
862
|
+
await Promise.all(superseded.map((name) => Bun.file(join4(directory, name)).delete().catch(() => {
|
|
824
863
|
return;
|
|
825
864
|
})));
|
|
826
865
|
} catch {}
|
|
827
866
|
}, writeBoth = async (clientOutputPath, serverOutputPath, content) => {
|
|
828
867
|
await Promise.all([
|
|
829
|
-
mkdir(
|
|
830
|
-
mkdir(
|
|
868
|
+
mkdir(dirname3(clientOutputPath), { recursive: true }),
|
|
869
|
+
mkdir(dirname3(serverOutputPath), { recursive: true })
|
|
831
870
|
]);
|
|
832
871
|
await Promise.all([
|
|
833
872
|
write(clientOutputPath, content),
|
|
@@ -835,11 +874,38 @@ var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION = 1, HASH_LENGTH = 24,
|
|
|
835
874
|
]);
|
|
836
875
|
}, copyBoth = async (clientOutputPath, serverOutputPath, cachedPath) => {
|
|
837
876
|
await Promise.all([
|
|
838
|
-
mkdir(
|
|
839
|
-
mkdir(
|
|
877
|
+
mkdir(dirname3(clientOutputPath), { recursive: true }),
|
|
878
|
+
mkdir(dirname3(serverOutputPath), { recursive: true })
|
|
840
879
|
]);
|
|
841
880
|
copyFileSync(cachedPath, clientOutputPath);
|
|
842
881
|
copyFileSync(cachedPath, serverOutputPath);
|
|
882
|
+
}, QUOTES, MIRRORED_MODULE, IMPORT_CANDIDATE_SUFFIXES, isFilePath = (path) => {
|
|
883
|
+
try {
|
|
884
|
+
return statSync(path).isFile();
|
|
885
|
+
} catch {
|
|
886
|
+
return false;
|
|
887
|
+
}
|
|
888
|
+
}, resolveImportTarget = (sourceDir, specifier) => {
|
|
889
|
+
const base = resolve3(sourceDir, specifier);
|
|
890
|
+
return IMPORT_CANDIDATE_SUFFIXES.map((suffix) => `${base}${suffix}`).find(isFilePath) ?? base;
|
|
891
|
+
}, rewriteMirrorImports = (code, sourcePath) => {
|
|
892
|
+
const sourceDir = dirname3(sourcePath);
|
|
893
|
+
const rewrites = new Map;
|
|
894
|
+
for (const { path } of transpiler.scanImports(code)) {
|
|
895
|
+
if (!path.startsWith("./") && !path.startsWith("../"))
|
|
896
|
+
continue;
|
|
897
|
+
const target = resolveImportTarget(sourceDir, path);
|
|
898
|
+
if (!MIRRORED_MODULE.test(target))
|
|
899
|
+
continue;
|
|
900
|
+
const specifier = vueMirrorImport(sourcePath, path, target);
|
|
901
|
+
if (specifier !== path)
|
|
902
|
+
rewrites.set(path, specifier);
|
|
903
|
+
}
|
|
904
|
+
const replacements = Array.from(rewrites).flatMap(([written, mirrored]) => QUOTES.map((quote) => [
|
|
905
|
+
`${quote}${written}${quote}`,
|
|
906
|
+
`${quote}${mirrored}${quote}`
|
|
907
|
+
]));
|
|
908
|
+
return replacements.reduce((rewritten, [written, mirrored]) => rewritten.replaceAll(written, mirrored), code);
|
|
843
909
|
}, emitOne = async ({
|
|
844
910
|
clientOutputPath,
|
|
845
911
|
serverOutputPath,
|
|
@@ -849,12 +915,12 @@ var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION = 1, HASH_LENGTH = 24,
|
|
|
849
915
|
const key = cacheKey(sourcePath, sourceCode);
|
|
850
916
|
const directory = cacheDir();
|
|
851
917
|
const fileName = key ? `${key.path}-${key.content}.js` : null;
|
|
852
|
-
const cachedPath = fileName ?
|
|
918
|
+
const cachedPath = fileName ? join4(directory, fileName) : null;
|
|
853
919
|
if (cachedPath && existsSync3(cachedPath)) {
|
|
854
920
|
await copyBoth(clientOutputPath, serverOutputPath, cachedPath);
|
|
855
921
|
return;
|
|
856
922
|
}
|
|
857
|
-
const transpiledCode = transpiler.transformSync(sourceCode);
|
|
923
|
+
const transpiledCode = rewriteMirrorImports(transpiler.transformSync(sourceCode), sourcePath);
|
|
858
924
|
const withMap = transpiledCode + inlineLineMapComment(sourcePath, sourceCode, transpiledCode);
|
|
859
925
|
await writeBoth(clientOutputPath, serverOutputPath, withMap);
|
|
860
926
|
if (key && fileName) {
|
|
@@ -869,7 +935,18 @@ var CACHE_DIR_NAME = "vue-helpers", CACHE_FORMAT_VERSION = 1, HASH_LENGTH = 24,
|
|
|
869
935
|
var init_emitTsHelpers = __esm(() => {
|
|
870
936
|
init_chainInlineSourcemaps();
|
|
871
937
|
init_vueCompileCache();
|
|
938
|
+
init_vueModuleOutputPath();
|
|
872
939
|
transpiler = new Transpiler({ loader: "ts", target: "browser" });
|
|
940
|
+
QUOTES = ['"', "'"];
|
|
941
|
+
MIRRORED_MODULE = /\.(?:[cm]?[jt]s|vue)$/;
|
|
942
|
+
IMPORT_CANDIDATE_SUFFIXES = [
|
|
943
|
+
"",
|
|
944
|
+
".ts",
|
|
945
|
+
".js",
|
|
946
|
+
".mjs",
|
|
947
|
+
`${sep2}index.ts`,
|
|
948
|
+
`${sep2}index.js`
|
|
949
|
+
];
|
|
873
950
|
});
|
|
874
951
|
|
|
875
952
|
// src/islands/sourceMetadata.ts
|
|
@@ -950,8 +1027,8 @@ var init_sourceMetadata = __esm(() => {
|
|
|
950
1027
|
});
|
|
951
1028
|
|
|
952
1029
|
// src/utils/isFile.ts
|
|
953
|
-
import { statSync } from "fs";
|
|
954
|
-
var isFile = (path) =>
|
|
1030
|
+
import { statSync as statSync2 } from "fs";
|
|
1031
|
+
var isFile = (path) => statSync2(path, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
955
1032
|
var init_isFile = () => {};
|
|
956
1033
|
|
|
957
1034
|
// src/utils/vueCompiler.ts
|
|
@@ -972,19 +1049,19 @@ var createVueCompiler = async () => {
|
|
|
972
1049
|
};
|
|
973
1050
|
|
|
974
1051
|
// src/utils/runtimeMode.ts
|
|
975
|
-
var ENV_VAR = "NODE_ENV",
|
|
1052
|
+
var ENV_VAR = "NODE_ENV", readEnv = () => typeof process === "undefined" ? undefined : process.env?.[ENV_VAR], getNodeEnv = () => readEnv();
|
|
976
1053
|
|
|
977
1054
|
// src/build/stylePreprocessor.ts
|
|
978
1055
|
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
979
1056
|
import { readFile } from "fs/promises";
|
|
980
1057
|
import { createRequire } from "module";
|
|
981
1058
|
import {
|
|
982
|
-
dirname as
|
|
1059
|
+
dirname as dirname4,
|
|
983
1060
|
extname,
|
|
984
|
-
isAbsolute,
|
|
985
|
-
join as
|
|
986
|
-
relative,
|
|
987
|
-
resolve as
|
|
1061
|
+
isAbsolute as isAbsolute2,
|
|
1062
|
+
join as join5,
|
|
1063
|
+
relative as relative2,
|
|
1064
|
+
resolve as resolve4
|
|
988
1065
|
} from "path";
|
|
989
1066
|
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "url";
|
|
990
1067
|
var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleLanguage = (filePathOrLanguage) => {
|
|
@@ -1020,9 +1097,9 @@ ${message}`);
|
|
|
1020
1097
|
return requireOptionalPeer(specifier);
|
|
1021
1098
|
}
|
|
1022
1099
|
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
1023
|
-
|
|
1100
|
+
dirname4(filePath),
|
|
1024
1101
|
process.cwd(),
|
|
1025
|
-
...paths.map((path) =>
|
|
1102
|
+
...paths.map((path) => resolve4(process.cwd(), path))
|
|
1026
1103
|
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
1027
1104
|
pattern,
|
|
1028
1105
|
replacements: Array.isArray(value) ? value : [value]
|
|
@@ -1030,7 +1107,7 @@ ${message}`);
|
|
|
1030
1107
|
const cwd = process.cwd();
|
|
1031
1108
|
if (tsconfigAliasCache?.cwd === cwd)
|
|
1032
1109
|
return tsconfigAliasCache;
|
|
1033
|
-
const tsconfigPath =
|
|
1110
|
+
const tsconfigPath = resolve4(cwd, "tsconfig.json");
|
|
1034
1111
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
1035
1112
|
if (!existsSync4(tsconfigPath)) {
|
|
1036
1113
|
tsconfigAliasCache = empty;
|
|
@@ -1039,7 +1116,7 @@ ${message}`);
|
|
|
1039
1116
|
try {
|
|
1040
1117
|
const parsed = JSON.parse(stripJsonComments(readFileSync4(tsconfigPath, "utf-8")));
|
|
1041
1118
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
1042
|
-
const baseUrl =
|
|
1119
|
+
const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
|
|
1043
1120
|
tsconfigAliasCache = {
|
|
1044
1121
|
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
1045
1122
|
baseUrl,
|
|
@@ -1067,7 +1144,7 @@ ${message}`);
|
|
|
1067
1144
|
continue;
|
|
1068
1145
|
const wildcard = match[1] ?? "";
|
|
1069
1146
|
for (const replacement of alias.replacements) {
|
|
1070
|
-
targets.push(
|
|
1147
|
+
targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
|
|
1071
1148
|
}
|
|
1072
1149
|
}
|
|
1073
1150
|
return targets;
|
|
@@ -1081,21 +1158,21 @@ ${message}`);
|
|
|
1081
1158
|
const ext = extname(basePath);
|
|
1082
1159
|
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
1083
1160
|
`${basePath}${extension}`,
|
|
1084
|
-
|
|
1161
|
+
join5(basePath, `index${extension}`)
|
|
1085
1162
|
]);
|
|
1086
1163
|
if (language === "scss" || language === "sass") {
|
|
1087
1164
|
return paths.flatMap((path) => {
|
|
1088
|
-
const dir =
|
|
1165
|
+
const dir = dirname4(path);
|
|
1089
1166
|
const base = path.slice(dir.length + 1);
|
|
1090
|
-
return [path,
|
|
1167
|
+
return [path, join5(dir, `_${base}`)];
|
|
1091
1168
|
});
|
|
1092
1169
|
}
|
|
1093
1170
|
return paths;
|
|
1094
1171
|
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
1095
1172
|
const rawCandidates = [
|
|
1096
1173
|
...resolveAliasTargets(specifier, config),
|
|
1097
|
-
|
|
1098
|
-
...loadPaths.map((path) =>
|
|
1174
|
+
isAbsolute2(specifier) ? specifier : resolve4(fromDirectory, specifier),
|
|
1175
|
+
...loadPaths.map((path) => resolve4(path, specifier))
|
|
1099
1176
|
];
|
|
1100
1177
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
1101
1178
|
if (existsSync4(candidate))
|
|
@@ -1111,8 +1188,8 @@ ${message}`);
|
|
|
1111
1188
|
path: url.slice(0, markerIndex)
|
|
1112
1189
|
};
|
|
1113
1190
|
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
1114
|
-
const sourceDir =
|
|
1115
|
-
const entryDir =
|
|
1191
|
+
const sourceDir = dirname4(sourceFile);
|
|
1192
|
+
const entryDir = dirname4(entryFile);
|
|
1116
1193
|
if (sourceDir === entryDir)
|
|
1117
1194
|
return contents;
|
|
1118
1195
|
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
@@ -1120,15 +1197,15 @@ ${message}`);
|
|
|
1120
1197
|
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
1121
1198
|
return match;
|
|
1122
1199
|
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
1123
|
-
const rebased =
|
|
1200
|
+
const rebased = relative2(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
|
|
1124
1201
|
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
1125
1202
|
const nextQuote = quote || '"';
|
|
1126
1203
|
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
1127
1204
|
});
|
|
1128
1205
|
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
1129
|
-
if (specifier.startsWith(".") ||
|
|
1206
|
+
if (specifier.startsWith(".") || isAbsolute2(specifier) || isExternalCssUrl(specifier))
|
|
1130
1207
|
return match;
|
|
1131
|
-
const resolved = resolveImportPath(specifier,
|
|
1208
|
+
const resolved = resolveImportPath(specifier, dirname4(sourceFile), loadPaths, language, config);
|
|
1132
1209
|
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
1133
1210
|
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
1134
1211
|
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
@@ -1158,7 +1235,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1158
1235
|
}
|
|
1159
1236
|
return mod;
|
|
1160
1237
|
}, loadPostcssConfigFile = async (configPath) => {
|
|
1161
|
-
const resolved =
|
|
1238
|
+
const resolved = resolve4(process.cwd(), configPath);
|
|
1162
1239
|
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
1163
1240
|
const config = normalizePostcssModule(loaded);
|
|
1164
1241
|
const value = typeof config === "function" ? await config({
|
|
@@ -1218,9 +1295,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1218
1295
|
return result.css;
|
|
1219
1296
|
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
1220
1297
|
canonicalize(specifier, options) {
|
|
1221
|
-
const fromDirectory = options.containingUrl ?
|
|
1298
|
+
const fromDirectory = options.containingUrl ? dirname4(fileURLToPath(options.containingUrl)) : dirname4(entryFile);
|
|
1222
1299
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
1223
|
-
return resolved ? new URL(pathToFileURL2(
|
|
1300
|
+
return resolved ? new URL(pathToFileURL2(resolve4(resolved)).href) : null;
|
|
1224
1301
|
},
|
|
1225
1302
|
load(canonicalUrl) {
|
|
1226
1303
|
const filePath = fileURLToPath(canonicalUrl);
|
|
@@ -1237,9 +1314,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1237
1314
|
install(less, pluginManager) {
|
|
1238
1315
|
const baseManager = new less.FileManager;
|
|
1239
1316
|
const manager = Object.create(baseManager);
|
|
1240
|
-
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename,
|
|
1317
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
|
|
1241
1318
|
manager.loadFile = async (filename, currentDirectory) => {
|
|
1242
|
-
const resolved = resolveImportPath(filename,
|
|
1319
|
+
const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
|
|
1243
1320
|
if (!resolved) {
|
|
1244
1321
|
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
1245
1322
|
}
|
|
@@ -1276,17 +1353,17 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1276
1353
|
const stylusDeps = renderer.deps?.();
|
|
1277
1354
|
if (Array.isArray(stylusDeps)) {
|
|
1278
1355
|
for (const dep of stylusDeps)
|
|
1279
|
-
deps.add(
|
|
1356
|
+
deps.add(resolve4(dep));
|
|
1280
1357
|
}
|
|
1281
1358
|
}
|
|
1282
1359
|
resolveCss(css ?? "");
|
|
1283
1360
|
});
|
|
1284
1361
|
});
|
|
1285
1362
|
}, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
|
|
1286
|
-
const key =
|
|
1363
|
+
const key = resolve4(entry);
|
|
1287
1364
|
const stripped = new Set;
|
|
1288
1365
|
for (const dep of deps) {
|
|
1289
|
-
const resolved =
|
|
1366
|
+
const resolved = resolve4(dep);
|
|
1290
1367
|
if (resolved !== key)
|
|
1291
1368
|
stripped.add(resolved);
|
|
1292
1369
|
}
|
|
@@ -1314,7 +1391,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1314
1391
|
loadPaths,
|
|
1315
1392
|
style: "expanded",
|
|
1316
1393
|
syntax: language === "sass" ? "indented" : "scss",
|
|
1317
|
-
url: new URL(pathToFileURL2(
|
|
1394
|
+
url: new URL(pathToFileURL2(resolve4(filePath)).href)
|
|
1318
1395
|
});
|
|
1319
1396
|
const css = await runPostcss(result.css, filePath, config);
|
|
1320
1397
|
const loadedUrls = result.loadedUrls ?? [];
|
|
@@ -1322,7 +1399,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
1322
1399
|
if (url.protocol !== "file:")
|
|
1323
1400
|
continue;
|
|
1324
1401
|
const dep = fileURLToPath(url);
|
|
1325
|
-
if (
|
|
1402
|
+
if (resolve4(dep) === resolve4(filePath))
|
|
1326
1403
|
continue;
|
|
1327
1404
|
deps.add(dep);
|
|
1328
1405
|
}
|
|
@@ -1423,7 +1500,7 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1423
1500
|
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
1424
1501
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
1425
1502
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
1426
|
-
requireFromCwd = createRequire(
|
|
1503
|
+
requireFromCwd = createRequire(join5(process.cwd(), "package.json"));
|
|
1427
1504
|
styleDependencyGraph = new Map;
|
|
1428
1505
|
styleOutputHashes = new Map;
|
|
1429
1506
|
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
@@ -1431,7 +1508,7 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
1431
1508
|
|
|
1432
1509
|
// src/build/inlineCssImports.ts
|
|
1433
1510
|
import { readFileSync as readFileSync5, realpathSync } from "fs";
|
|
1434
|
-
import { dirname as
|
|
1511
|
+
import { dirname as dirname5, resolve as resolve5 } from "path";
|
|
1435
1512
|
var inlineCssImports = (cssContent, cssFilePath, visited = new Set) => {
|
|
1436
1513
|
const resolved = realpathSync(cssFilePath);
|
|
1437
1514
|
if (visited.has(resolved))
|
|
@@ -1439,7 +1516,7 @@ var inlineCssImports = (cssContent, cssFilePath, visited = new Set) => {
|
|
|
1439
1516
|
visited.add(resolved);
|
|
1440
1517
|
const importRegex = /@import\s+(?:url\(\s*)?(['"])(\.{1,2}\/[^'"]+)\1\s*\)?\s*;?/g;
|
|
1441
1518
|
return cssContent.replace(importRegex, (match, _quote, relPath) => {
|
|
1442
|
-
const importedPath =
|
|
1519
|
+
const importedPath = resolve5(dirname5(cssFilePath), relPath);
|
|
1443
1520
|
if (!isFile(importedPath))
|
|
1444
1521
|
return match;
|
|
1445
1522
|
const importedContent = readFileSync5(importedPath, "utf-8");
|
|
@@ -1452,7 +1529,7 @@ var init_inlineCssImports = __esm(() => {
|
|
|
1452
1529
|
|
|
1453
1530
|
// src/build/compileVueSfc.ts
|
|
1454
1531
|
import { existsSync as existsSync5, readFileSync as readFileSync6, realpathSync as realpathSync2 } from "fs";
|
|
1455
|
-
import { dirname as
|
|
1532
|
+
import { dirname as dirname6, join as join6, relative as relative3, resolve as resolve6 } from "path";
|
|
1456
1533
|
var {Transpiler: Transpiler2 } = globalThis.Bun;
|
|
1457
1534
|
var transpiler2, toJs = (filePath, sourceDir) => {
|
|
1458
1535
|
if (filePath.endsWith(".vue"))
|
|
@@ -1461,15 +1538,15 @@ var transpiler2, toJs = (filePath, sourceDir) => {
|
|
|
1461
1538
|
return filePath.replace(/\.ts$/, ".js");
|
|
1462
1539
|
if (isStylePath(filePath)) {
|
|
1463
1540
|
if (sourceDir && (filePath.startsWith("./") || filePath.startsWith("../"))) {
|
|
1464
|
-
return
|
|
1541
|
+
return resolve6(sourceDir, filePath);
|
|
1465
1542
|
}
|
|
1466
1543
|
return filePath;
|
|
1467
1544
|
}
|
|
1468
1545
|
if (sourceDir && (filePath.startsWith("./") || filePath.startsWith("../"))) {
|
|
1469
|
-
const directTs =
|
|
1546
|
+
const directTs = resolve6(sourceDir, `${filePath}.ts`);
|
|
1470
1547
|
if (existsSync5(directTs))
|
|
1471
1548
|
return `${filePath}.js`;
|
|
1472
|
-
const indexedTs =
|
|
1549
|
+
const indexedTs = resolve6(sourceDir, filePath, "index.ts");
|
|
1473
1550
|
if (existsSync5(indexedTs))
|
|
1474
1551
|
return `${filePath}/index.js`;
|
|
1475
1552
|
}
|
|
@@ -1517,7 +1594,7 @@ const ${localName} = (source) => ${importedName}(
|
|
|
1517
1594
|
: { ...source, loader: () => __absoluteResolveAsyncVueComponent(source.loader) },
|
|
1518
1595
|
);`;
|
|
1519
1596
|
return code.replace(vueImportRegex, `import { ${specifiers.join(", ")} } from 'vue';${wrapper}`);
|
|
1520
|
-
}, rewriteRelativeImports = (code, sourceDir) => code.replace(/(['"])(\.{1,2}\/[^'"]+)(['"])/g, (_, quoteStart, relativeImport, quoteEnd) => `${quoteStart}${toJs(relativeImport, sourceDir)}${quoteEnd}`), compileVueSfc = async ({
|
|
1597
|
+
}, toOutputImport = (specifier, sourceDir) => specifier.startsWith("./") || specifier.startsWith("../") ? vueMirrorImport(join6(sourceDir, "__importer__"), specifier, resolve6(sourceDir, specifier)) : specifier, rewriteRelativeImports = (code, sourceDir) => code.replace(/(['"])(\.{1,2}\/[^'"]+)(['"])/g, (_, quoteStart, relativeImport, quoteEnd) => `${quoteStart}${toOutputImport(toJs(relativeImport, sourceDir), sourceDir)}${quoteEnd}`), compileVueSfc = async ({
|
|
1521
1598
|
clientOutputPath,
|
|
1522
1599
|
componentId,
|
|
1523
1600
|
hmrId,
|
|
@@ -1557,7 +1634,7 @@ const ${localName} = (source) => ${importedName}(
|
|
|
1557
1634
|
typeDepHashes[dep] = hashContent(readFileSync6(dep, "utf-8"));
|
|
1558
1635
|
}
|
|
1559
1636
|
const strippedScript = stripExports(compiledScript.content);
|
|
1560
|
-
const sourceDir =
|
|
1637
|
+
const sourceDir = dirname6(sourceFilePath);
|
|
1561
1638
|
const transpiledScript = rewriteRelativeImports(transpiler2.transformSync(strippedScript), sourceDir);
|
|
1562
1639
|
const generateRenderFunction = (ssr) => {
|
|
1563
1640
|
const rendered = compiler.compileTemplate({
|
|
@@ -1612,7 +1689,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
1612
1689
|
let result = code;
|
|
1613
1690
|
for (const [bareImport, paths] of packageImportRewrites) {
|
|
1614
1691
|
const targetPath = mode === "server" ? paths.server : paths.client;
|
|
1615
|
-
let rel =
|
|
1692
|
+
let rel = relative3(dirname6(outputPath), targetPath).replace(/\\/g, "/");
|
|
1616
1693
|
if (!rel.startsWith("."))
|
|
1617
1694
|
rel = `./${rel}`;
|
|
1618
1695
|
result = result.replaceAll(bareImport, rel);
|
|
@@ -1648,6 +1725,7 @@ var init_compileVueSfc = __esm(() => {
|
|
|
1648
1725
|
init_stylePreprocessor();
|
|
1649
1726
|
init_inlineCssImports();
|
|
1650
1727
|
init_vueCompileCache();
|
|
1728
|
+
init_vueModuleOutputPath();
|
|
1651
1729
|
transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
|
|
1652
1730
|
});
|
|
1653
1731
|
|