@vue/compiler-sfc 3.2.13 → 3.2.17
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/README.md +3 -2
- package/dist/compiler-sfc.cjs.js +12 -5
- package/dist/compiler-sfc.d.ts +1 -2
- package/dist/compiler-sfc.esm-browser.js +40 -36
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> Lower level utilities for compiling Vue Single File Components
|
|
4
4
|
|
|
5
|
+
**Note: as of 3.2.13+, this package is included as a dependency of the main `vue` package and can be accessed as `vue/compiler-sfc`. This means you no longer need to explicitly install this package and ensure its version match that of `vue`'s. Just use the main `vue/compiler-sfc` deep import instead.**
|
|
6
|
+
|
|
5
7
|
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite).
|
|
6
8
|
|
|
7
9
|
## API
|
|
@@ -9,6 +11,7 @@ This package contains lower level utilities that you can use if you are writing
|
|
|
9
11
|
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
|
|
10
12
|
|
|
11
13
|
- Separate hot-module replacement (HMR) for script, template and styles
|
|
14
|
+
|
|
12
15
|
- template updates should not reset component state
|
|
13
16
|
- style updates should be performed without component re-render
|
|
14
17
|
|
|
@@ -74,6 +77,4 @@ export default script
|
|
|
74
77
|
|
|
75
78
|
Options needed for these APIs can be passed via the query string.
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
80
|
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue/tree/next) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).
|
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -15869,6 +15869,7 @@ function compileScript(sfc, options) {
|
|
|
15869
15869
|
const helperImports = new Set();
|
|
15870
15870
|
const userImports = Object.create(null);
|
|
15871
15871
|
const userImportAlias = Object.create(null);
|
|
15872
|
+
const scriptBindings = Object.create(null);
|
|
15872
15873
|
const setupBindings = Object.create(null);
|
|
15873
15874
|
let defaultExport;
|
|
15874
15875
|
let hasDefinePropsCall = false;
|
|
@@ -16205,14 +16206,14 @@ function compileScript(sfc, options) {
|
|
|
16205
16206
|
}
|
|
16206
16207
|
}
|
|
16207
16208
|
if (node.declaration) {
|
|
16208
|
-
walkDeclaration(node.declaration,
|
|
16209
|
+
walkDeclaration(node.declaration, scriptBindings, userImportAlias);
|
|
16209
16210
|
}
|
|
16210
16211
|
}
|
|
16211
16212
|
else if ((node.type === 'VariableDeclaration' ||
|
|
16212
16213
|
node.type === 'FunctionDeclaration' ||
|
|
16213
16214
|
node.type === 'ClassDeclaration') &&
|
|
16214
16215
|
!node.declare) {
|
|
16215
|
-
walkDeclaration(node,
|
|
16216
|
+
walkDeclaration(node, scriptBindings, userImportAlias);
|
|
16216
16217
|
}
|
|
16217
16218
|
}
|
|
16218
16219
|
// apply ref transform
|
|
@@ -16462,6 +16463,9 @@ function compileScript(sfc, options) {
|
|
|
16462
16463
|
? "setup-const" /* SETUP_CONST */
|
|
16463
16464
|
: "setup-maybe-ref" /* SETUP_MAYBE_REF */;
|
|
16464
16465
|
}
|
|
16466
|
+
for (const key in scriptBindings) {
|
|
16467
|
+
bindingMetadata[key] = scriptBindings[key];
|
|
16468
|
+
}
|
|
16465
16469
|
for (const key in setupBindings) {
|
|
16466
16470
|
bindingMetadata[key] = setupBindings[key];
|
|
16467
16471
|
}
|
|
@@ -16552,8 +16556,8 @@ function compileScript(sfc, options) {
|
|
|
16552
16556
|
}
|
|
16553
16557
|
}
|
|
16554
16558
|
else {
|
|
16555
|
-
// return bindings from setup
|
|
16556
|
-
const allBindings = Object.assign({}, setupBindings);
|
|
16559
|
+
// return bindings from script and script setup
|
|
16560
|
+
const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
|
|
16557
16561
|
for (const key in userImports) {
|
|
16558
16562
|
if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
|
|
16559
16563
|
allBindings[key] = true;
|
|
@@ -17099,6 +17103,9 @@ function stripTemplateString(str) {
|
|
|
17099
17103
|
return '';
|
|
17100
17104
|
}
|
|
17101
17105
|
|
|
17106
|
+
// API
|
|
17107
|
+
const walk$1 = estreeWalker.walk;
|
|
17108
|
+
|
|
17102
17109
|
exports.extractIdentifiers = compilerCore.extractIdentifiers;
|
|
17103
17110
|
exports.generateCodeFrame = compilerCore.generateCodeFrame;
|
|
17104
17111
|
exports.isInDestructureAssignment = compilerCore.isInDestructureAssignment;
|
|
@@ -17106,7 +17113,6 @@ exports.isStaticProperty = compilerCore.isStaticProperty;
|
|
|
17106
17113
|
exports.walkIdentifiers = compilerCore.walkIdentifiers;
|
|
17107
17114
|
exports.MagicString = MagicString__default;
|
|
17108
17115
|
exports.babelParse = parser$2.parse;
|
|
17109
|
-
exports.walk = estreeWalker.walk;
|
|
17110
17116
|
exports.shouldTransformRef = refTransform.shouldTransform;
|
|
17111
17117
|
exports.transformRef = refTransform.transform;
|
|
17112
17118
|
exports.transformRefAST = refTransform.transformAST;
|
|
@@ -17116,3 +17122,4 @@ exports.compileStyleAsync = compileStyleAsync;
|
|
|
17116
17122
|
exports.compileTemplate = compileTemplate;
|
|
17117
17123
|
exports.parse = parse;
|
|
17118
17124
|
exports.rewriteDefault = rewriteDefault;
|
|
17125
|
+
exports.walk = walk$1;
|
package/dist/compiler-sfc.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ import { shouldTransform as shouldTransformRef } from '@vue/ref-transform';
|
|
|
19
19
|
import { SourceLocation } from '@vue/compiler-core';
|
|
20
20
|
import { transform as transformRef } from '@vue/ref-transform';
|
|
21
21
|
import { transformAST as transformRefAST } from '@vue/ref-transform';
|
|
22
|
-
import { walk } from 'estree-walker';
|
|
23
22
|
import { walkIdentifiers } from '@vue/compiler-core';
|
|
24
23
|
|
|
25
24
|
declare interface AssetURLOptions {
|
|
@@ -280,7 +279,7 @@ export { transformRef }
|
|
|
280
279
|
|
|
281
280
|
export { transformRefAST }
|
|
282
281
|
|
|
283
|
-
export
|
|
282
|
+
export declare const walk: any;
|
|
284
283
|
|
|
285
284
|
export { walkIdentifiers }
|
|
286
285
|
|
|
@@ -524,7 +524,7 @@ const errorMessages = {
|
|
|
524
524
|
[47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
|
|
525
525
|
[48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
526
526
|
[49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
|
|
527
|
-
// just to
|
|
527
|
+
// just to fulfill types
|
|
528
528
|
[50 /* __EXTEND_POINT__ */]: ``
|
|
529
529
|
};
|
|
530
530
|
|
|
@@ -15447,25 +15447,21 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
15447
15447
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
15448
15448
|
};
|
|
15449
15449
|
const isMemberExpressionNode = (path, context) => {
|
|
15450
|
-
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15459
|
-
|
|
15450
|
+
try {
|
|
15451
|
+
let ret = parseExpression_1(path, {
|
|
15452
|
+
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
|
|
15453
|
+
});
|
|
15454
|
+
if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
|
|
15455
|
+
ret = ret.expression;
|
|
15456
|
+
}
|
|
15457
|
+
return (ret.type === 'MemberExpression' ||
|
|
15458
|
+
ret.type === 'OptionalMemberExpression' ||
|
|
15459
|
+
ret.type === 'Identifier');
|
|
15460
15460
|
}
|
|
15461
|
-
|
|
15462
|
-
|
|
15463
|
-
|
|
15464
|
-
}
|
|
15465
|
-
catch (e) {
|
|
15466
|
-
return false;
|
|
15467
|
-
}
|
|
15468
|
-
};
|
|
15461
|
+
catch (e) {
|
|
15462
|
+
return false;
|
|
15463
|
+
}
|
|
15464
|
+
};
|
|
15469
15465
|
const isMemberExpression = isMemberExpressionNode;
|
|
15470
15466
|
function getInnerRange(loc, offset, length) {
|
|
15471
15467
|
const source = loc.source.substr(offset, length);
|
|
@@ -20393,7 +20389,7 @@ var sourceMap = {
|
|
|
20393
20389
|
};
|
|
20394
20390
|
|
|
20395
20391
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
20396
|
-
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 }) {
|
|
20392
|
+
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 }) {
|
|
20397
20393
|
const context = {
|
|
20398
20394
|
mode,
|
|
20399
20395
|
prefixIdentifiers,
|
|
@@ -20403,6 +20399,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
|
|
|
20403
20399
|
optimizeImports,
|
|
20404
20400
|
runtimeGlobalName,
|
|
20405
20401
|
runtimeModuleName,
|
|
20402
|
+
ssrRuntimeModuleName,
|
|
20406
20403
|
ssr,
|
|
20407
20404
|
isTS,
|
|
20408
20405
|
inSSR,
|
|
@@ -20574,7 +20571,7 @@ function generate(ast, options = {}) {
|
|
|
20574
20571
|
};
|
|
20575
20572
|
}
|
|
20576
20573
|
function genFunctionPreamble(ast, context) {
|
|
20577
|
-
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
|
|
20574
|
+
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
20578
20575
|
const VueBinding = ssr
|
|
20579
20576
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
|
20580
20577
|
: runtimeGlobalName;
|
|
@@ -20614,14 +20611,14 @@ function genFunctionPreamble(ast, context) {
|
|
|
20614
20611
|
// ssr guarantees prefixIdentifier: true
|
|
20615
20612
|
push(`const { ${ast.ssrHelpers
|
|
20616
20613
|
.map(aliasHelper)
|
|
20617
|
-
.join(', ')} } = require("
|
|
20614
|
+
.join(', ')} } = require("${ssrRuntimeModuleName}")\n`);
|
|
20618
20615
|
}
|
|
20619
20616
|
genHoists(ast.hoists, context);
|
|
20620
20617
|
newline();
|
|
20621
20618
|
push(`return `);
|
|
20622
20619
|
}
|
|
20623
20620
|
function genModulePreamble(ast, context, genScopeId, inline) {
|
|
20624
|
-
const { push, newline, optimizeImports, runtimeModuleName } = context;
|
|
20621
|
+
const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
|
|
20625
20622
|
if (genScopeId && ast.hoists.length) {
|
|
20626
20623
|
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
|
|
20627
20624
|
}
|
|
@@ -20649,7 +20646,7 @@ function genModulePreamble(ast, context, genScopeId, inline) {
|
|
|
20649
20646
|
if (ast.ssrHelpers && ast.ssrHelpers.length) {
|
|
20650
20647
|
push(`import { ${ast.ssrHelpers
|
|
20651
20648
|
.map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
|
|
20652
|
-
.join(', ')} } from "
|
|
20649
|
+
.join(', ')} } from "${ssrRuntimeModuleName}"\n`);
|
|
20653
20650
|
}
|
|
20654
20651
|
if (ast.imports.length) {
|
|
20655
20652
|
genImports(ast.imports, context);
|
|
@@ -22945,7 +22942,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
22945
22942
|
hasRef = true;
|
|
22946
22943
|
// in inline mode there is no setupState object, so we can't use string
|
|
22947
22944
|
// keys to set the ref. Instead, we need to transform it to pass the
|
|
22948
|
-
//
|
|
22945
|
+
// actual ref instead.
|
|
22949
22946
|
if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
|
|
22950
22947
|
valueNode = createFunctionExpression(['_value', '_refs']);
|
|
22951
22948
|
valueNode.body = createBlockStatement(processInlineRef(context, value.content));
|
|
@@ -23634,9 +23631,9 @@ const transformModel = (dir, node, context) => {
|
|
|
23634
23631
|
if (bindingType === "setup-ref" /* SETUP_REF */) {
|
|
23635
23632
|
// v-model used on known ref.
|
|
23636
23633
|
assignmentExp = createCompoundExpression([
|
|
23637
|
-
`${eventArg} => (`,
|
|
23634
|
+
`${eventArg} => ((`,
|
|
23638
23635
|
createSimpleExpression(rawExp, false, exp.loc),
|
|
23639
|
-
|
|
23636
|
+
`).value = $event)`
|
|
23640
23637
|
]);
|
|
23641
23638
|
}
|
|
23642
23639
|
else {
|
|
@@ -23644,17 +23641,17 @@ const transformModel = (dir, node, context) => {
|
|
|
23644
23641
|
// the assignment needs to check whether the binding is actually a ref.
|
|
23645
23642
|
const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
|
|
23646
23643
|
assignmentExp = createCompoundExpression([
|
|
23647
|
-
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? `,
|
|
23644
|
+
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
|
|
23648
23645
|
createSimpleExpression(rawExp, false, exp.loc),
|
|
23649
|
-
|
|
23646
|
+
`).value = $event : ${altAssignment})`
|
|
23650
23647
|
]);
|
|
23651
23648
|
}
|
|
23652
23649
|
}
|
|
23653
23650
|
else {
|
|
23654
23651
|
assignmentExp = createCompoundExpression([
|
|
23655
|
-
`${eventArg} => (`,
|
|
23652
|
+
`${eventArg} => ((`,
|
|
23656
23653
|
exp,
|
|
23657
|
-
` = $event)`
|
|
23654
|
+
`) = $event)`
|
|
23658
23655
|
]);
|
|
23659
23656
|
}
|
|
23660
23657
|
const props = [
|
|
@@ -46591,6 +46588,7 @@ function compileScript(sfc, options) {
|
|
|
46591
46588
|
const helperImports = new Set();
|
|
46592
46589
|
const userImports = Object.create(null);
|
|
46593
46590
|
const userImportAlias = Object.create(null);
|
|
46591
|
+
const scriptBindings = Object.create(null);
|
|
46594
46592
|
const setupBindings = Object.create(null);
|
|
46595
46593
|
let defaultExport;
|
|
46596
46594
|
let hasDefinePropsCall = false;
|
|
@@ -46927,14 +46925,14 @@ function compileScript(sfc, options) {
|
|
|
46927
46925
|
}
|
|
46928
46926
|
}
|
|
46929
46927
|
if (node.declaration) {
|
|
46930
|
-
walkDeclaration(node.declaration,
|
|
46928
|
+
walkDeclaration(node.declaration, scriptBindings, userImportAlias);
|
|
46931
46929
|
}
|
|
46932
46930
|
}
|
|
46933
46931
|
else if ((node.type === 'VariableDeclaration' ||
|
|
46934
46932
|
node.type === 'FunctionDeclaration' ||
|
|
46935
46933
|
node.type === 'ClassDeclaration') &&
|
|
46936
46934
|
!node.declare) {
|
|
46937
|
-
walkDeclaration(node,
|
|
46935
|
+
walkDeclaration(node, scriptBindings, userImportAlias);
|
|
46938
46936
|
}
|
|
46939
46937
|
}
|
|
46940
46938
|
// apply ref transform
|
|
@@ -47184,6 +47182,9 @@ function compileScript(sfc, options) {
|
|
|
47184
47182
|
? "setup-const" /* SETUP_CONST */
|
|
47185
47183
|
: "setup-maybe-ref" /* SETUP_MAYBE_REF */;
|
|
47186
47184
|
}
|
|
47185
|
+
for (const key in scriptBindings) {
|
|
47186
|
+
bindingMetadata[key] = scriptBindings[key];
|
|
47187
|
+
}
|
|
47187
47188
|
for (const key in setupBindings) {
|
|
47188
47189
|
bindingMetadata[key] = setupBindings[key];
|
|
47189
47190
|
}
|
|
@@ -47274,8 +47275,8 @@ function compileScript(sfc, options) {
|
|
|
47274
47275
|
}
|
|
47275
47276
|
}
|
|
47276
47277
|
else {
|
|
47277
|
-
// return bindings from setup
|
|
47278
|
-
const allBindings = Object.assign({}, setupBindings);
|
|
47278
|
+
// return bindings from script and script setup
|
|
47279
|
+
const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
|
|
47279
47280
|
for (const key in userImports) {
|
|
47280
47281
|
if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
|
|
47281
47282
|
allBindings[key] = true;
|
|
@@ -47821,4 +47822,7 @@ function stripTemplateString(str) {
|
|
|
47821
47822
|
return '';
|
|
47822
47823
|
}
|
|
47823
47824
|
|
|
47824
|
-
|
|
47825
|
+
// API
|
|
47826
|
+
const walk$2 = walk$1;
|
|
47827
|
+
|
|
47828
|
+
export { MagicString, parse_1 as babelParse, compileScript, compileStyle, compileStyleAsync, compileTemplate, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, parse$2 as parse, rewriteDefault, shouldTransform as shouldTransformRef, transform$1 as transformRef, transformAST as transformRefAST, walk$2 as walk, walkIdentifiers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.17",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-sfc#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "^7.15.0",
|
|
36
|
-
"@vue/compiler-core": "3.2.
|
|
37
|
-
"@vue/compiler-dom": "3.2.
|
|
38
|
-
"@vue/compiler-ssr": "3.2.
|
|
39
|
-
"@vue/ref-transform": "3.2.
|
|
40
|
-
"@vue/shared": "3.2.
|
|
36
|
+
"@vue/compiler-core": "3.2.17",
|
|
37
|
+
"@vue/compiler-dom": "3.2.17",
|
|
38
|
+
"@vue/compiler-ssr": "3.2.17",
|
|
39
|
+
"@vue/ref-transform": "3.2.17",
|
|
40
|
+
"@vue/shared": "3.2.17",
|
|
41
41
|
"estree-walker": "^2.0.2",
|
|
42
42
|
"magic-string": "^0.25.7",
|
|
43
43
|
"source-map": "^0.6.1",
|