@vue/compiler-sfc 3.5.0-beta.2 → 3.5.0-rc.1

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.0-beta.2
2
+ * @vue/compiler-sfc v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1917,7 +1917,7 @@ function parse$2(source, options = {}) {
1917
1917
  if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
1918
1918
  errors.push(
1919
1919
  new SyntaxError(
1920
- `At least one <template> or <script> is required in a single file component.`
1920
+ `At least one <template> or <script> is required in a single file component. ${descriptor.filename}`
1921
1921
  )
1922
1922
  );
1923
1923
  }
@@ -6940,7 +6940,7 @@ tokenTypes.combinator = combinator$1;
6940
6940
  }
6941
6941
  // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
6942
6942
  var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
6943
- if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
6943
+ if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
6944
6944
  var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
6945
6945
  if (nodes.length > 0) {
6946
6946
  var last = this.current.last;
@@ -17973,6 +17973,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
17973
17973
  );
17974
17974
  }
17975
17975
  case "TSExpressionWithTypeArguments":
17976
+ // referenced by interface extends
17976
17977
  case "TSTypeReference": {
17977
17978
  const typeName = getReferenceName(node);
17978
17979
  if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
@@ -18634,7 +18635,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
18634
18635
  return fs.realpath ? fs.realpath(filename) : filename;
18635
18636
  }
18636
18637
  }
18637
- function loadTSConfig(configPath, ts2, fs) {
18638
+ function loadTSConfig(configPath, ts2, fs, visited = /* @__PURE__ */ new Set()) {
18638
18639
  const parseConfigHost = ts2.sys;
18639
18640
  const config = ts2.parseJsonConfigFileContent(
18640
18641
  ts2.readConfigFile(configPath, fs.readFile).config,
@@ -18644,14 +18645,15 @@ function loadTSConfig(configPath, ts2, fs) {
18644
18645
  configPath
18645
18646
  );
18646
18647
  const res = [config];
18648
+ visited.add(configPath);
18647
18649
  if (config.projectReferences) {
18648
18650
  for (const ref of config.projectReferences) {
18649
18651
  const refPath = ts2.resolveProjectReferencePath(ref);
18650
- if (!fs.fileExists(refPath)) {
18652
+ if (visited.has(refPath) || !fs.fileExists(refPath)) {
18651
18653
  continue;
18652
18654
  }
18653
18655
  tsConfigRefMap.set(refPath, configPath);
18654
- res.unshift(...loadTSConfig(refPath, ts2, fs));
18656
+ res.unshift(...loadTSConfig(refPath, ts2, fs, visited));
18655
18657
  }
18656
18658
  }
18657
18659
  return res;
@@ -19021,6 +19023,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
19021
19023
  case "ConstructorParameters":
19022
19024
  case "ReadonlyArray":
19023
19025
  return ["String", "Number"];
19026
+ // TS built-in utility types
19024
19027
  case "Record":
19025
19028
  case "Partial":
19026
19029
  case "Required":
@@ -19074,6 +19077,8 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
19074
19077
  case "Promise":
19075
19078
  case "Error":
19076
19079
  return [node.typeName.name];
19080
+ // TS built-in utility types
19081
+ // https://www.typescriptlang.org/docs/handbook/utility-types.html
19077
19082
  case "Partial":
19078
19083
  case "Required":
19079
19084
  case "Readonly":
@@ -19170,6 +19175,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
19170
19175
  }
19171
19176
  break;
19172
19177
  }
19178
+ // e.g. readonly
19173
19179
  case "TSTypeOperator": {
19174
19180
  return inferRuntimeType(
19175
19181
  ctx,
@@ -20835,12 +20841,14 @@ function isStaticNode(node) {
20835
20841
  case "UnaryExpression":
20836
20842
  return isStaticNode(node.argument);
20837
20843
  case "LogicalExpression":
20844
+ // 1 > 2
20838
20845
  case "BinaryExpression":
20839
20846
  return isStaticNode(node.left) && isStaticNode(node.right);
20840
20847
  case "ConditionalExpression": {
20841
20848
  return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
20842
20849
  }
20843
20850
  case "SequenceExpression":
20851
+ // (1, 2)
20844
20852
  case "TemplateLiteral":
20845
20853
  return node.expressions.every((expr) => isStaticNode(expr));
20846
20854
  case "ParenthesizedExpression":
@@ -20855,7 +20863,7 @@ function isStaticNode(node) {
20855
20863
  return false;
20856
20864
  }
20857
20865
 
20858
- const version = "3.5.0-beta.2";
20866
+ const version = "3.5.0-rc.1";
20859
20867
  const parseCache = parseCache$1;
20860
20868
  const errorMessages = {
20861
20869
  ...CompilerDOM.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.0-beta.2
2
+ * @vue/compiler-sfc v3.5.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -16796,6 +16796,9 @@ const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || no
16796
16796
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
16797
16797
  function isReferenced(node, parent, grandparent) {
16798
16798
  switch (parent.type) {
16799
+ // yes: PARENT[NODE]
16800
+ // yes: NODE.child
16801
+ // no: parent.NODE
16799
16802
  case "MemberExpression":
16800
16803
  case "OptionalMemberExpression":
16801
16804
  if (parent.property === node) {
@@ -16804,12 +16807,23 @@ function isReferenced(node, parent, grandparent) {
16804
16807
  return parent.object === node;
16805
16808
  case "JSXMemberExpression":
16806
16809
  return parent.object === node;
16810
+ // no: let NODE = init;
16811
+ // yes: let id = NODE;
16807
16812
  case "VariableDeclarator":
16808
16813
  return parent.init === node;
16814
+ // yes: () => NODE
16815
+ // no: (NODE) => {}
16809
16816
  case "ArrowFunctionExpression":
16810
16817
  return parent.body === node;
16818
+ // no: class { #NODE; }
16819
+ // no: class { get #NODE() {} }
16820
+ // no: class { #NODE() {} }
16821
+ // no: class { fn() { return this.#NODE; } }
16811
16822
  case "PrivateName":
16812
16823
  return false;
16824
+ // no: class { NODE() {} }
16825
+ // yes: class { [NODE]() {} }
16826
+ // no: class { foo(NODE) {} }
16813
16827
  case "ClassMethod":
16814
16828
  case "ClassPrivateMethod":
16815
16829
  case "ObjectMethod":
@@ -16817,11 +16831,18 @@ function isReferenced(node, parent, grandparent) {
16817
16831
  return !!parent.computed;
16818
16832
  }
16819
16833
  return false;
16834
+ // yes: { [NODE]: "" }
16835
+ // no: { NODE: "" }
16836
+ // depends: { NODE }
16837
+ // depends: { key: NODE }
16820
16838
  case "ObjectProperty":
16821
16839
  if (parent.key === node) {
16822
16840
  return !!parent.computed;
16823
16841
  }
16824
16842
  return !grandparent;
16843
+ // no: class { NODE = value; }
16844
+ // yes: class { [NODE] = value; }
16845
+ // yes: class { key = NODE; }
16825
16846
  case "ClassProperty":
16826
16847
  if (parent.key === node) {
16827
16848
  return !!parent.computed;
@@ -16829,47 +16850,80 @@ function isReferenced(node, parent, grandparent) {
16829
16850
  return true;
16830
16851
  case "ClassPrivateProperty":
16831
16852
  return parent.key !== node;
16853
+ // no: class NODE {}
16854
+ // yes: class Foo extends NODE {}
16832
16855
  case "ClassDeclaration":
16833
16856
  case "ClassExpression":
16834
16857
  return parent.superClass === node;
16858
+ // yes: left = NODE;
16859
+ // no: NODE = right;
16835
16860
  case "AssignmentExpression":
16836
16861
  return parent.right === node;
16862
+ // no: [NODE = foo] = [];
16863
+ // yes: [foo = NODE] = [];
16837
16864
  case "AssignmentPattern":
16838
16865
  return parent.right === node;
16866
+ // no: NODE: for (;;) {}
16839
16867
  case "LabeledStatement":
16840
16868
  return false;
16869
+ // no: try {} catch (NODE) {}
16841
16870
  case "CatchClause":
16842
16871
  return false;
16872
+ // no: function foo(...NODE) {}
16843
16873
  case "RestElement":
16844
16874
  return false;
16845
16875
  case "BreakStatement":
16846
16876
  case "ContinueStatement":
16847
16877
  return false;
16878
+ // no: function NODE() {}
16879
+ // no: function foo(NODE) {}
16848
16880
  case "FunctionDeclaration":
16849
16881
  case "FunctionExpression":
16850
16882
  return false;
16883
+ // no: export NODE from "foo";
16884
+ // no: export * as NODE from "foo";
16851
16885
  case "ExportNamespaceSpecifier":
16852
16886
  case "ExportDefaultSpecifier":
16853
16887
  return false;
16888
+ // no: export { foo as NODE };
16889
+ // yes: export { NODE as foo };
16890
+ // no: export { NODE as foo } from "foo";
16854
16891
  case "ExportSpecifier":
16855
16892
  return parent.local === node;
16893
+ // no: import NODE from "foo";
16894
+ // no: import * as NODE from "foo";
16895
+ // no: import { NODE as foo } from "foo";
16896
+ // no: import { foo as NODE } from "foo";
16897
+ // no: import NODE from "bar";
16856
16898
  case "ImportDefaultSpecifier":
16857
16899
  case "ImportNamespaceSpecifier":
16858
16900
  case "ImportSpecifier":
16859
16901
  return false;
16902
+ // no: import "foo" assert { NODE: "json" }
16860
16903
  case "ImportAttribute":
16861
16904
  return false;
16905
+ // no: <div NODE="foo" />
16862
16906
  case "JSXAttribute":
16863
16907
  return false;
16908
+ // no: [NODE] = [];
16909
+ // no: ({ NODE }) = [];
16864
16910
  case "ObjectPattern":
16865
16911
  case "ArrayPattern":
16866
16912
  return false;
16913
+ // no: new.NODE
16914
+ // no: NODE.target
16867
16915
  case "MetaProperty":
16868
16916
  return false;
16917
+ // yes: type X = { someProperty: NODE }
16918
+ // no: type X = { NODE: OtherType }
16869
16919
  case "ObjectTypeProperty":
16870
16920
  return parent.key !== node;
16921
+ // yes: enum X { Foo = NODE }
16922
+ // no: enum X { NODE }
16871
16923
  case "TSEnumMember":
16872
16924
  return parent.id !== node;
16925
+ // yes: { [NODE]: value }
16926
+ // no: { NODE: value }
16873
16927
  case "TSPropertySignature":
16874
16928
  if (parent.key === node) {
16875
16929
  return !!parent.computed;
@@ -17519,7 +17573,9 @@ const tokenizer$2 = new Tokenizer$1(stack, {
17519
17573
  case 17:
17520
17574
  case 18:
17521
17575
  case 19:
17576
+ // "
17522
17577
  case 20:
17578
+ // '
17523
17579
  case 21:
17524
17580
  emitError(9, end);
17525
17581
  break;
@@ -18468,6 +18524,7 @@ function traverseNode(node, context) {
18468
18524
  context.helper(TO_DISPLAY_STRING);
18469
18525
  }
18470
18526
  break;
18527
+ // for container types, further traverse downwards
18471
18528
  case 9:
18472
18529
  for (let i2 = 0; i2 < node.branches.length; i2++) {
18473
18530
  traverseNode(node.branches[i2], context);
@@ -22283,6 +22340,7 @@ function genNode(node, context) {
22283
22340
  case 21:
22284
22341
  genNodeList(node.body, context, true, false);
22285
22342
  break;
22343
+ // SSR only types
22286
22344
  case 22:
22287
22345
  genTemplateLiteral(node, context);
22288
22346
  break;
@@ -22298,6 +22356,7 @@ function genNode(node, context) {
22298
22356
  case 26:
22299
22357
  genReturnStatement(node, context);
22300
22358
  break;
22359
+ /* v8 ignore start */
22301
22360
  case 10:
22302
22361
  break;
22303
22362
  default:
@@ -26674,7 +26733,7 @@ function parse$7(source, options = {}) {
26674
26733
  if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
26675
26734
  errors.push(
26676
26735
  new SyntaxError(
26677
- `At least one <template> or <script> is required in a single file component.`
26736
+ `At least one <template> or <script> is required in a single file component. ${descriptor.filename}`
26678
26737
  )
26679
26738
  );
26680
26739
  }
@@ -39666,7 +39725,7 @@ tokenTypes.combinator = combinator$1;
39666
39725
  }
39667
39726
  // We need to decide between a space that's a descendant combinator and meaningless whitespace at the end of a selector.
39668
39727
  var nextSigTokenPos = this.locateNextMeaningfulToken(this.position);
39669
- if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma) {
39728
+ if (nextSigTokenPos < 0 || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.comma || this.tokens[nextSigTokenPos][_tokenize.FIELDS.TYPE] === tokens.closeParenthesis) {
39670
39729
  var nodes = this.parseWhitespaceEquivalentTokens(nextSigTokenPos);
39671
39730
  if (nodes.length > 0) {
39672
39731
  var last = this.current.last;
@@ -45963,6 +46022,7 @@ function innerResolveTypeElements(ctx, node, scope, typeParameters) {
45963
46022
  );
45964
46023
  }
45965
46024
  case "TSExpressionWithTypeArguments":
46025
+ // referenced by interface extends
45966
46026
  case "TSTypeReference": {
45967
46027
  const typeName = getReferenceName(node);
45968
46028
  if ((typeName === "ExtractPropTypes" || typeName === "ExtractPublicPropTypes") && node.typeParameters && ((_a = scope.imports[typeName]) == null ? void 0 : _a.source) === "vue") {
@@ -46923,6 +46983,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
46923
46983
  case "ConstructorParameters":
46924
46984
  case "ReadonlyArray":
46925
46985
  return ["String", "Number"];
46986
+ // TS built-in utility types
46926
46987
  case "Record":
46927
46988
  case "Partial":
46928
46989
  case "Required":
@@ -46976,6 +47037,8 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
46976
47037
  case "Promise":
46977
47038
  case "Error":
46978
47039
  return [node.typeName.name];
47040
+ // TS built-in utility types
47041
+ // https://www.typescriptlang.org/docs/handbook/utility-types.html
46979
47042
  case "Partial":
46980
47043
  case "Required":
46981
47044
  case "Readonly":
@@ -47072,6 +47135,7 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
47072
47135
  }
47073
47136
  break;
47074
47137
  }
47138
+ // e.g. readonly
47075
47139
  case "TSTypeOperator": {
47076
47140
  return inferRuntimeType(
47077
47141
  ctx,
@@ -48751,12 +48815,14 @@ function isStaticNode(node) {
48751
48815
  case "UnaryExpression":
48752
48816
  return isStaticNode(node.argument);
48753
48817
  case "LogicalExpression":
48818
+ // 1 > 2
48754
48819
  case "BinaryExpression":
48755
48820
  return isStaticNode(node.left) && isStaticNode(node.right);
48756
48821
  case "ConditionalExpression": {
48757
48822
  return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
48758
48823
  }
48759
48824
  case "SequenceExpression":
48825
+ // (1, 2)
48760
48826
  case "TemplateLiteral":
48761
48827
  return node.expressions.every((expr) => isStaticNode(expr));
48762
48828
  case "ParenthesizedExpression":
@@ -48787,7 +48853,7 @@ var __spreadValues = (a, b) => {
48787
48853
  }
48788
48854
  return a;
48789
48855
  };
48790
- const version = "3.5.0-beta.2";
48856
+ const version = "3.5.0-rc.1";
48791
48857
  const parseCache = parseCache$1;
48792
48858
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48793
48859
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.5.0-beta.2",
3
+ "version": "3.5.0-rc.1",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -47,10 +47,10 @@
47
47
  "magic-string": "^0.30.11",
48
48
  "postcss": "^8.4.41",
49
49
  "source-map-js": "^1.2.0",
50
- "@vue/compiler-core": "3.5.0-beta.2",
51
- "@vue/compiler-ssr": "3.5.0-beta.2",
52
- "@vue/compiler-dom": "3.5.0-beta.2",
53
- "@vue/shared": "3.5.0-beta.2"
50
+ "@vue/compiler-core": "3.5.0-rc.1",
51
+ "@vue/compiler-dom": "3.5.0-rc.1",
52
+ "@vue/shared": "3.5.0-rc.1",
53
+ "@vue/compiler-ssr": "3.5.0-rc.1"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.25.2",
@@ -60,7 +60,7 @@
60
60
  "merge-source-map": "^1.1.0",
61
61
  "minimatch": "~9.0.5",
62
62
  "postcss-modules": "^6.0.0",
63
- "postcss-selector-parser": "^6.1.1",
63
+ "postcss-selector-parser": "^6.1.2",
64
64
  "pug": "^3.0.3",
65
65
  "sass": "^1.77.8"
66
66
  }