nuxt-nightly 4.3.0-29436247.ecea7a86 → 4.3.0-29436330.9aa80014
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/index.mjs +340 -273
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -855,212 +855,227 @@ const PageMetaPlugin = (options = {}) => createUnplugin(() => {
|
|
|
855
855
|
transformInclude(id) {
|
|
856
856
|
return !!parseMacroQuery(id).macro;
|
|
857
857
|
},
|
|
858
|
-
transform
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
const hasMacro = HAS_MACRO_RE.test(code);
|
|
873
|
-
const imports = findStaticImports(code);
|
|
874
|
-
const scriptImport = imports.find((i) => parseMacroQuery(i.specifier).type === "script");
|
|
875
|
-
if (scriptImport) {
|
|
876
|
-
const reorderedQuery = rewriteQuery(scriptImport.specifier);
|
|
877
|
-
const quotedSpecifier = getQuotedSpecifier(scriptImport.code)?.replace(scriptImport.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery);
|
|
878
|
-
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`);
|
|
879
|
-
return result();
|
|
880
|
-
}
|
|
881
|
-
const currentExports = findExports(code);
|
|
882
|
-
for (const match of currentExports) {
|
|
883
|
-
if (match.type !== "default" || !match.specifier) {
|
|
884
|
-
continue;
|
|
885
|
-
}
|
|
886
|
-
const reorderedQuery = rewriteQuery(match.specifier);
|
|
887
|
-
const quotedSpecifier = getQuotedSpecifier(match.code)?.replace(match.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery);
|
|
888
|
-
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`);
|
|
889
|
-
return result();
|
|
890
|
-
}
|
|
891
|
-
if (!hasMacro && !code.includes("export { default }") && !code.includes("__nuxt_page_meta")) {
|
|
892
|
-
if (!code) {
|
|
893
|
-
s.append(options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
894
|
-
const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
895
|
-
logger.error(`The file \`${pathname}\` is not a valid page as it has no content.`);
|
|
896
|
-
} else {
|
|
897
|
-
s.overwrite(0, code.length, options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
898
|
-
}
|
|
899
|
-
return result();
|
|
900
|
-
}
|
|
901
|
-
const importMap = /* @__PURE__ */ new Map();
|
|
902
|
-
const addedImports = /* @__PURE__ */ new Set();
|
|
903
|
-
for (const i of imports) {
|
|
904
|
-
const parsed = parseStaticImport(i);
|
|
905
|
-
for (const name of [
|
|
906
|
-
parsed.defaultImport,
|
|
907
|
-
...Object.values(parsed.namedImports || {}),
|
|
908
|
-
parsed.namespacedImport
|
|
909
|
-
].filter(Boolean)) {
|
|
910
|
-
importMap.set(name, i);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
function isStaticIdentifier(name) {
|
|
914
|
-
return !!(name && importMap.has(name));
|
|
915
|
-
}
|
|
916
|
-
function addImport(name) {
|
|
917
|
-
if (!isStaticIdentifier(name)) {
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
const importValue = importMap.get(name).code.trim();
|
|
921
|
-
if (!addedImports.has(importValue)) {
|
|
922
|
-
addedImports.add(importValue);
|
|
858
|
+
transform: {
|
|
859
|
+
filter: {
|
|
860
|
+
id: {
|
|
861
|
+
exclude: [/(?:\?|%3F).*type=(?:style|template)/]
|
|
862
|
+
},
|
|
863
|
+
code: {
|
|
864
|
+
include: [
|
|
865
|
+
HAS_MACRO_RE,
|
|
866
|
+
/\bfrom\s+["'][^"'?]*\?[^"']*type=script[^"']*["']/,
|
|
867
|
+
/export\s+\{\s*default\s*\}\s+from\s+["'][^"'?]*\?[^"']*type=script[^"']*["']/,
|
|
868
|
+
/^(?!.*__nuxt_page_meta)(?!.*export\s+\{\s*default\s*\})(?!.*\bdefinePageMeta\s*\()[\s\S]*$/
|
|
869
|
+
]
|
|
923
870
|
}
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
const codeSectionKey = `${resolveStart(node)}-${resolveEnd(node)}`;
|
|
929
|
-
if (addedDeclarations.has(codeSectionKey)) {
|
|
871
|
+
},
|
|
872
|
+
handler(code, id) {
|
|
873
|
+
const query = parseMacroQuery(id);
|
|
874
|
+
if (query.type && query.type !== "script") {
|
|
930
875
|
return;
|
|
931
876
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
const declaration = scopeTracker.getDeclaration(name);
|
|
940
|
-
if (declaration && declaration !== node) {
|
|
941
|
-
processDeclaration(declaration);
|
|
877
|
+
const s = new MagicString(code);
|
|
878
|
+
function result() {
|
|
879
|
+
if (s.hasChanged()) {
|
|
880
|
+
return {
|
|
881
|
+
code: s.toString(),
|
|
882
|
+
map: options.sourcemap ? s.generateMap({ hires: true }) : void 0
|
|
883
|
+
};
|
|
942
884
|
}
|
|
943
885
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
if (node.type === "AwaitExpression") {
|
|
958
|
-
logger.error(`Await expressions are not supported in definePageMeta. File: '${id}'`);
|
|
959
|
-
throw new Error("await in definePageMeta");
|
|
960
|
-
}
|
|
961
|
-
if (isBindingIdentifier(node, parent) || node.type !== "Identifier") {
|
|
962
|
-
return;
|
|
963
|
-
}
|
|
964
|
-
addImportOrDeclaration(node.name, scopeTrackerNode);
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
} else if (scopeTrackerNode?.type === "Function") {
|
|
969
|
-
if (scopeTrackerNode.node.type === "ArrowFunctionExpression") {
|
|
970
|
-
return;
|
|
886
|
+
const hasMacro = HAS_MACRO_RE.test(code);
|
|
887
|
+
const imports = findStaticImports(code);
|
|
888
|
+
const scriptImport = imports.find((i) => parseMacroQuery(i.specifier).type === "script");
|
|
889
|
+
if (scriptImport) {
|
|
890
|
+
const reorderedQuery = rewriteQuery(scriptImport.specifier);
|
|
891
|
+
const quotedSpecifier = getQuotedSpecifier(scriptImport.code)?.replace(scriptImport.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery);
|
|
892
|
+
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`);
|
|
893
|
+
return result();
|
|
894
|
+
}
|
|
895
|
+
const currentExports = findExports(code);
|
|
896
|
+
for (const match of currentExports) {
|
|
897
|
+
if (match.type !== "default" || !match.specifier) {
|
|
898
|
+
continue;
|
|
971
899
|
}
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
900
|
+
const reorderedQuery = rewriteQuery(match.specifier);
|
|
901
|
+
const quotedSpecifier = getQuotedSpecifier(match.code)?.replace(match.specifier, reorderedQuery) ?? JSON.stringify(reorderedQuery);
|
|
902
|
+
s.overwrite(0, code.length, `export { default } from ${quotedSpecifier}`);
|
|
903
|
+
return result();
|
|
904
|
+
}
|
|
905
|
+
if (!hasMacro && !code.includes("export { default }") && !code.includes("__nuxt_page_meta")) {
|
|
906
|
+
if (!code) {
|
|
907
|
+
s.append(options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
908
|
+
const { pathname } = parseURL(decodeURIComponent(pathToFileURL(id).href));
|
|
909
|
+
logger.error(`The file \`${pathname}\` is not a valid page as it has no content.`);
|
|
910
|
+
} else {
|
|
911
|
+
s.overwrite(0, code.length, options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
975
912
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
913
|
+
return result();
|
|
914
|
+
}
|
|
915
|
+
const importMap = /* @__PURE__ */ new Map();
|
|
916
|
+
const addedImports = /* @__PURE__ */ new Set();
|
|
917
|
+
for (const i of imports) {
|
|
918
|
+
const parsed = parseStaticImport(i);
|
|
919
|
+
for (const name of [
|
|
920
|
+
parsed.defaultImport,
|
|
921
|
+
...Object.values(parsed.namedImports || {}),
|
|
922
|
+
parsed.namespacedImport
|
|
923
|
+
].filter(Boolean)) {
|
|
924
|
+
importMap.set(name, i);
|
|
980
925
|
}
|
|
981
926
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
scopeTracker,
|
|
985
|
-
parseOptions: {
|
|
986
|
-
lang: query.lang ?? "ts"
|
|
927
|
+
function isStaticIdentifier(name) {
|
|
928
|
+
return !!(name && importMap.has(name));
|
|
987
929
|
}
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
let instances = 0;
|
|
991
|
-
walk(ast, {
|
|
992
|
-
scopeTracker,
|
|
993
|
-
enter: (node) => {
|
|
994
|
-
if (node.type !== "CallExpression" || node.callee.type !== "Identifier") {
|
|
930
|
+
function addImport(name) {
|
|
931
|
+
if (!isStaticIdentifier(name)) {
|
|
995
932
|
return;
|
|
996
933
|
}
|
|
997
|
-
|
|
998
|
-
|
|
934
|
+
const importValue = importMap.get(name).code.trim();
|
|
935
|
+
if (!addedImports.has(importValue)) {
|
|
936
|
+
addedImports.add(importValue);
|
|
999
937
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
938
|
+
}
|
|
939
|
+
const declarationNodes = [];
|
|
940
|
+
const addedDeclarations = /* @__PURE__ */ new Set();
|
|
941
|
+
function addDeclaration(node) {
|
|
942
|
+
const codeSectionKey = `${resolveStart(node)}-${resolveEnd(node)}`;
|
|
943
|
+
if (addedDeclarations.has(codeSectionKey)) {
|
|
1003
944
|
return;
|
|
1004
945
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
946
|
+
addedDeclarations.add(codeSectionKey);
|
|
947
|
+
declarationNodes.push(node);
|
|
948
|
+
}
|
|
949
|
+
function addImportOrDeclaration(name, node) {
|
|
950
|
+
if (isStaticIdentifier(name)) {
|
|
951
|
+
addImport(name);
|
|
952
|
+
} else {
|
|
953
|
+
const declaration = scopeTracker.getDeclaration(name);
|
|
954
|
+
if (declaration && declaration !== node) {
|
|
955
|
+
processDeclaration(declaration);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
const scopeTracker = new ScopeTracker({
|
|
960
|
+
preserveExitedScopes: true
|
|
961
|
+
});
|
|
962
|
+
function processDeclaration(scopeTrackerNode) {
|
|
963
|
+
if (scopeTrackerNode?.type === "Variable") {
|
|
964
|
+
addDeclaration(scopeTrackerNode);
|
|
965
|
+
for (const decl of scopeTrackerNode.variableNode.declarations) {
|
|
966
|
+
if (!decl.init) {
|
|
967
|
+
continue;
|
|
1023
968
|
}
|
|
969
|
+
walk(decl.init, {
|
|
970
|
+
enter: (node, parent) => {
|
|
971
|
+
if (node.type === "AwaitExpression") {
|
|
972
|
+
logger.error(`Await expressions are not supported in definePageMeta. File: '${id}'`);
|
|
973
|
+
throw new Error("await in definePageMeta");
|
|
974
|
+
}
|
|
975
|
+
if (isBindingIdentifier(node, parent) || node.type !== "Identifier") {
|
|
976
|
+
return;
|
|
977
|
+
}
|
|
978
|
+
addImportOrDeclaration(node.name, scopeTrackerNode);
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
} else if (scopeTrackerNode?.type === "Function") {
|
|
983
|
+
if (scopeTrackerNode.node.type === "ArrowFunctionExpression") {
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
const name = scopeTrackerNode.node.id?.name;
|
|
987
|
+
if (!name) {
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
addDeclaration(scopeTrackerNode);
|
|
991
|
+
const undeclaredIdentifiers = getUndeclaredIdentifiersInFunction(scopeTrackerNode.node);
|
|
992
|
+
for (const name2 of undeclaredIdentifiers) {
|
|
993
|
+
addImportOrDeclaration(name2);
|
|
1024
994
|
}
|
|
1025
995
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
996
|
+
}
|
|
997
|
+
const { program: ast } = parseAndWalk(code, id, {
|
|
998
|
+
scopeTracker,
|
|
999
|
+
parseOptions: {
|
|
1000
|
+
lang: query.lang ?? "ts"
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
scopeTracker.freeze();
|
|
1004
|
+
let instances = 0;
|
|
1005
|
+
walk(ast, {
|
|
1006
|
+
scopeTracker,
|
|
1007
|
+
enter: (node) => {
|
|
1008
|
+
if (node.type !== "CallExpression" || node.callee.type !== "Identifier") {
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
if (!("name" in node.callee) || node.callee.name !== "definePageMeta") {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
instances++;
|
|
1015
|
+
const meta = node.arguments[0];
|
|
1016
|
+
if (!meta) {
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
const metaCode = code.slice(meta.start, meta.end);
|
|
1020
|
+
const m = new MagicString(metaCode);
|
|
1021
|
+
if (meta.type === "ObjectExpression") {
|
|
1022
|
+
for (let i = 0; i < meta.properties.length; i++) {
|
|
1023
|
+
const prop = meta.properties[i];
|
|
1024
|
+
if (prop.type === "Property" && prop.key.type === "Identifier" && options.extractedKeys?.includes(prop.key.name)) {
|
|
1025
|
+
const { serializable } = isSerializable(metaCode, prop.value);
|
|
1026
|
+
if (!serializable) {
|
|
1027
|
+
continue;
|
|
1028
|
+
}
|
|
1029
|
+
const nextProperty = meta.properties[i + 1];
|
|
1030
|
+
if (nextProperty) {
|
|
1031
|
+
m.overwrite(prop.start - meta.start, nextProperty.start - meta.start, "");
|
|
1032
|
+
} else if (code[prop.end] === ",") {
|
|
1033
|
+
m.overwrite(prop.start - meta.start, prop.end - meta.start + 1, "");
|
|
1034
|
+
} else {
|
|
1035
|
+
m.overwrite(prop.start - meta.start, prop.end - meta.start, "");
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1032
1038
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1039
|
+
}
|
|
1040
|
+
const definePageMetaScope = scopeTracker.getCurrentScope();
|
|
1041
|
+
walk(meta, {
|
|
1042
|
+
scopeTracker,
|
|
1043
|
+
enter(node2, parent) {
|
|
1044
|
+
if (isBindingIdentifier(node2, parent) || node2.type !== "Identifier") {
|
|
1036
1045
|
return;
|
|
1037
1046
|
}
|
|
1047
|
+
const declaration = scopeTracker.getDeclaration(node2.name);
|
|
1048
|
+
if (declaration) {
|
|
1049
|
+
if (declaration.isUnderScope(definePageMetaScope) && (scopeTracker.isCurrentScopeUnder(declaration.scope) || resolveStart(declaration) < node2.start)) {
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
if (isStaticIdentifier(node2.name)) {
|
|
1054
|
+
addImport(node2.name);
|
|
1055
|
+
} else if (declaration) {
|
|
1056
|
+
processDeclaration(declaration);
|
|
1057
|
+
}
|
|
1038
1058
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
const importStatements = Array.from(addedImports).join("\n");
|
|
1047
|
-
const declarations = declarationNodes.sort((a, b) => resolveStart(a) - resolveStart(b)).map((node2) => code.slice(resolveStart(node2), resolveEnd(node2))).join("\n");
|
|
1048
|
-
const extracted = [
|
|
1049
|
-
importStatements,
|
|
1050
|
-
declarations,
|
|
1051
|
-
`const __nuxt_page_meta = ${m.toString() || "null"}
|
|
1059
|
+
});
|
|
1060
|
+
const importStatements = Array.from(addedImports).join("\n");
|
|
1061
|
+
const declarations = declarationNodes.sort((a, b) => resolveStart(a) - resolveStart(b)).map((node2) => code.slice(resolveStart(node2), resolveEnd(node2))).join("\n");
|
|
1062
|
+
const extracted = [
|
|
1063
|
+
importStatements,
|
|
1064
|
+
declarations,
|
|
1065
|
+
`const __nuxt_page_meta = ${m.toString() || "null"}
|
|
1052
1066
|
export default __nuxt_page_meta` + (options.dev ? CODE_HMR : "")
|
|
1053
|
-
|
|
1054
|
-
|
|
1067
|
+
].join("\n");
|
|
1068
|
+
s.overwrite(0, code.length, extracted.trim());
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
if (instances > 1) {
|
|
1072
|
+
throw new Error("Multiple `definePageMeta` calls are not supported. File: " + id.replace(/\?.+$/, ""));
|
|
1055
1073
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
if (!s.hasChanged() && !code.includes("__nuxt_page_meta")) {
|
|
1061
|
-
s.overwrite(0, code.length, options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
1074
|
+
if (!s.hasChanged() && !code.includes("__nuxt_page_meta")) {
|
|
1075
|
+
s.overwrite(0, code.length, options.dev ? CODE_DEV_EMPTY + CODE_HMR : CODE_EMPTY);
|
|
1076
|
+
}
|
|
1077
|
+
return result();
|
|
1062
1078
|
}
|
|
1063
|
-
return result();
|
|
1064
1079
|
},
|
|
1065
1080
|
vite: {
|
|
1066
1081
|
handleHotUpdate: {
|
|
@@ -2796,82 +2811,99 @@ function TransformPlugin$1(nuxt, options) {
|
|
|
2796
2811
|
];
|
|
2797
2812
|
});
|
|
2798
2813
|
}
|
|
2799
|
-
return createUnplugin(() =>
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2814
|
+
return createUnplugin(() => [
|
|
2815
|
+
{
|
|
2816
|
+
name: "nuxt:components:imports-wrapper",
|
|
2817
|
+
enforce: "post",
|
|
2818
|
+
transformInclude(id) {
|
|
2819
|
+
id = normalize(id);
|
|
2820
|
+
return id.startsWith("virtual:") || id.startsWith("\0virtual:") || id.startsWith(nuxt.options.buildDir) || !isIgnored(id, void 0, nuxt);
|
|
2821
|
+
},
|
|
2822
|
+
transform: {
|
|
2823
|
+
filter: {
|
|
2824
|
+
id: COMPONENT_QUERY_RE
|
|
2825
|
+
},
|
|
2826
|
+
handler(_code, id) {
|
|
2827
|
+
const { search } = parseURL(id);
|
|
2828
|
+
const query = parseQuery$1(search);
|
|
2829
|
+
const mode = query.nuxt_component;
|
|
2830
|
+
const bare = id.replace(/\?.*/, "");
|
|
2831
|
+
const componentExport = query.nuxt_component_export || "default";
|
|
2832
|
+
const exportWording = componentExport === "default" ? "export default" : `export const ${componentExport} =`;
|
|
2833
|
+
if (mode === "async") {
|
|
2834
|
+
return {
|
|
2835
|
+
code: [
|
|
2836
|
+
'import { defineAsyncComponent } from "vue"',
|
|
2837
|
+
`${exportWording} defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => r[${JSON.stringify(componentExport)}] || r.default || r))`
|
|
2838
|
+
].join("\n"),
|
|
2839
|
+
map: null
|
|
2840
|
+
};
|
|
2841
|
+
} else if (mode === "client") {
|
|
2842
|
+
return {
|
|
2843
|
+
code: [
|
|
2844
|
+
genImport(bare, [{ name: componentExport, as: "__component" }]),
|
|
2845
|
+
'import { createClientOnly } from "#app/components/client-only"',
|
|
2846
|
+
`${exportWording} createClientOnly(__component)`
|
|
2847
|
+
].join("\n"),
|
|
2848
|
+
map: null
|
|
2849
|
+
};
|
|
2850
|
+
} else if (mode === "client,async") {
|
|
2851
|
+
return {
|
|
2852
|
+
code: [
|
|
2853
|
+
'import { defineAsyncComponent } from "vue"',
|
|
2854
|
+
'import { createClientOnly } from "#app/components/client-only"',
|
|
2855
|
+
`${exportWording} defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r[${JSON.stringify(componentExport)}] || r.default || r)))`
|
|
2856
|
+
].join("\n"),
|
|
2857
|
+
map: null
|
|
2858
|
+
};
|
|
2859
|
+
} else if (mode === "server" || mode === "server,async") {
|
|
2860
|
+
const name = query.nuxt_component_name;
|
|
2861
|
+
return {
|
|
2862
|
+
code: [
|
|
2863
|
+
`import { createServerComponent } from ${JSON.stringify(options.serverComponentRuntime)}`,
|
|
2864
|
+
`${exportWording} createServerComponent(${JSON.stringify(name)})`
|
|
2865
|
+
].join("\n"),
|
|
2866
|
+
map: null
|
|
2867
|
+
};
|
|
2868
|
+
} else {
|
|
2869
|
+
throw new Error(`Unknown component mode: ${mode}, this might be an internal bug of Nuxt.`);
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2805
2873
|
},
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
}
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
}
|
|
2831
|
-
} else if (mode === "client,async") {
|
|
2832
|
-
return {
|
|
2833
|
-
code: [
|
|
2834
|
-
'import { defineAsyncComponent } from "vue"',
|
|
2835
|
-
'import { createClientOnly } from "#app/components/client-only"',
|
|
2836
|
-
`${exportWording} defineAsyncComponent(() => import(${JSON.stringify(bare)}).then(r => createClientOnly(r[${JSON.stringify(componentExport)}] || r.default || r)))`
|
|
2837
|
-
].join("\n"),
|
|
2838
|
-
map: null
|
|
2839
|
-
};
|
|
2840
|
-
} else if (mode === "server" || mode === "server,async") {
|
|
2841
|
-
const name = query.nuxt_component_name;
|
|
2874
|
+
{
|
|
2875
|
+
name: "nuxt:components:imports-alias",
|
|
2876
|
+
enforce: "post",
|
|
2877
|
+
transformInclude(id) {
|
|
2878
|
+
id = normalize(id);
|
|
2879
|
+
return id.startsWith("virtual:") || id.startsWith("\0virtual:") || id.startsWith(nuxt.options.buildDir) || !isIgnored(id, void 0, nuxt);
|
|
2880
|
+
},
|
|
2881
|
+
transform: {
|
|
2882
|
+
filter: {
|
|
2883
|
+
code: /#components/
|
|
2884
|
+
},
|
|
2885
|
+
async handler(code, id) {
|
|
2886
|
+
const pkg = isAbsolute(id) && /node_modules[\\/](?!\.virtual)/.test(id) ? await readPackage(id, { try: true }) : void 0;
|
|
2887
|
+
if (isObject(pkg) && isObject(pkg.imports) && Object.hasOwn(pkg.imports, "#components")) {
|
|
2888
|
+
return;
|
|
2889
|
+
}
|
|
2890
|
+
componentUnimport.modifyDynamicImports((imports) => {
|
|
2891
|
+
imports.length = 0;
|
|
2892
|
+
imports.push(...getComponentsImports());
|
|
2893
|
+
return imports;
|
|
2894
|
+
});
|
|
2895
|
+
const result = await componentUnimport.injectImports(code, id, { autoImport: false, transformVirtualImports: true });
|
|
2896
|
+
if (!result) {
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2842
2899
|
return {
|
|
2843
|
-
code:
|
|
2844
|
-
|
|
2845
|
-
`${exportWording} createServerComponent(${JSON.stringify(name)})`
|
|
2846
|
-
].join("\n"),
|
|
2847
|
-
map: null
|
|
2900
|
+
code: result.code,
|
|
2901
|
+
map: nuxt.options.sourcemap.server || nuxt.options.sourcemap.client ? result.s.generateMap({ hires: true }) : void 0
|
|
2848
2902
|
};
|
|
2849
|
-
} else {
|
|
2850
|
-
throw new Error(`Unknown component mode: ${mode}, this might be an internal bug of Nuxt.`);
|
|
2851
2903
|
}
|
|
2852
2904
|
}
|
|
2853
|
-
if (!code.includes("#components")) {
|
|
2854
|
-
return;
|
|
2855
|
-
}
|
|
2856
|
-
const pkg = isAbsolute(id) && /node_modules[\\/](?!\.virtual)/.test(id) ? await readPackage(id, { try: true }) : void 0;
|
|
2857
|
-
if (isObject(pkg) && isObject(pkg.imports) && Object.hasOwn(pkg.imports, "#components")) {
|
|
2858
|
-
return;
|
|
2859
|
-
}
|
|
2860
|
-
componentUnimport.modifyDynamicImports((imports) => {
|
|
2861
|
-
imports.length = 0;
|
|
2862
|
-
imports.push(...getComponentsImports());
|
|
2863
|
-
return imports;
|
|
2864
|
-
});
|
|
2865
|
-
const result = await componentUnimport.injectImports(code, id, { autoImport: false, transformVirtualImports: true });
|
|
2866
|
-
if (!result) {
|
|
2867
|
-
return;
|
|
2868
|
-
}
|
|
2869
|
-
return {
|
|
2870
|
-
code: result.code,
|
|
2871
|
-
map: nuxt.options.sourcemap.server || nuxt.options.sourcemap.client ? result.s.generateMap({ hires: true }) : void 0
|
|
2872
|
-
};
|
|
2873
2905
|
}
|
|
2874
|
-
|
|
2906
|
+
]);
|
|
2875
2907
|
}
|
|
2876
2908
|
|
|
2877
2909
|
const SSR_RENDER_RE = /ssrRenderComponent/;
|
|
@@ -3736,7 +3768,9 @@ const importsModule = defineNuxtModule({
|
|
|
3736
3768
|
});
|
|
3737
3769
|
nuxt.options.alias["#imports"] = join(nuxt.options.buildDir, "imports");
|
|
3738
3770
|
addBuildPlugin(TransformPlugin({
|
|
3739
|
-
ctx: {
|
|
3771
|
+
ctx: {
|
|
3772
|
+
injectImports: (code, id, options2) => ctx.injectImports(code, id, options2)
|
|
3773
|
+
},
|
|
3740
3774
|
options,
|
|
3741
3775
|
sourcemap: !!nuxt.options.sourcemap.server || !!nuxt.options.sourcemap.client
|
|
3742
3776
|
}));
|
|
@@ -3846,7 +3880,7 @@ function addDeclarationTemplates(ctx, options) {
|
|
|
3846
3880
|
});
|
|
3847
3881
|
}
|
|
3848
3882
|
|
|
3849
|
-
const version = "4.3.0-
|
|
3883
|
+
const version = "4.3.0-29436330.9aa80014";
|
|
3850
3884
|
const pkg = {
|
|
3851
3885
|
version: version};
|
|
3852
3886
|
|
|
@@ -3908,7 +3942,11 @@ const UnctxTransformPlugin = (options) => createUnplugin(() => {
|
|
|
3908
3942
|
},
|
|
3909
3943
|
transform: {
|
|
3910
3944
|
filter: {
|
|
3911
|
-
|
|
3945
|
+
...transformer.filter,
|
|
3946
|
+
code: {
|
|
3947
|
+
...transformer.filter.code,
|
|
3948
|
+
exclude: TRANSFORM_MARKER_RE
|
|
3949
|
+
}
|
|
3912
3950
|
},
|
|
3913
3951
|
handler(code) {
|
|
3914
3952
|
if (!transformer.shouldTransform(code)) {
|
|
@@ -4716,23 +4754,25 @@ function ResolveExternalsPlugin(nuxt) {
|
|
|
4716
4754
|
}
|
|
4717
4755
|
return {
|
|
4718
4756
|
name: "nuxt:resolve-externals:external",
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
}
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
if (res
|
|
4726
|
-
res.id
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4757
|
+
resolveId: {
|
|
4758
|
+
filter: {
|
|
4759
|
+
id: [...external].map((dep) => new RegExp("^" + escapeRE(dep) + "$"))
|
|
4760
|
+
},
|
|
4761
|
+
async handler(id, importer) {
|
|
4762
|
+
const res = await this.resolve?.(id, importer, { skipSelf: true });
|
|
4763
|
+
if (res !== void 0 && res !== null) {
|
|
4764
|
+
if (res.id === id) {
|
|
4765
|
+
res.id = resolveModulePath(res.id, {
|
|
4766
|
+
try: true,
|
|
4767
|
+
from: importer,
|
|
4768
|
+
extensions: nuxt.options.extensions
|
|
4769
|
+
}) || res.id;
|
|
4770
|
+
}
|
|
4771
|
+
return {
|
|
4772
|
+
...res,
|
|
4773
|
+
external: "absolute"
|
|
4774
|
+
};
|
|
4731
4775
|
}
|
|
4732
|
-
return {
|
|
4733
|
-
...res,
|
|
4734
|
-
external: "absolute"
|
|
4735
|
-
};
|
|
4736
4776
|
}
|
|
4737
4777
|
}
|
|
4738
4778
|
};
|
|
@@ -4967,12 +5007,36 @@ const VirtualFSPlugin = (nuxt, options) => createUnplugin((_, meta) => {
|
|
|
4967
5007
|
}
|
|
4968
5008
|
}
|
|
4969
5009
|
}
|
|
5010
|
+
const relevantAliases = /* @__PURE__ */ new Set();
|
|
5011
|
+
for (const key in alias) {
|
|
5012
|
+
const value = alias[key];
|
|
5013
|
+
if (value && Object.keys(nuxt.vfs).some((vfsPath) => vfsPath.startsWith(value))) {
|
|
5014
|
+
relevantAliases.add(escapeDirectory(key));
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
const vfsEntries = /* @__PURE__ */ new Set();
|
|
5018
|
+
for (const key in nuxt.vfs) {
|
|
5019
|
+
if (!key.startsWith("#build/") && !key.startsWith(nuxt.options.buildDir)) {
|
|
5020
|
+
vfsEntries.add(escapeDirectory(dirname(key)));
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
const filter = {
|
|
5024
|
+
id: [
|
|
5025
|
+
PREFIX_RE,
|
|
5026
|
+
RELATIVE_ID_RE,
|
|
5027
|
+
/^#build\//,
|
|
5028
|
+
new RegExp("^(\\w:)?" + escapeDirectory(nuxt.options.buildDir)),
|
|
5029
|
+
...Array.from(vfsEntries).map((id) => new RegExp("^" + id)),
|
|
5030
|
+
...relevantAliases.size ? [new RegExp("^" + Array.from(relevantAliases).join("|") + "([\\\\/]|$)")] : []
|
|
5031
|
+
]
|
|
5032
|
+
};
|
|
4970
5033
|
return {
|
|
4971
5034
|
name: "nuxt:virtual",
|
|
4972
|
-
resolveId: meta.framework === "vite" ? void 0 : { order: "pre", handler: resolveId },
|
|
5035
|
+
resolveId: meta.framework === "vite" ? void 0 : { order: "pre", filter, handler: resolveId },
|
|
4973
5036
|
vite: {
|
|
4974
5037
|
resolveId: {
|
|
4975
5038
|
order: "pre",
|
|
5039
|
+
filter,
|
|
4976
5040
|
handler(id, importer) {
|
|
4977
5041
|
const res = resolveId(id, importer);
|
|
4978
5042
|
if (res) {
|
|
@@ -5005,6 +5069,9 @@ const QUERY_RE = /\?.*$/;
|
|
|
5005
5069
|
function withoutQuery(id) {
|
|
5006
5070
|
return id.replace(QUERY_RE, "");
|
|
5007
5071
|
}
|
|
5072
|
+
function escapeDirectory(path) {
|
|
5073
|
+
return escapeRE(path).replace(/\//g, "[\\\\/]");
|
|
5074
|
+
}
|
|
5008
5075
|
|
|
5009
5076
|
function createNuxt(options) {
|
|
5010
5077
|
const hooks = createHooks();
|
|
@@ -5961,13 +6028,13 @@ const schemaNodeTemplate = {
|
|
|
5961
6028
|
` * Configuration for \`${importName}\``,
|
|
5962
6029
|
...options.addJSDocTags && link ? [` * @see ${link}`] : [],
|
|
5963
6030
|
` */`,
|
|
5964
|
-
` [${configKey}]${options.unresolved ? "?" : ""}: typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O, unknown, boolean> ? ${options.unresolved ? "Partial<O>" : "O"} : Record<string, any
|
|
6031
|
+
` [${configKey}]${options.unresolved ? "?" : ""}: typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O, unknown, boolean> ? ${options.unresolved ? "Partial<O>" : "O"} | false : Record<string, any> | false`
|
|
5965
6032
|
];
|
|
5966
6033
|
}),
|
|
5967
6034
|
modules.length > 0 && options.unresolved ? ` modules?: (undefined | null | false | NuxtModule<any> | string | [NuxtModule | string, Record<string, any>] | ${modules.map(([configKey, importName, mod]) => `[${genString(mod.meta?.rawPath || importName)}, Exclude<NuxtConfig[${configKey}], boolean>]`).join(" | ")})[],` : ""
|
|
5968
6035
|
].filter(Boolean);
|
|
5969
6036
|
const moduleDependencies = modules.flatMap(([_configKey, importName, mod]) => [
|
|
5970
|
-
` [${genString(mod.meta.name || importName)}]?: ModuleDependencyMeta<typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O> ? O : Record<string, unknown
|
|
6037
|
+
` [${genString(mod.meta.name || importName)}]?: ModuleDependencyMeta<typeof ${genDynamicImport(importName, { wrapper: false })}.default extends NuxtModule<infer O> ? O | false : Record<string, unknown>> | false`
|
|
5971
6038
|
]).join("\n");
|
|
5972
6039
|
return [
|
|
5973
6040
|
"import { NuxtModule, ModuleDependencyMeta } from '@nuxt/schema'",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-nightly",
|
|
3
|
-
"version": "4.3.0-
|
|
3
|
+
"version": "4.3.0-29436330.9aa80014",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/nuxt/nuxt.git",
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
"@dxup/nuxt": "^0.3.2",
|
|
68
68
|
"@nuxt/cli": "npm:@nuxt/cli-nightly@latest",
|
|
69
69
|
"@nuxt/devtools": "^3.1.1",
|
|
70
|
-
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-
|
|
71
|
-
"@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@4.3.0-
|
|
72
|
-
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-
|
|
70
|
+
"@nuxt/kit": "npm:@nuxt/kit-nightly@4.3.0-29436330.9aa80014",
|
|
71
|
+
"@nuxt/nitro-server": "npm:@nuxt/nitro-server-nightly@4.3.0-29436330.9aa80014",
|
|
72
|
+
"@nuxt/schema": "npm:@nuxt/schema-nightly@4.3.0-29436330.9aa80014",
|
|
73
73
|
"@nuxt/telemetry": "^2.6.6",
|
|
74
|
-
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.3.0-
|
|
74
|
+
"@nuxt/vite-builder": "npm:@nuxt/vite-builder-nightly@4.3.0-29436330.9aa80014",
|
|
75
75
|
"@unhead/vue": "^2.0.19",
|
|
76
76
|
"@vue/shared": "^3.5.25",
|
|
77
77
|
"c12": "^3.3.2",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"ufo": "^1.6.1",
|
|
115
115
|
"ultrahtml": "^1.6.0",
|
|
116
116
|
"uncrypto": "^0.1.3",
|
|
117
|
-
"unctx": "^2.
|
|
117
|
+
"unctx": "^2.5.0",
|
|
118
118
|
"unimport": "^5.6.0",
|
|
119
119
|
"unplugin": "^2.3.11",
|
|
120
120
|
"unplugin-vue-router": "^0.19.1",
|