@vue/compiler-sfc 3.2.34 → 3.2.35

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.
@@ -3295,6 +3295,7 @@ function rewriteDefault(input, as, parserPlugins) {
3295
3295
  plugins: parserPlugins
3296
3296
  }).program.body;
3297
3297
  ast.forEach(node => {
3298
+ var _a;
3298
3299
  if (node.type === 'ExportDefaultDeclaration') {
3299
3300
  s.overwrite(node.start, node.declaration.start, `const ${as} = `);
3300
3301
  }
@@ -3313,7 +3314,7 @@ function rewriteDefault(input, as, parserPlugins) {
3313
3314
  }
3314
3315
  else {
3315
3316
  const end = specifierEnd(input, specifier.exported.end, node.end);
3316
- s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${node.source?.value}'\n`);
3317
+ s.prepend(`import { ${input.slice(specifier.local.start, specifier.local.end)} } from '${(_a = node.source) === null || _a === void 0 ? void 0 : _a.value}'\n`);
3317
3318
  s.overwrite(specifier.start, end, ``);
3318
3319
  s.append(`\nconst ${as} = ${specifier.local.name}`);
3319
3320
  continue;
@@ -3358,13 +3359,14 @@ const DEFINE_EXPOSE = 'defineExpose';
3358
3359
  const WITH_DEFAULTS = 'withDefaults';
3359
3360
  // constants
3360
3361
  const DEFAULT_VAR = `__default__`;
3361
- const isBuiltInDir = shared.makeMap(`once,memo,if,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
3362
+ const isBuiltInDir = shared.makeMap(`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
3362
3363
  /**
3363
3364
  * Compile `<script setup>`
3364
3365
  * It requires the whole SFC descriptor because we need to handle and merge
3365
3366
  * normal `<script>` + `<script setup>` if both are present.
3366
3367
  */
3367
3368
  function compileScript(sfc, options) {
3369
+ var _a;
3368
3370
  let { script, scriptSetup, source, filename } = sfc;
3369
3371
  // feature flags
3370
3372
  // TODO remove support for deprecated options when out of experimental
@@ -4237,7 +4239,7 @@ function compileScript(sfc, options) {
4237
4239
  // 8. inject `useCssVars` calls
4238
4240
  if (cssVars.length &&
4239
4241
  // no need to do this when targeting SSR
4240
- !(options.inlineTemplate && options.templateOptions?.ssr)) {
4242
+ !(options.inlineTemplate && ((_a = options.templateOptions) === null || _a === void 0 ? void 0 : _a.ssr))) {
4241
4243
  helperImports.add(CSS_VARS_HELPER);
4242
4244
  helperImports.add('unref');
4243
4245
  s.prependRight(startOffset, `\n${genCssVarsCode(cssVars, bindingMetadata, scopeId, isProd)}\n`);
@@ -4445,8 +4447,8 @@ function compileScript(sfc, options) {
4445
4447
  includeContent: true
4446
4448
  })
4447
4449
  : undefined,
4448
- scriptAst: scriptAst?.body,
4449
- scriptSetupAst: scriptSetupAst?.body
4450
+ scriptAst: scriptAst === null || scriptAst === void 0 ? void 0 : scriptAst.body,
4451
+ scriptSetupAst: scriptSetupAst === null || scriptSetupAst === void 0 ? void 0 : scriptSetupAst.body
4450
4452
  };
4451
4453
  }
4452
4454
  function registerBinding(bindings, node, type) {
@@ -4889,7 +4891,7 @@ function resolveTemplateUsageCheckString(sfc) {
4889
4891
  code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
4890
4892
  }
4891
4893
  if (prop.exp) {
4892
- code += `,${processExp(prop.exp.content)}`;
4894
+ code += `,${processExp(prop.exp.content, prop.name)}`;
4893
4895
  }
4894
4896
  }
4895
4897
  }
@@ -4904,8 +4906,19 @@ function resolveTemplateUsageCheckString(sfc) {
4904
4906
  templateUsageCheckCache.set(content, code);
4905
4907
  return code;
4906
4908
  }
4907
- function processExp(exp) {
4908
- if (/ as \w|<.*>/.test(exp)) {
4909
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
4910
+ function processExp(exp, dir) {
4911
+ if (/ as\s+\w|<.*>|:/.test(exp)) {
4912
+ if (dir === 'slot') {
4913
+ exp = `(${exp})=>{}`;
4914
+ }
4915
+ else if (dir === 'for') {
4916
+ const inMatch = exp.match(forAliasRE);
4917
+ if (inMatch) {
4918
+ const [, LHS, RHS] = inMatch;
4919
+ return processExp(`(${LHS})=>{}`) + processExp(RHS);
4920
+ }
4921
+ }
4909
4922
  let ret = '';
4910
4923
  // has potential type cast or generic arguments that uses types
4911
4924
  const ast = parser$2.parseExpression(exp, { plugins: ['typescript'] });
@@ -35385,7 +35385,7 @@ const DEFINE_EXPOSE = 'defineExpose';
35385
35385
  const WITH_DEFAULTS = 'withDefaults';
35386
35386
  // constants
35387
35387
  const DEFAULT_VAR = `__default__`;
35388
- const isBuiltInDir = makeMap(`once,memo,if,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
35388
+ const isBuiltInDir = makeMap(`once,memo,if,for,else,else-if,slot,text,html,on,bind,model,show,cloak,is`);
35389
35389
  /**
35390
35390
  * Compile `<script setup>`
35391
35391
  * It requires the whole SFC descriptor because we need to handle and merge
@@ -36888,7 +36888,7 @@ function resolveTemplateUsageCheckString(sfc) {
36888
36888
  code += `,v${capitalize(camelize(prop.name))}`;
36889
36889
  }
36890
36890
  if (prop.exp) {
36891
- code += `,${processExp(prop.exp.content)}`;
36891
+ code += `,${processExp(prop.exp.content, prop.name)}`;
36892
36892
  }
36893
36893
  }
36894
36894
  }
@@ -36903,8 +36903,19 @@ function resolveTemplateUsageCheckString(sfc) {
36903
36903
  templateUsageCheckCache.set(content, code);
36904
36904
  return code;
36905
36905
  }
36906
- function processExp(exp) {
36907
- if (/ as \w|<.*>/.test(exp)) {
36906
+ const forAliasRE$1 = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
36907
+ function processExp(exp, dir) {
36908
+ if (/ as\s+\w|<.*>|:/.test(exp)) {
36909
+ if (dir === 'slot') {
36910
+ exp = `(${exp})=>{}`;
36911
+ }
36912
+ else if (dir === 'for') {
36913
+ const inMatch = exp.match(forAliasRE$1);
36914
+ if (inMatch) {
36915
+ const [, LHS, RHS] = inMatch;
36916
+ return processExp(`(${LHS})=>{}`) + processExp(RHS);
36917
+ }
36918
+ }
36908
36919
  let ret = '';
36909
36920
  // has potential type cast or generic arguments that uses types
36910
36921
  const ast = parseExpression_1(exp, { plugins: ['typescript'] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.34",
3
+ "version": "3.2.35",
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/core/tree/main/packages/compiler-sfc#readme",
34
34
  "dependencies": {
35
35
  "@babel/parser": "^7.16.4",
36
- "@vue/compiler-core": "3.2.34",
37
- "@vue/compiler-dom": "3.2.34",
38
- "@vue/compiler-ssr": "3.2.34",
39
- "@vue/reactivity-transform": "3.2.34",
40
- "@vue/shared": "3.2.34",
36
+ "@vue/compiler-core": "3.2.35",
37
+ "@vue/compiler-dom": "3.2.35",
38
+ "@vue/compiler-ssr": "3.2.35",
39
+ "@vue/reactivity-transform": "3.2.35",
40
+ "@vue/shared": "3.2.35",
41
41
  "estree-walker": "^2.0.2",
42
42
  "magic-string": "^0.25.7",
43
43
  "source-map": "^0.6.1",