@vue/compiler-sfc 3.2.13 → 3.2.14
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 +8 -4
- package/dist/compiler-sfc.esm-browser.js +16 -16
- 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;
|
|
@@ -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,10 +15447,6 @@ const isMemberExpressionBrowser = (path) => {
|
|
|
15447
15447
|
return !currentOpenBracketCount && !currentOpenParensCount;
|
|
15448
15448
|
};
|
|
15449
15449
|
const isMemberExpressionNode = (path, context) => {
|
|
15450
|
-
path = path.trim();
|
|
15451
|
-
if (!validFirstIdentCharRE.test(path[0])) {
|
|
15452
|
-
return false;
|
|
15453
|
-
}
|
|
15454
15450
|
try {
|
|
15455
15451
|
let ret = parseExpression_1(path, {
|
|
15456
15452
|
plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
|
|
@@ -22945,7 +22941,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
22945
22941
|
hasRef = true;
|
|
22946
22942
|
// in inline mode there is no setupState object, so we can't use string
|
|
22947
22943
|
// keys to set the ref. Instead, we need to transform it to pass the
|
|
22948
|
-
//
|
|
22944
|
+
// actual ref instead.
|
|
22949
22945
|
if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
|
|
22950
22946
|
valueNode = createFunctionExpression(['_value', '_refs']);
|
|
22951
22947
|
valueNode.body = createBlockStatement(processInlineRef(context, value.content));
|
|
@@ -23634,9 +23630,9 @@ const transformModel = (dir, node, context) => {
|
|
|
23634
23630
|
if (bindingType === "setup-ref" /* SETUP_REF */) {
|
|
23635
23631
|
// v-model used on known ref.
|
|
23636
23632
|
assignmentExp = createCompoundExpression([
|
|
23637
|
-
`${eventArg} => (`,
|
|
23633
|
+
`${eventArg} => ((`,
|
|
23638
23634
|
createSimpleExpression(rawExp, false, exp.loc),
|
|
23639
|
-
|
|
23635
|
+
`).value = $event)`
|
|
23640
23636
|
]);
|
|
23641
23637
|
}
|
|
23642
23638
|
else {
|
|
@@ -23644,17 +23640,17 @@ const transformModel = (dir, node, context) => {
|
|
|
23644
23640
|
// the assignment needs to check whether the binding is actually a ref.
|
|
23645
23641
|
const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
|
|
23646
23642
|
assignmentExp = createCompoundExpression([
|
|
23647
|
-
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? `,
|
|
23643
|
+
`${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
|
|
23648
23644
|
createSimpleExpression(rawExp, false, exp.loc),
|
|
23649
|
-
|
|
23645
|
+
`).value = $event : ${altAssignment})`
|
|
23650
23646
|
]);
|
|
23651
23647
|
}
|
|
23652
23648
|
}
|
|
23653
23649
|
else {
|
|
23654
23650
|
assignmentExp = createCompoundExpression([
|
|
23655
|
-
`${eventArg} => (`,
|
|
23651
|
+
`${eventArg} => ((`,
|
|
23656
23652
|
exp,
|
|
23657
|
-
` = $event)`
|
|
23653
|
+
`) = $event)`
|
|
23658
23654
|
]);
|
|
23659
23655
|
}
|
|
23660
23656
|
const props = [
|
|
@@ -46591,6 +46587,7 @@ function compileScript(sfc, options) {
|
|
|
46591
46587
|
const helperImports = new Set();
|
|
46592
46588
|
const userImports = Object.create(null);
|
|
46593
46589
|
const userImportAlias = Object.create(null);
|
|
46590
|
+
const scriptBindings = Object.create(null);
|
|
46594
46591
|
const setupBindings = Object.create(null);
|
|
46595
46592
|
let defaultExport;
|
|
46596
46593
|
let hasDefinePropsCall = false;
|
|
@@ -46927,14 +46924,14 @@ function compileScript(sfc, options) {
|
|
|
46927
46924
|
}
|
|
46928
46925
|
}
|
|
46929
46926
|
if (node.declaration) {
|
|
46930
|
-
walkDeclaration(node.declaration,
|
|
46927
|
+
walkDeclaration(node.declaration, scriptBindings, userImportAlias);
|
|
46931
46928
|
}
|
|
46932
46929
|
}
|
|
46933
46930
|
else if ((node.type === 'VariableDeclaration' ||
|
|
46934
46931
|
node.type === 'FunctionDeclaration' ||
|
|
46935
46932
|
node.type === 'ClassDeclaration') &&
|
|
46936
46933
|
!node.declare) {
|
|
46937
|
-
walkDeclaration(node,
|
|
46934
|
+
walkDeclaration(node, scriptBindings, userImportAlias);
|
|
46938
46935
|
}
|
|
46939
46936
|
}
|
|
46940
46937
|
// apply ref transform
|
|
@@ -47184,6 +47181,9 @@ function compileScript(sfc, options) {
|
|
|
47184
47181
|
? "setup-const" /* SETUP_CONST */
|
|
47185
47182
|
: "setup-maybe-ref" /* SETUP_MAYBE_REF */;
|
|
47186
47183
|
}
|
|
47184
|
+
for (const key in scriptBindings) {
|
|
47185
|
+
bindingMetadata[key] = scriptBindings[key];
|
|
47186
|
+
}
|
|
47187
47187
|
for (const key in setupBindings) {
|
|
47188
47188
|
bindingMetadata[key] = setupBindings[key];
|
|
47189
47189
|
}
|
|
@@ -47274,8 +47274,8 @@ function compileScript(sfc, options) {
|
|
|
47274
47274
|
}
|
|
47275
47275
|
}
|
|
47276
47276
|
else {
|
|
47277
|
-
// return bindings from setup
|
|
47278
|
-
const allBindings = Object.assign({}, setupBindings);
|
|
47277
|
+
// return bindings from script and script setup
|
|
47278
|
+
const allBindings = Object.assign(Object.assign({}, scriptBindings), setupBindings);
|
|
47279
47279
|
for (const key in userImports) {
|
|
47280
47280
|
if (!userImports[key].isType && userImports[key].isUsedInTemplate) {
|
|
47281
47281
|
allBindings[key] = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.14",
|
|
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.14",
|
|
37
|
+
"@vue/compiler-dom": "3.2.14",
|
|
38
|
+
"@vue/compiler-ssr": "3.2.14",
|
|
39
|
+
"@vue/ref-transform": "3.2.14",
|
|
40
|
+
"@vue/shared": "3.2.14",
|
|
41
41
|
"estree-walker": "^2.0.2",
|
|
42
42
|
"magic-string": "^0.25.7",
|
|
43
43
|
"source-map": "^0.6.1",
|