@vue/compiler-core 3.2.15 → 3.2.19
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.
|
@@ -452,21 +452,21 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
452
452
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
453
453
|
};
|
|
454
454
|
const isMemberExpressionNode = (path, context) => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
455
|
+
try {
|
|
456
|
+
let ret = parser.parseExpression(path, {
|
|
457
|
+
plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
|
|
458
|
+
});
|
|
459
|
+
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
460
|
+
ret = ret.expression;
|
|
461
|
+
}
|
|
462
|
+
return (ret.type === 'MemberExpression' ||
|
|
463
|
+
ret.type === 'OptionalMemberExpression' ||
|
|
464
|
+
ret.type === 'Identifier');
|
|
461
465
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
catch (e) {
|
|
467
|
-
return false;
|
|
468
|
-
}
|
|
469
|
-
};
|
|
466
|
+
catch (e) {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
470
|
const isMemberExpression = isMemberExpressionNode;
|
|
471
471
|
function getInnerRange(loc, offset, length) {
|
|
472
472
|
const source = loc.source.substr(offset, length);
|
|
@@ -2254,7 +2254,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
|
|
2256
2256
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2257
|
-
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
|
|
2257
|
+
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2258
2258
|
const context = {
|
|
2259
2259
|
mode,
|
|
2260
2260
|
prefixIdentifiers,
|
|
@@ -2264,6 +2264,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
|
|
|
2264
2264
|
optimizeImports,
|
|
2265
2265
|
runtimeGlobalName,
|
|
2266
2266
|
runtimeModuleName,
|
|
2267
|
+
ssrRuntimeModuleName,
|
|
2267
2268
|
ssr,
|
|
2268
2269
|
isTS,
|
|
2269
2270
|
inSSR,
|
|
@@ -2440,7 +2441,7 @@ function generate(ast, options = {}) {
|
|
|
2440
2441
|
};
|
|
2441
2442
|
}
|
|
2442
2443
|
function genFunctionPreamble(ast, context) {
|
|
2443
|
-
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
|
|
2444
|
+
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2444
2445
|
const VueBinding = ssr
|
|
2445
2446
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
|
2446
2447
|
: runtimeGlobalName;
|
|
@@ -2480,14 +2481,14 @@ function genFunctionPreamble(ast, context) {
|
|
|
2480
2481
|
// ssr guarantees prefixIdentifier: true
|
|
2481
2482
|
push(`const { ${ast.ssrHelpers
|
|
2482
2483
|
.map(aliasHelper)
|
|
2483
|
-
.join(', ')} } = require("
|
|
2484
|
+
.join(', ')} } = require("${ssrRuntimeModuleName}")\n`);
|
|
2484
2485
|
}
|
|
2485
2486
|
genHoists(ast.hoists, context);
|
|
2486
2487
|
newline();
|
|
2487
2488
|
push(`return `);
|
|
2488
2489
|
}
|
|
2489
2490
|
function genModulePreamble(ast, context, genScopeId, inline) {
|
|
2490
|
-
const { push, newline, optimizeImports, runtimeModuleName } = context;
|
|
2491
|
+
const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
|
|
2491
2492
|
if (genScopeId && ast.hoists.length) {
|
|
2492
2493
|
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
|
|
2493
2494
|
}
|
|
@@ -2515,7 +2516,7 @@ function genModulePreamble(ast, context, genScopeId, inline) {
|
|
|
2515
2516
|
if (ast.ssrHelpers && ast.ssrHelpers.length) {
|
|
2516
2517
|
push(`import { ${ast.ssrHelpers
|
|
2517
2518
|
.map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
|
|
2518
|
-
.join(', ')} } from "
|
|
2519
|
+
.join(', ')} } from "${ssrRuntimeModuleName}"\n`);
|
|
2519
2520
|
}
|
|
2520
2521
|
if (ast.imports.length) {
|
|
2521
2522
|
genImports(ast.imports, context);
|
|
@@ -3817,7 +3818,9 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3817
3818
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3818
3819
|
: keyProp.exp);
|
|
3819
3820
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3820
|
-
if (context.prefixIdentifiers &&
|
|
3821
|
+
if (context.prefixIdentifiers &&
|
|
3822
|
+
keyProperty &&
|
|
3823
|
+
keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
3821
3824
|
// #2085 process :key expression needs to be processed in order for it
|
|
3822
3825
|
// to behave consistently for <template v-for> and <div v-for>.
|
|
3823
3826
|
// In the case of `<template v-for>`, the node is discarded and never
|
|
@@ -451,21 +451,21 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
451
451
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
452
452
|
};
|
|
453
453
|
const isMemberExpressionNode = (path, context) => {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
454
|
+
try {
|
|
455
|
+
let ret = parser.parseExpression(path, {
|
|
456
|
+
plugins: [...context.expressionPlugins, ...shared.babelParserDefaultPlugins]
|
|
457
|
+
});
|
|
458
|
+
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
459
|
+
ret = ret.expression;
|
|
460
|
+
}
|
|
461
|
+
return (ret.type === 'MemberExpression' ||
|
|
462
|
+
ret.type === 'OptionalMemberExpression' ||
|
|
463
|
+
ret.type === 'Identifier');
|
|
460
464
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
catch (e) {
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
};
|
|
465
|
+
catch (e) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
469
|
const isMemberExpression = isMemberExpressionNode;
|
|
470
470
|
function getInnerRange(loc, offset, length) {
|
|
471
471
|
const source = loc.source.substr(offset, length);
|
|
@@ -2205,7 +2205,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2205
2205
|
}
|
|
2206
2206
|
|
|
2207
2207
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2208
|
-
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
|
|
2208
|
+
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2209
2209
|
const context = {
|
|
2210
2210
|
mode,
|
|
2211
2211
|
prefixIdentifiers,
|
|
@@ -2215,6 +2215,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
|
|
|
2215
2215
|
optimizeImports,
|
|
2216
2216
|
runtimeGlobalName,
|
|
2217
2217
|
runtimeModuleName,
|
|
2218
|
+
ssrRuntimeModuleName,
|
|
2218
2219
|
ssr,
|
|
2219
2220
|
isTS,
|
|
2220
2221
|
inSSR,
|
|
@@ -2391,7 +2392,7 @@ function generate(ast, options = {}) {
|
|
|
2391
2392
|
};
|
|
2392
2393
|
}
|
|
2393
2394
|
function genFunctionPreamble(ast, context) {
|
|
2394
|
-
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
|
|
2395
|
+
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2395
2396
|
const VueBinding = ssr
|
|
2396
2397
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
|
2397
2398
|
: runtimeGlobalName;
|
|
@@ -2431,14 +2432,14 @@ function genFunctionPreamble(ast, context) {
|
|
|
2431
2432
|
// ssr guarantees prefixIdentifier: true
|
|
2432
2433
|
push(`const { ${ast.ssrHelpers
|
|
2433
2434
|
.map(aliasHelper)
|
|
2434
|
-
.join(', ')} } = require("
|
|
2435
|
+
.join(', ')} } = require("${ssrRuntimeModuleName}")\n`);
|
|
2435
2436
|
}
|
|
2436
2437
|
genHoists(ast.hoists, context);
|
|
2437
2438
|
newline();
|
|
2438
2439
|
push(`return `);
|
|
2439
2440
|
}
|
|
2440
2441
|
function genModulePreamble(ast, context, genScopeId, inline) {
|
|
2441
|
-
const { push, newline, optimizeImports, runtimeModuleName } = context;
|
|
2442
|
+
const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
|
|
2442
2443
|
if (genScopeId && ast.hoists.length) {
|
|
2443
2444
|
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
|
|
2444
2445
|
}
|
|
@@ -2466,7 +2467,7 @@ function genModulePreamble(ast, context, genScopeId, inline) {
|
|
|
2466
2467
|
if (ast.ssrHelpers && ast.ssrHelpers.length) {
|
|
2467
2468
|
push(`import { ${ast.ssrHelpers
|
|
2468
2469
|
.map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
|
|
2469
|
-
.join(', ')} } from "
|
|
2470
|
+
.join(', ')} } from "${ssrRuntimeModuleName}"\n`);
|
|
2470
2471
|
}
|
|
2471
2472
|
if (ast.imports.length) {
|
|
2472
2473
|
genImports(ast.imports, context);
|
|
@@ -3736,7 +3737,9 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
3736
3737
|
? createSimpleExpression(keyProp.value.content, true)
|
|
3737
3738
|
: keyProp.exp);
|
|
3738
3739
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
3739
|
-
if (context.prefixIdentifiers &&
|
|
3740
|
+
if (context.prefixIdentifiers &&
|
|
3741
|
+
keyProperty &&
|
|
3742
|
+
keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
3740
3743
|
// #2085 process :key expression needs to be processed in order for it
|
|
3741
3744
|
// to behave consistently for <template v-for> and <div v-for>.
|
|
3742
3745
|
// In the case of `<template v-for>`, the node is discarded and never
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -174,6 +174,11 @@ export declare interface CodegenOptions extends SharedTransformCodegenOptions {
|
|
|
174
174
|
* @default 'vue'
|
|
175
175
|
*/
|
|
176
176
|
runtimeModuleName?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Customize where to import ssr runtime helpers from/**
|
|
179
|
+
* @default 'vue/server-renderer'
|
|
180
|
+
*/
|
|
181
|
+
ssrRuntimeModuleName?: string;
|
|
177
182
|
/**
|
|
178
183
|
* Customize the global variable name of `Vue` to get helpers from
|
|
179
184
|
* in function mode
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { isString, hyphenate,
|
|
1
|
+
import { isString, hyphenate, NOOP, extend, isObject, NO, isArray, makeMap, isSymbol, EMPTY_OBJ, capitalize, camelize as camelize$1, PatchFlagNames, slotFlagsText, isOn, isReservedProp, toHandlerKey } from '@vue/shared';
|
|
2
2
|
export { generateCodeFrame } from '@vue/shared';
|
|
3
|
-
import { parseExpression } from '@babel/parser';
|
|
4
3
|
|
|
5
4
|
function defaultOnError(error) {
|
|
6
5
|
throw error;
|
|
@@ -447,22 +446,8 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
447
446
|
}
|
|
448
447
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
449
448
|
};
|
|
450
|
-
const isMemberExpressionNode =
|
|
451
|
-
|
|
452
|
-
let ret = parseExpression(path, {
|
|
453
|
-
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
|
|
454
|
-
});
|
|
455
|
-
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
456
|
-
ret = ret.expression;
|
|
457
|
-
}
|
|
458
|
-
return (ret.type === 'MemberExpression' ||
|
|
459
|
-
ret.type === 'OptionalMemberExpression' ||
|
|
460
|
-
ret.type === 'Identifier');
|
|
461
|
-
}
|
|
462
|
-
catch (e) {
|
|
463
|
-
return false;
|
|
464
|
-
}
|
|
465
|
-
};
|
|
449
|
+
const isMemberExpressionNode = NOOP
|
|
450
|
+
;
|
|
466
451
|
const isMemberExpression = isMemberExpressionBrowser
|
|
467
452
|
;
|
|
468
453
|
function getInnerRange(loc, offset, length) {
|
|
@@ -2223,7 +2208,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2223
2208
|
}
|
|
2224
2209
|
|
|
2225
2210
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2226
|
-
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
|
|
2211
|
+
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2227
2212
|
const context = {
|
|
2228
2213
|
mode,
|
|
2229
2214
|
prefixIdentifiers,
|
|
@@ -2233,6 +2218,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
|
|
|
2233
2218
|
optimizeImports,
|
|
2234
2219
|
runtimeGlobalName,
|
|
2235
2220
|
runtimeModuleName,
|
|
2221
|
+
ssrRuntimeModuleName,
|
|
2236
2222
|
ssr,
|
|
2237
2223
|
isTS,
|
|
2238
2224
|
inSSR,
|
|
@@ -2358,7 +2344,7 @@ function generate(ast, options = {}) {
|
|
|
2358
2344
|
};
|
|
2359
2345
|
}
|
|
2360
2346
|
function genFunctionPreamble(ast, context) {
|
|
2361
|
-
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
|
|
2347
|
+
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2362
2348
|
const VueBinding = runtimeGlobalName;
|
|
2363
2349
|
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2364
2350
|
// Generate const declaration for helpers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.19",
|
|
4
4
|
"description": "@vue/compiler-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/compiler-core.esm-bundler.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-core#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vue/shared": "3.2.
|
|
35
|
+
"@vue/shared": "3.2.19",
|
|
36
36
|
"@babel/parser": "^7.15.0",
|
|
37
37
|
"estree-walker": "^2.0.2",
|
|
38
38
|
"source-map": "^0.6.1"
|