@vue/compiler-sfc 3.2.23 → 3.2.24

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.
@@ -1086,7 +1086,7 @@ function getImportsExpressionExp(path, hash, loc, context) {
1086
1086
  }
1087
1087
  else {
1088
1088
  name = `_imports_${context.imports.length}`;
1089
- exp = compilerCore.createSimpleExpression(name, false, loc, 2 /* CAN_HOIST */);
1089
+ exp = compilerCore.createSimpleExpression(name, false, loc, 3 /* CAN_STRINGIFY */);
1090
1090
  context.imports.push({ exp, path });
1091
1091
  }
1092
1092
  if (!hash) {
@@ -1100,12 +1100,12 @@ function getImportsExpressionExp(path, hash, loc, context) {
1100
1100
  h.content === hashExp);
1101
1101
  });
1102
1102
  if (existingHoistIndex > -1) {
1103
- return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 2 /* CAN_HOIST */);
1103
+ return compilerCore.createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* CAN_STRINGIFY */);
1104
1104
  }
1105
- return context.hoist(compilerCore.createSimpleExpression(hashExp, false, loc, 2 /* CAN_HOIST */));
1105
+ return context.hoist(compilerCore.createSimpleExpression(hashExp, false, loc, 3 /* CAN_STRINGIFY */));
1106
1106
  }
1107
1107
  else {
1108
- return compilerCore.createSimpleExpression(`''`, false, loc, 2 /* CAN_HOIST */);
1108
+ return compilerCore.createSimpleExpression(`''`, false, loc, 3 /* CAN_STRINGIFY */);
1109
1109
  }
1110
1110
  }
1111
1111
 
@@ -1134,7 +1134,7 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1134
1134
  .split(' ', 2);
1135
1135
  return { url, descriptor };
1136
1136
  });
1137
- // data urls contains comma after the ecoding so we need to re-merge
1137
+ // data urls contains comma after the encoding so we need to re-merge
1138
1138
  // them
1139
1139
  for (let i = 0; i < imageCandidates.length; i++) {
1140
1140
  const { url } = imageCandidates[i];
@@ -1178,17 +1178,17 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1178
1178
  if (path) {
1179
1179
  const existingImportsIndex = context.imports.findIndex(i => i.path === path);
1180
1180
  if (existingImportsIndex > -1) {
1181
- exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* CAN_HOIST */);
1181
+ exp = compilerCore.createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1182
1182
  }
1183
1183
  else {
1184
- exp = compilerCore.createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 2 /* CAN_HOIST */);
1184
+ exp = compilerCore.createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1185
1185
  context.imports.push({ exp, path });
1186
1186
  }
1187
1187
  compoundExpression.children.push(exp);
1188
1188
  }
1189
1189
  }
1190
1190
  else {
1191
- const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 2 /* CAN_HOIST */);
1191
+ const exp = compilerCore.createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* CAN_STRINGIFY */);
1192
1192
  compoundExpression.children.push(exp);
1193
1193
  }
1194
1194
  const isNotLast = imageCandidates.length - 1 > index;
@@ -1203,7 +1203,7 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1203
1203
  }
1204
1204
  });
1205
1205
  const hoisted = context.hoist(compoundExpression);
1206
- hoisted.constType = 2 /* CAN_HOIST */;
1206
+ hoisted.constType = 3 /* CAN_STRINGIFY */;
1207
1207
  node.props[index] = {
1208
1208
  type: 7 /* DIRECTIVE */,
1209
1209
  name: 'bind',
@@ -3486,7 +3486,7 @@ function compileScript(sfc, options) {
3486
3486
  };
3487
3487
  }
3488
3488
  else if (prop.value.type === 'Identifier') {
3489
- // simple destucture
3489
+ // simple destructure
3490
3490
  propsDestructuredBindings[propKey] = {
3491
3491
  local: prop.value.name
3492
3492
  };
@@ -3641,7 +3641,7 @@ function compileScript(sfc, options) {
3641
3641
  }
3642
3642
  /**
3643
3643
  * check defaults. If the default object is an object literal with only
3644
- * static properties, we can directly generate more optimzied default
3644
+ * static properties, we can directly generate more optimized default
3645
3645
  * declarations. Otherwise we will have to fallback to runtime merging.
3646
3646
  */
3647
3647
  function hasStaticWithDefaults() {
@@ -4327,7 +4327,7 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
4327
4327
  }
4328
4328
  else {
4329
4329
  // ...rest
4330
- // argument can only be identifer when destructuring
4330
+ // argument can only be identifier when destructuring
4331
4331
  const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
4332
4332
  registerBinding(bindings, p.argument, type);
4333
4333
  }
@@ -4348,7 +4348,7 @@ function walkPattern(node, bindings, isConst, isDefineCall = false) {
4348
4348
  registerBinding(bindings, node, type);
4349
4349
  }
4350
4350
  else if (node.type === 'RestElement') {
4351
- // argument can only be identifer when destructuring
4351
+ // argument can only be identifier when destructuring
4352
4352
  const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
4353
4353
  registerBinding(bindings, node.argument, type);
4354
4354
  }
@@ -172,7 +172,7 @@ export declare interface SFCScriptBlock extends SFCBlock {
172
172
 
173
173
  export declare interface SFCScriptCompileOptions {
174
174
  /**
175
- * Scope ID for prefixing injected CSS varialbes.
175
+ * Scope ID for prefixing injected CSS variables.
176
176
  * This must be consistent with the `id` passed to `compileStyle`.
177
177
  */
178
178
  id: string;
@@ -214,7 +214,7 @@ export declare interface SFCScriptCompileOptions {
214
214
  inlineTemplate?: boolean;
215
215
  /**
216
216
  * Options for template compilation when inlining. Note these are options that
217
- * would normally be pased to `compiler-sfc`'s own `compileTemplate()`, not
217
+ * would normally be passed to `compiler-sfc`'s own `compileTemplate()`, not
218
218
  * options passed to `compiler-dom`.
219
219
  */
220
220
  templateOptions?: Partial<SFCTemplateCompileOptions>;
@@ -15925,7 +15925,6 @@ function getUnnormalizedProps(props, callPath = []) {
15925
15925
  }
15926
15926
  function injectProp(node, prop, context) {
15927
15927
  let propsWithInjection;
15928
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
15929
15928
  /**
15930
15929
  * 1. mergeProps(...)
15931
15930
  * 2. toHandlers(...)
@@ -15934,7 +15933,7 @@ function injectProp(node, prop, context) {
15934
15933
  *
15935
15934
  * we need to get the real props before normalization
15936
15935
  */
15937
- let props = originalProps;
15936
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
15938
15937
  let callPath = [];
15939
15938
  let parentCall;
15940
15939
  if (props &&
@@ -16942,15 +16941,6 @@ function isSingleElementRoot(root, child) {
16942
16941
  !isSlotOutlet(child));
16943
16942
  }
16944
16943
  function walk(node, context, doNotHoistNode = false) {
16945
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
16946
- // static bindings with expressions. These expressions are guaranteed to be
16947
- // constant so they are still eligible for hoisting, but they are only
16948
- // available at runtime and therefore cannot be evaluated ahead of time.
16949
- // This is only a concern for pre-stringification (via transformHoist by
16950
- // @vue/compiler-dom), but doing it here allows us to perform only one full
16951
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
16952
- // stringification threshold is met.
16953
- let canStringify = true;
16954
16944
  const { children } = node;
16955
16945
  const originalCount = children.length;
16956
16946
  let hoistedCount = 0;
@@ -16963,9 +16953,6 @@ function walk(node, context, doNotHoistNode = false) {
16963
16953
  ? 0 /* NOT_CONSTANT */
16964
16954
  : getConstantType(child, context);
16965
16955
  if (constantType > 0 /* NOT_CONSTANT */) {
16966
- if (constantType < 3 /* CAN_STRINGIFY */) {
16967
- canStringify = false;
16968
- }
16969
16956
  if (constantType >= 2 /* CAN_HOIST */) {
16970
16957
  child.codegenNode.patchFlag =
16971
16958
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -16996,17 +16983,10 @@ function walk(node, context, doNotHoistNode = false) {
16996
16983
  }
16997
16984
  }
16998
16985
  }
16999
- else if (child.type === 12 /* TEXT_CALL */) {
17000
- const contentType = getConstantType(child.content, context);
17001
- if (contentType > 0) {
17002
- if (contentType < 3 /* CAN_STRINGIFY */) {
17003
- canStringify = false;
17004
- }
17005
- if (contentType >= 2 /* CAN_HOIST */) {
17006
- child.codegenNode = context.hoist(child.codegenNode);
17007
- hoistedCount++;
17008
- }
17009
- }
16986
+ else if (child.type === 12 /* TEXT_CALL */ &&
16987
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
16988
+ child.codegenNode = context.hoist(child.codegenNode);
16989
+ hoistedCount++;
17010
16990
  }
17011
16991
  // walk further
17012
16992
  if (child.type === 1 /* ELEMENT */) {
@@ -17030,7 +17010,7 @@ function walk(node, context, doNotHoistNode = false) {
17030
17010
  }
17031
17011
  }
17032
17012
  }
17033
- if (canStringify && hoistedCount && context.transformHoist) {
17013
+ if (hoistedCount && context.transformHoist) {
17034
17014
  context.transformHoist(children, context, node);
17035
17015
  }
17036
17016
  // all children were hoisted - the entire children array is hoistable.
@@ -26893,6 +26873,11 @@ function hasMultipleChildren(node) {
26893
26873
  /**
26894
26874
  * This module is Node-only.
26895
26875
  */
26876
+ /**
26877
+ * Regex for replacing placeholders for embedded constant variables
26878
+ * (e.g. import URL string constants generated by compiler-sfc)
26879
+ */
26880
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
26896
26881
  /**
26897
26882
  * Turn eligible hoisted static trees into stringified static nodes, e.g.
26898
26883
  *
@@ -26929,7 +26914,7 @@ const stringifyStatic = (children, context, parent) => {
26929
26914
  ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
26930
26915
  // combine all currently eligible nodes into a single static vnode call
26931
26916
  const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
26932
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
26917
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
26933
26918
  // the 2nd argument indicates the number of DOM nodes this static vnode
26934
26919
  // will insert / hydrate
26935
26920
  String(currentChunk.length)
@@ -26997,7 +26982,7 @@ const replaceHoist = (node, replacement, context) => {
26997
26982
  const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
26998
26983
  /**
26999
26984
  * for a hoisted node, analyze it and return:
27000
- * - false: bailed (contains runtime constant)
26985
+ * - false: bailed (contains non-stringifiable props or runtime constant)
27001
26986
  * - [nc, ec] where
27002
26987
  * - nc is the number of nodes inside
27003
26988
  * - ec is the number of element with bindings inside
@@ -27035,6 +27020,11 @@ function analyzeNode(node) {
27035
27020
  (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
27036
27021
  return bail();
27037
27022
  }
27023
+ if (p.exp &&
27024
+ (p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
27025
+ p.exp.constType < 3 /* CAN_STRINGIFY */)) {
27026
+ return bail();
27027
+ }
27038
27028
  }
27039
27029
  }
27040
27030
  for (let i = 0; i < node.children.length; i++) {
@@ -27090,8 +27080,15 @@ function stringifyElement(node, context) {
27090
27080
  }
27091
27081
  }
27092
27082
  else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
27083
+ const exp = p.exp;
27084
+ if (exp.content[0] === '_') {
27085
+ // internally generated string constant references
27086
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
27087
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
27088
+ continue;
27089
+ }
27093
27090
  // constant v-bind, e.g. :foo="1"
27094
- let evaluated = evaluateConstant(p.exp);
27091
+ let evaluated = evaluateConstant(exp);
27095
27092
  if (evaluated != null) {
27096
27093
  const arg = p.arg && p.arg.content;
27097
27094
  if (arg === 'class') {
@@ -32884,7 +32881,7 @@ function getImportsExpressionExp(path, hash, loc, context) {
32884
32881
  }
32885
32882
  else {
32886
32883
  name = `_imports_${context.imports.length}`;
32887
- exp = createSimpleExpression(name, false, loc, 2 /* CAN_HOIST */);
32884
+ exp = createSimpleExpression(name, false, loc, 3 /* CAN_STRINGIFY */);
32888
32885
  context.imports.push({ exp, path });
32889
32886
  }
32890
32887
  if (!hash) {
@@ -32898,12 +32895,12 @@ function getImportsExpressionExp(path, hash, loc, context) {
32898
32895
  h.content === hashExp);
32899
32896
  });
32900
32897
  if (existingHoistIndex > -1) {
32901
- return createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 2 /* CAN_HOIST */);
32898
+ return createSimpleExpression(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3 /* CAN_STRINGIFY */);
32902
32899
  }
32903
- return context.hoist(createSimpleExpression(hashExp, false, loc, 2 /* CAN_HOIST */));
32900
+ return context.hoist(createSimpleExpression(hashExp, false, loc, 3 /* CAN_STRINGIFY */));
32904
32901
  }
32905
32902
  else {
32906
- return createSimpleExpression(`''`, false, loc, 2 /* CAN_HOIST */);
32903
+ return createSimpleExpression(`''`, false, loc, 3 /* CAN_STRINGIFY */);
32907
32904
  }
32908
32905
  }
32909
32906
 
@@ -32932,7 +32929,7 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
32932
32929
  .split(' ', 2);
32933
32930
  return { url, descriptor };
32934
32931
  });
32935
- // data urls contains comma after the ecoding so we need to re-merge
32932
+ // data urls contains comma after the encoding so we need to re-merge
32936
32933
  // them
32937
32934
  for (let i = 0; i < imageCandidates.length; i++) {
32938
32935
  const { url } = imageCandidates[i];
@@ -32976,17 +32973,17 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
32976
32973
  if (path) {
32977
32974
  const existingImportsIndex = context.imports.findIndex(i => i.path === path);
32978
32975
  if (existingImportsIndex > -1) {
32979
- exp = createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 2 /* CAN_HOIST */);
32976
+ exp = createSimpleExpression(`_imports_${existingImportsIndex}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
32980
32977
  }
32981
32978
  else {
32982
- exp = createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 2 /* CAN_HOIST */);
32979
+ exp = createSimpleExpression(`_imports_${context.imports.length}`, false, attr.loc, 3 /* CAN_STRINGIFY */);
32983
32980
  context.imports.push({ exp, path });
32984
32981
  }
32985
32982
  compoundExpression.children.push(exp);
32986
32983
  }
32987
32984
  }
32988
32985
  else {
32989
- const exp = createSimpleExpression(`"${url}"`, false, attr.loc, 2 /* CAN_HOIST */);
32986
+ const exp = createSimpleExpression(`"${url}"`, false, attr.loc, 3 /* CAN_STRINGIFY */);
32990
32987
  compoundExpression.children.push(exp);
32991
32988
  }
32992
32989
  const isNotLast = imageCandidates.length - 1 > index;
@@ -33001,7 +32998,7 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
33001
32998
  }
33002
32999
  });
33003
33000
  const hoisted = context.hoist(compoundExpression);
33004
- hoisted.constType = 2 /* CAN_HOIST */;
33001
+ hoisted.constType = 3 /* CAN_STRINGIFY */;
33005
33002
  node.props[index] = {
33006
33003
  type: 7 /* DIRECTIVE */,
33007
33004
  name: 'bind',
@@ -34975,7 +34972,7 @@ function compileScript(sfc, options) {
34975
34972
  };
34976
34973
  }
34977
34974
  else if (prop.value.type === 'Identifier') {
34978
- // simple destucture
34975
+ // simple destructure
34979
34976
  propsDestructuredBindings[propKey] = {
34980
34977
  local: prop.value.name
34981
34978
  };
@@ -35130,7 +35127,7 @@ function compileScript(sfc, options) {
35130
35127
  }
35131
35128
  /**
35132
35129
  * check defaults. If the default object is an object literal with only
35133
- * static properties, we can directly generate more optimzied default
35130
+ * static properties, we can directly generate more optimized default
35134
35131
  * declarations. Otherwise we will have to fallback to runtime merging.
35135
35132
  */
35136
35133
  function hasStaticWithDefaults() {
@@ -35816,7 +35813,7 @@ function walkObjectPattern(node, bindings, isConst, isDefineCall = false) {
35816
35813
  }
35817
35814
  else {
35818
35815
  // ...rest
35819
- // argument can only be identifer when destructuring
35816
+ // argument can only be identifier when destructuring
35820
35817
  const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
35821
35818
  registerBinding(bindings, p.argument, type);
35822
35819
  }
@@ -35837,7 +35834,7 @@ function walkPattern(node, bindings, isConst, isDefineCall = false) {
35837
35834
  registerBinding(bindings, node, type);
35838
35835
  }
35839
35836
  else if (node.type === 'RestElement') {
35840
- // argument can only be identifer when destructuring
35837
+ // argument can only be identifier when destructuring
35841
35838
  const type = isConst ? "setup-const" /* SETUP_CONST */ : "setup-let" /* SETUP_LET */;
35842
35839
  registerBinding(bindings, node.argument, type);
35843
35840
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.23",
3
+ "version": "3.2.24",
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.23",
37
- "@vue/compiler-dom": "3.2.23",
38
- "@vue/compiler-ssr": "3.2.23",
39
- "@vue/ref-transform": "3.2.23",
40
- "@vue/shared": "3.2.23",
36
+ "@vue/compiler-core": "3.2.24",
37
+ "@vue/compiler-dom": "3.2.24",
38
+ "@vue/compiler-ssr": "3.2.24",
39
+ "@vue/ref-transform": "3.2.24",
40
+ "@vue/shared": "3.2.24",
41
41
  "estree-walker": "^2.0.2",
42
42
  "magic-string": "^0.25.7",
43
43
  "source-map": "^0.6.1",