@vureact/compiler-core 1.6.0 → 1.6.1
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vureact/compiler-core v1.6.
|
|
2
|
+
* @vureact/compiler-core v1.6.1
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -324,6 +324,11 @@ var ADAPTER_RULES = {
|
|
|
324
324
|
target: "nextTick",
|
|
325
325
|
package: PACKAGE_NAME.runtime,
|
|
326
326
|
type: "rename"
|
|
327
|
+
},
|
|
328
|
+
defineAsyncComponent: {
|
|
329
|
+
target: "defineAsyncComponent",
|
|
330
|
+
package: PACKAGE_NAME.runtime,
|
|
331
|
+
type: "rename"
|
|
327
332
|
}
|
|
328
333
|
},
|
|
329
334
|
// =================== [VuReact Router] ===================
|
|
@@ -1053,7 +1058,7 @@ function buildStandardProp(nodeIR) {
|
|
|
1053
1058
|
babelExp: { ast: keyAST },
|
|
1054
1059
|
value: {
|
|
1055
1060
|
content,
|
|
1056
|
-
isStringLiteral:
|
|
1061
|
+
isStringLiteral: isStringLiteral13,
|
|
1057
1062
|
babelExp: { ast: valueAST }
|
|
1058
1063
|
}
|
|
1059
1064
|
} = nodeIR;
|
|
@@ -1062,7 +1067,7 @@ function buildStandardProp(nodeIR) {
|
|
|
1062
1067
|
}
|
|
1063
1068
|
let value;
|
|
1064
1069
|
if (content !== "true") {
|
|
1065
|
-
value =
|
|
1070
|
+
value = isStringLiteral13 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
|
|
1066
1071
|
}
|
|
1067
1072
|
return t9.jsxAttribute(keyAST, value);
|
|
1068
1073
|
}
|
|
@@ -2991,98 +2996,22 @@ function resolveDefineAsyncComponent(ctx) {
|
|
|
2991
2996
|
return;
|
|
2992
2997
|
}
|
|
2993
2998
|
const [arg] = node.arguments;
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
function checkIsUnsupported(ctx, arg) {
|
|
3001
|
-
if (t25.isFunction(arg)) {
|
|
3002
|
-
checkIsDynamicImport(ctx, arg);
|
|
3003
|
-
} else if (t25.isObjectExpression(arg)) {
|
|
3004
|
-
const { value } = arg.properties.find(
|
|
3005
|
-
(p) => t25.isObjectProperty(p) && t25.isIdentifier(p.key) && p.key.name === "loader"
|
|
3006
|
-
);
|
|
3007
|
-
checkIsDynamicImport(ctx, value);
|
|
3008
|
-
if (arg.properties.length > 1) {
|
|
3009
|
-
warnMultipleOptionsUsed(ctx, arg);
|
|
3010
|
-
}
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
function checkIsDynamicImport(ctx, node) {
|
|
3014
|
-
const { scriptData, filename } = ctx;
|
|
3015
|
-
const warnIsNotImport = (target) => {
|
|
3016
|
-
if (!target || !t25.isImport(target)) {
|
|
3017
|
-
logger.error(
|
|
3018
|
-
`Only ES module dynamic imports are supported. You must use and return import('...').`,
|
|
3019
|
-
{
|
|
3020
|
-
source: scriptData.source,
|
|
3021
|
-
file: filename,
|
|
3022
|
-
loc: target?.loc || {}
|
|
2999
|
+
if (!t25.isObjectExpression(arg)) {
|
|
3000
|
+
return;
|
|
3001
|
+
}
|
|
3002
|
+
for (const prop of arg.properties) {
|
|
3003
|
+
if (!t25.isObjectProperty(prop) || !t25.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
|
|
3004
|
+
continue;
|
|
3023
3005
|
}
|
|
3024
|
-
|
|
3006
|
+
logger.warn('Unsupported option "hydrate"', {
|
|
3007
|
+
file: ctx.filename,
|
|
3008
|
+
source: ctx.scriptData.source,
|
|
3009
|
+
loc: prop.key.loc
|
|
3010
|
+
});
|
|
3011
|
+
break;
|
|
3012
|
+
}
|
|
3025
3013
|
}
|
|
3026
3014
|
};
|
|
3027
|
-
if (t25.isFunction(node)) {
|
|
3028
|
-
checkIsDynamicImport(ctx, node.body);
|
|
3029
|
-
return;
|
|
3030
|
-
}
|
|
3031
|
-
if (t25.isBlockStatement(node)) {
|
|
3032
|
-
const [returnSmt] = node.body;
|
|
3033
|
-
if (t25.isReturnStatement(returnSmt)) {
|
|
3034
|
-
warnIsNotImport(returnSmt.argument);
|
|
3035
|
-
}
|
|
3036
|
-
return;
|
|
3037
|
-
}
|
|
3038
|
-
if (t25.isCallExpression(node)) {
|
|
3039
|
-
warnIsNotImport(node.callee);
|
|
3040
|
-
if (t25.isStringLiteral(node.arguments[0])) {
|
|
3041
|
-
replaceVueSuffix(node.arguments[0]);
|
|
3042
|
-
}
|
|
3043
|
-
return;
|
|
3044
|
-
}
|
|
3045
|
-
warnIsNotImport(node);
|
|
3046
|
-
}
|
|
3047
|
-
function warnMultipleOptionsUsed(ctx, node) {
|
|
3048
|
-
const { scriptData, filename } = ctx;
|
|
3049
|
-
logger.warn(
|
|
3050
|
-
"Only the loader option is supported. Other options may be implemented manually based on your needs.",
|
|
3051
|
-
{
|
|
3052
|
-
source: scriptData.source,
|
|
3053
|
-
file: filename,
|
|
3054
|
-
loc: node.loc
|
|
3055
|
-
}
|
|
3056
|
-
);
|
|
3057
|
-
}
|
|
3058
|
-
function pushToGlobalScope(path9, ctx) {
|
|
3059
|
-
const { node } = path9;
|
|
3060
|
-
const callee = node.callee;
|
|
3061
|
-
callee.name = REACT_API_MAP.lazy;
|
|
3062
|
-
callee.loc.identifierName = REACT_API_MAP.lazy;
|
|
3063
|
-
if (node.typeParameters) {
|
|
3064
|
-
node.typeParameters = void 0;
|
|
3065
|
-
}
|
|
3066
|
-
let declarationPath = path9.parentPath;
|
|
3067
|
-
while (declarationPath) {
|
|
3068
|
-
if (declarationPath.isVariableDeclaration()) {
|
|
3069
|
-
break;
|
|
3070
|
-
}
|
|
3071
|
-
declarationPath = declarationPath.parentPath;
|
|
3072
|
-
}
|
|
3073
|
-
let fullNode;
|
|
3074
|
-
if (declarationPath?.isVariableDeclaration()) {
|
|
3075
|
-
fullNode = declarationPath.node;
|
|
3076
|
-
declarationPath.remove();
|
|
3077
|
-
} else if (path9.parentPath.isVariableDeclarator()) {
|
|
3078
|
-
fullNode = path9.parent;
|
|
3079
|
-
path9.parentPath.remove();
|
|
3080
|
-
} else {
|
|
3081
|
-
fullNode = path9.node;
|
|
3082
|
-
path9.remove();
|
|
3083
|
-
}
|
|
3084
|
-
const scriptIR = getScriptIR(ctx);
|
|
3085
|
-
scriptIR.statement.global.push(fullNode);
|
|
3086
3015
|
}
|
|
3087
3016
|
|
|
3088
3017
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
|
|
@@ -4903,6 +4832,10 @@ function resolveRenameAdapter(ctx) {
|
|
|
4903
4832
|
};
|
|
4904
4833
|
}
|
|
4905
4834
|
function isVueApiReference2(path9, apiName) {
|
|
4835
|
+
const whitelist = [VUE_API_MAP.defineAsyncComponent];
|
|
4836
|
+
if (whitelist.includes(apiName)) {
|
|
4837
|
+
return true;
|
|
4838
|
+
}
|
|
4906
4839
|
if (path9.isIdentifier()) {
|
|
4907
4840
|
if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
|
|
4908
4841
|
return false;
|
|
@@ -5070,7 +5003,7 @@ import * as t45 from "@babel/types";
|
|
|
5070
5003
|
var strCodeTypes = {
|
|
5071
5004
|
isIdentifier: isIdentifier24,
|
|
5072
5005
|
isSimpleExpression,
|
|
5073
|
-
isStringLiteral:
|
|
5006
|
+
isStringLiteral: isStringLiteral12
|
|
5074
5007
|
};
|
|
5075
5008
|
function isSimpleExpression(code, excludeVar = false) {
|
|
5076
5009
|
let node;
|
|
@@ -5107,7 +5040,7 @@ function isIdentifier24(code) {
|
|
|
5107
5040
|
return false;
|
|
5108
5041
|
}
|
|
5109
5042
|
}
|
|
5110
|
-
function
|
|
5043
|
+
function isStringLiteral12(code) {
|
|
5111
5044
|
try {
|
|
5112
5045
|
const node = parseExpression3(code);
|
|
5113
5046
|
return t45.isStringLiteral(node);
|
|
@@ -5254,21 +5187,21 @@ function resolvePropAsBabelExp(ir, ctx) {
|
|
|
5254
5187
|
target.content = valueName;
|
|
5255
5188
|
target.ast = t46.jsxIdentifier(valueName);
|
|
5256
5189
|
};
|
|
5257
|
-
const setValueExpression = (target, content,
|
|
5190
|
+
const setValueExpression = (target, content, isStringLiteral13) => {
|
|
5258
5191
|
target.content = content;
|
|
5259
|
-
target.ast = resolveStringExpr(content, ctx,
|
|
5192
|
+
target.ast = resolveStringExpr(content, ctx, isStringLiteral13);
|
|
5260
5193
|
};
|
|
5261
5194
|
const createRuntimeCall = (fnName, args) => {
|
|
5262
5195
|
const fnArgs = args.filter(Boolean).join(",");
|
|
5263
5196
|
return `${fnName}(${fnArgs})`;
|
|
5264
5197
|
};
|
|
5265
|
-
const applyRuntimeExpression = (expression, setName = false, nameIdentifier,
|
|
5198
|
+
const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral13) => {
|
|
5266
5199
|
if (setName && nameIdentifier) {
|
|
5267
5200
|
setNameIdentifier(nameExp, nameIdentifier);
|
|
5268
5201
|
}
|
|
5269
5202
|
const dir = ADAPTER_RULES.runtime.dir;
|
|
5270
5203
|
recordImport(ctx, dir.package, dir.target);
|
|
5271
|
-
setValueExpression(value.babelExp, expression,
|
|
5204
|
+
setValueExpression(value.babelExp, expression, isStringLiteral13);
|
|
5272
5205
|
};
|
|
5273
5206
|
if (ir.isKeyLessVBind) {
|
|
5274
5207
|
const dirKeyless = ADAPTER_RULES.runtime.dirKeyless;
|
|
@@ -5686,12 +5619,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
5686
5619
|
content = propsIR.value.content = parseStyleString(content);
|
|
5687
5620
|
}
|
|
5688
5621
|
if (isDynamic) {
|
|
5689
|
-
const
|
|
5690
|
-
if (
|
|
5622
|
+
const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
|
|
5623
|
+
if (isStringLiteral13) {
|
|
5691
5624
|
content = normalizeString(content);
|
|
5692
5625
|
propsIR.value.content = content;
|
|
5693
5626
|
}
|
|
5694
|
-
propsIR.value.isStringLiteral =
|
|
5627
|
+
propsIR.value.isStringLiteral = isStringLiteral13;
|
|
5695
5628
|
}
|
|
5696
5629
|
const existing = findSameProp(nodeIR.props, propsIR);
|
|
5697
5630
|
if (existing) {
|
|
@@ -6387,7 +6320,7 @@ function transform(ast, ctx, options) {
|
|
|
6387
6320
|
}
|
|
6388
6321
|
|
|
6389
6322
|
// package.json
|
|
6390
|
-
var version = "1.6.
|
|
6323
|
+
var version = "1.6.1";
|
|
6391
6324
|
var bin = {
|
|
6392
6325
|
vureact: "./bin/vureact.js"
|
|
6393
6326
|
};
|