@vue/compiler-sfc 3.2.27 → 3.2.28
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/compiler-sfc.cjs.js +12 -9
- package/dist/compiler-sfc.esm-browser.js +50 -23
- package/package.json +9 -9
package/dist/compiler-sfc.cjs.js
CHANGED
|
@@ -109,7 +109,7 @@ function sum (o) {
|
|
|
109
109
|
var hashSum = sum;
|
|
110
110
|
|
|
111
111
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
112
|
-
const cssVarRE = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][
|
|
112
|
+
const cssVarRE = /\bv-bind\s*\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^;]*))\s*\)/g;
|
|
113
113
|
function genCssVarsFromList(vars, id, isProd) {
|
|
114
114
|
return `{\n ${vars
|
|
115
115
|
.map(key => `"${genVarName(id, key, isProd)}": (${key})`)
|
|
@@ -3288,7 +3288,7 @@ function compileScript(sfc, options) {
|
|
|
3288
3288
|
let { script, scriptSetup, source, filename } = sfc;
|
|
3289
3289
|
// feature flags
|
|
3290
3290
|
// TODO remove support for deprecated options when out of experimental
|
|
3291
|
-
const
|
|
3291
|
+
const enableReactivityTransform = !!options.reactivityTransform ||
|
|
3292
3292
|
!!options.refSugar ||
|
|
3293
3293
|
!!options.refTransform;
|
|
3294
3294
|
const enablePropsTransform = !!options.reactivityTransform || !!options.propsDestructureTransform;
|
|
@@ -3308,6 +3308,7 @@ function compileScript(sfc, options) {
|
|
|
3308
3308
|
scriptLang === 'tsx' ||
|
|
3309
3309
|
scriptSetupLang === 'ts' ||
|
|
3310
3310
|
scriptSetupLang === 'tsx';
|
|
3311
|
+
// resolve parser plugins
|
|
3311
3312
|
const plugins = [];
|
|
3312
3313
|
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
|
|
3313
3314
|
plugins.push('jsx');
|
|
@@ -3332,7 +3333,7 @@ function compileScript(sfc, options) {
|
|
|
3332
3333
|
sourceType: 'module'
|
|
3333
3334
|
}).program;
|
|
3334
3335
|
const bindings = analyzeScriptBindings(scriptAst.body);
|
|
3335
|
-
if (
|
|
3336
|
+
if (enableReactivityTransform && reactivityTransform.shouldTransform(content)) {
|
|
3336
3337
|
const s = new MagicString__default(source);
|
|
3337
3338
|
const startOffset = script.loc.start.offset;
|
|
3338
3339
|
const endOffset = script.loc.end.offset;
|
|
@@ -3799,10 +3800,10 @@ function compileScript(sfc, options) {
|
|
|
3799
3800
|
walkDeclaration(node, scriptBindings, userImportAlias);
|
|
3800
3801
|
}
|
|
3801
3802
|
}
|
|
3802
|
-
// apply
|
|
3803
|
-
if (
|
|
3804
|
-
const { rootRefs
|
|
3805
|
-
refBindings =
|
|
3803
|
+
// apply reactivity transform
|
|
3804
|
+
if (enableReactivityTransform && reactivityTransform.shouldTransform(script.content)) {
|
|
3805
|
+
const { rootRefs, importedHelpers } = reactivityTransform.transformAST(scriptAst, s, scriptStartOffset);
|
|
3806
|
+
refBindings = rootRefs;
|
|
3806
3807
|
for (const h of importedHelpers) {
|
|
3807
3808
|
helperImports.add(h);
|
|
3808
3809
|
}
|
|
@@ -3987,8 +3988,10 @@ function compileScript(sfc, options) {
|
|
|
3987
3988
|
}
|
|
3988
3989
|
}
|
|
3989
3990
|
}
|
|
3990
|
-
// 3. Apply
|
|
3991
|
-
if ((
|
|
3991
|
+
// 3. Apply reactivity transform
|
|
3992
|
+
if ((enableReactivityTransform &&
|
|
3993
|
+
// normal <script> had ref bindings that maybe used in <script setup>
|
|
3994
|
+
(refBindings || reactivityTransform.shouldTransform(scriptSetup.content))) ||
|
|
3992
3995
|
propsDestructureDecl) {
|
|
3993
3996
|
const { rootRefs, importedHelpers } = reactivityTransform.transformAST(scriptSetupAst, s, startOffset, refBindings, propsDestructuredBindings);
|
|
3994
3997
|
refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs;
|
|
@@ -302,8 +302,20 @@ const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,col
|
|
|
302
302
|
'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +
|
|
303
303
|
'text,textPath,title,tspan,unknown,use,view';
|
|
304
304
|
const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
|
|
305
|
+
/**
|
|
306
|
+
* Compiler only.
|
|
307
|
+
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
308
|
+
*/
|
|
305
309
|
const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
|
|
310
|
+
/**
|
|
311
|
+
* Compiler only.
|
|
312
|
+
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
313
|
+
*/
|
|
306
314
|
const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
|
|
315
|
+
/**
|
|
316
|
+
* Compiler only.
|
|
317
|
+
* Do NOT use in runtime code paths unless behind `true` flag.
|
|
318
|
+
*/
|
|
307
319
|
const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
|
|
308
320
|
|
|
309
321
|
const escapeRE = /["'&<>]/;
|
|
@@ -16849,7 +16861,7 @@ function parseAttributes(context, type) {
|
|
|
16849
16861
|
}
|
|
16850
16862
|
const attr = parseAttribute(context, attributeNames);
|
|
16851
16863
|
// Trim whitespace between class
|
|
16852
|
-
// https://github.com/vuejs/
|
|
16864
|
+
// https://github.com/vuejs/core/issues/4251
|
|
16853
16865
|
if (attr.type === 6 /* ATTRIBUTE */ &&
|
|
16854
16866
|
attr.value &&
|
|
16855
16867
|
attr.name === 'class') {
|
|
@@ -17074,7 +17086,7 @@ function parseTextData(context, length, mode) {
|
|
|
17074
17086
|
advanceBy(context, length);
|
|
17075
17087
|
if (mode === 2 /* RAWTEXT */ ||
|
|
17076
17088
|
mode === 3 /* CDATA */ ||
|
|
17077
|
-
rawText.
|
|
17089
|
+
!rawText.includes('&')) {
|
|
17078
17090
|
return rawText;
|
|
17079
17091
|
}
|
|
17080
17092
|
else {
|
|
@@ -22201,7 +22213,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
22201
22213
|
// no: NODE.target
|
|
22202
22214
|
case 'MetaProperty':
|
|
22203
22215
|
return false;
|
|
22204
|
-
// yes: type X = {
|
|
22216
|
+
// yes: type X = { someProperty: NODE }
|
|
22205
22217
|
// no: type X = { NODE: OtherType }
|
|
22206
22218
|
case 'ObjectTypeProperty':
|
|
22207
22219
|
return parent.key !== node;
|
|
@@ -22708,6 +22720,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
22708
22720
|
const renderExp = createCallExpression(helper(RENDER_LIST), [
|
|
22709
22721
|
forNode.source
|
|
22710
22722
|
]);
|
|
22723
|
+
const isTemplate = isTemplateNode(node);
|
|
22711
22724
|
const memo = findDir(node, 'memo');
|
|
22712
22725
|
const keyProp = findProp(node, `key`);
|
|
22713
22726
|
const keyExp = keyProp &&
|
|
@@ -22715,15 +22728,17 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
22715
22728
|
? createSimpleExpression(keyProp.value.content, true)
|
|
22716
22729
|
: keyProp.exp);
|
|
22717
22730
|
const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
|
|
22718
|
-
if (
|
|
22719
|
-
|
|
22720
|
-
|
|
22721
|
-
//
|
|
22722
|
-
//
|
|
22723
|
-
|
|
22724
|
-
|
|
22725
|
-
|
|
22726
|
-
keyProperty
|
|
22731
|
+
if (isTemplate) {
|
|
22732
|
+
// #2085 / #5288 process :key and v-memo expressions need to be
|
|
22733
|
+
// processed on `<template v-for>`. In this case the node is discarded
|
|
22734
|
+
// and never traversed so its binding expressions won't be processed
|
|
22735
|
+
// by the normal transforms.
|
|
22736
|
+
if (memo) {
|
|
22737
|
+
memo.exp = processExpression(memo.exp, context);
|
|
22738
|
+
}
|
|
22739
|
+
if (keyProperty && keyProp.type !== 6 /* ATTRIBUTE */) {
|
|
22740
|
+
keyProperty.value = processExpression(keyProperty.value, context);
|
|
22741
|
+
}
|
|
22727
22742
|
}
|
|
22728
22743
|
const isStableFragment = forNode.source.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
22729
22744
|
forNode.source.constType > 0 /* NOT_CONSTANT */;
|
|
@@ -22737,7 +22752,6 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
|
|
|
22737
22752
|
return () => {
|
|
22738
22753
|
// finish the codegen now that all children have been traversed
|
|
22739
22754
|
let childBlock;
|
|
22740
|
-
const isTemplate = isTemplateNode(node);
|
|
22741
22755
|
const { children } = forNode;
|
|
22742
22756
|
// check <template v-for> key placement
|
|
22743
22757
|
if (isTemplate) {
|
|
@@ -27648,7 +27662,7 @@ function sum (o) {
|
|
|
27648
27662
|
var hashSum = sum;
|
|
27649
27663
|
|
|
27650
27664
|
const CSS_VARS_HELPER = `useCssVars`;
|
|
27651
|
-
const cssVarRE = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][
|
|
27665
|
+
const cssVarRE = /\bv-bind\s*\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^;]*))\s*\)/g;
|
|
27652
27666
|
function genCssVarsFromList(vars, id, isProd) {
|
|
27653
27667
|
return `{\n ${vars
|
|
27654
27668
|
.map(key => `"${genVarName(id, key, isProd)}": (${key})`)
|
|
@@ -33526,7 +33540,7 @@ function ssrProcessTransitionGroup(node, context) {
|
|
|
33526
33540
|
|
|
33527
33541
|
// We need to construct the slot functions in the 1st pass to ensure proper
|
|
33528
33542
|
// scope tracking, but the children of each slot cannot be processed until
|
|
33529
|
-
// the 2nd pass, so we store the WIP slot functions in a
|
|
33543
|
+
// the 2nd pass, so we store the WIP slot functions in a weakMap during the 1st
|
|
33530
33544
|
// pass and complete them in the 2nd pass.
|
|
33531
33545
|
const wipMap$1 = new WeakMap();
|
|
33532
33546
|
const componentTypeMap = new WeakMap();
|
|
@@ -34764,6 +34778,15 @@ function transformAST(ast, s, offset = 0, knownRefs, knownProps) {
|
|
|
34764
34778
|
stmt.left.type === 'VariableDeclaration') {
|
|
34765
34779
|
walkVariableDeclaration(stmt.left);
|
|
34766
34780
|
}
|
|
34781
|
+
else if (stmt.type === 'ExportNamedDeclaration' &&
|
|
34782
|
+
stmt.declaration &&
|
|
34783
|
+
stmt.declaration.type === 'VariableDeclaration') {
|
|
34784
|
+
walkVariableDeclaration(stmt.declaration, isRoot);
|
|
34785
|
+
}
|
|
34786
|
+
else if (stmt.type === 'LabeledStatement' &&
|
|
34787
|
+
stmt.body.type === 'VariableDeclaration') {
|
|
34788
|
+
walkVariableDeclaration(stmt.body, isRoot);
|
|
34789
|
+
}
|
|
34767
34790
|
}
|
|
34768
34791
|
}
|
|
34769
34792
|
function walkVariableDeclaration(stmt, isRoot = false) {
|
|
@@ -35042,6 +35065,7 @@ function transformAST(ast, s, offset = 0, knownRefs, knownProps) {
|
|
|
35042
35065
|
walkScope(node);
|
|
35043
35066
|
return;
|
|
35044
35067
|
}
|
|
35068
|
+
// skip type nodes
|
|
35045
35069
|
if (parent &&
|
|
35046
35070
|
parent.type.startsWith('TS') &&
|
|
35047
35071
|
parent.type !== 'TSAsExpression' &&
|
|
@@ -35141,7 +35165,7 @@ function compileScript(sfc, options) {
|
|
|
35141
35165
|
let { script, scriptSetup, source, filename } = sfc;
|
|
35142
35166
|
// feature flags
|
|
35143
35167
|
// TODO remove support for deprecated options when out of experimental
|
|
35144
|
-
const
|
|
35168
|
+
const enableReactivityTransform = !!options.reactivityTransform ||
|
|
35145
35169
|
!!options.refSugar ||
|
|
35146
35170
|
!!options.refTransform;
|
|
35147
35171
|
const enablePropsTransform = !!options.reactivityTransform || !!options.propsDestructureTransform;
|
|
@@ -35161,6 +35185,7 @@ function compileScript(sfc, options) {
|
|
|
35161
35185
|
scriptLang === 'tsx' ||
|
|
35162
35186
|
scriptSetupLang === 'ts' ||
|
|
35163
35187
|
scriptSetupLang === 'tsx';
|
|
35188
|
+
// resolve parser plugins
|
|
35164
35189
|
const plugins = [];
|
|
35165
35190
|
if (!isTS || scriptLang === 'tsx' || scriptSetupLang === 'tsx') {
|
|
35166
35191
|
plugins.push('jsx');
|
|
@@ -35185,7 +35210,7 @@ function compileScript(sfc, options) {
|
|
|
35185
35210
|
sourceType: 'module'
|
|
35186
35211
|
}).program;
|
|
35187
35212
|
const bindings = analyzeScriptBindings(scriptAst.body);
|
|
35188
|
-
if (
|
|
35213
|
+
if (enableReactivityTransform && shouldTransform(content)) {
|
|
35189
35214
|
const s = new MagicString(source);
|
|
35190
35215
|
const startOffset = script.loc.start.offset;
|
|
35191
35216
|
const endOffset = script.loc.end.offset;
|
|
@@ -35652,10 +35677,10 @@ function compileScript(sfc, options) {
|
|
|
35652
35677
|
walkDeclaration(node, scriptBindings, userImportAlias);
|
|
35653
35678
|
}
|
|
35654
35679
|
}
|
|
35655
|
-
// apply
|
|
35656
|
-
if (
|
|
35657
|
-
const { rootRefs
|
|
35658
|
-
refBindings =
|
|
35680
|
+
// apply reactivity transform
|
|
35681
|
+
if (enableReactivityTransform && shouldTransform(script.content)) {
|
|
35682
|
+
const { rootRefs, importedHelpers } = transformAST(scriptAst, s, scriptStartOffset);
|
|
35683
|
+
refBindings = rootRefs;
|
|
35659
35684
|
for (const h of importedHelpers) {
|
|
35660
35685
|
helperImports.add(h);
|
|
35661
35686
|
}
|
|
@@ -35840,8 +35865,10 @@ function compileScript(sfc, options) {
|
|
|
35840
35865
|
}
|
|
35841
35866
|
}
|
|
35842
35867
|
}
|
|
35843
|
-
// 3. Apply
|
|
35844
|
-
if ((
|
|
35868
|
+
// 3. Apply reactivity transform
|
|
35869
|
+
if ((enableReactivityTransform &&
|
|
35870
|
+
// normal <script> had ref bindings that maybe used in <script setup>
|
|
35871
|
+
(refBindings || shouldTransform(scriptSetup.content))) ||
|
|
35845
35872
|
propsDestructureDecl) {
|
|
35846
35873
|
const { rootRefs, importedHelpers } = transformAST(scriptSetupAst, s, startOffset, refBindings, propsDestructuredBindings);
|
|
35847
35874
|
refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-sfc",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.28",
|
|
4
4
|
"description": "@vue/compiler-sfc",
|
|
5
5
|
"main": "dist/compiler-sfc.cjs.js",
|
|
6
6
|
"module": "dist/compiler-sfc.esm-browser.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/vuejs/
|
|
22
|
+
"url": "git+https://github.com/vuejs/core.git",
|
|
23
23
|
"directory": "packages/compiler-sfc"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"author": "Evan You",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/vuejs/
|
|
31
|
+
"url": "https://github.com/vuejs/core/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/vuejs/
|
|
33
|
+
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@babel/parser": "^7.16.4",
|
|
36
|
-
"@vue/compiler-core": "3.2.
|
|
37
|
-
"@vue/compiler-dom": "3.2.
|
|
38
|
-
"@vue/compiler-ssr": "3.2.
|
|
39
|
-
"@vue/reactivity-transform": "3.2.
|
|
40
|
-
"@vue/shared": "3.2.
|
|
36
|
+
"@vue/compiler-core": "3.2.28",
|
|
37
|
+
"@vue/compiler-dom": "3.2.28",
|
|
38
|
+
"@vue/compiler-ssr": "3.2.28",
|
|
39
|
+
"@vue/reactivity-transform": "3.2.28",
|
|
40
|
+
"@vue/shared": "3.2.28",
|
|
41
41
|
"estree-walker": "^2.0.2",
|
|
42
42
|
"magic-string": "^0.25.7",
|
|
43
43
|
"source-map": "^0.6.1",
|