@tsrx/vue 0.1.4 → 0.1.7

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Vue compiler built on @tsrx/core",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.4",
6
+ "version": "0.1.7",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -28,10 +28,10 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "esrap": "^2.1.0",
31
+ "esrap": "^2.2.7",
32
32
  "is-reference": "^3.0.3",
33
33
  "zimmerframe": "^1.1.2",
34
- "@tsrx/core": "0.1.4"
34
+ "@tsrx/core": "0.1.7"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "vue": ">=3.5",
package/src/index.js CHANGED
@@ -65,6 +65,7 @@ export function compile_to_volar_mappings(source, filename, options) {
65
65
  const transformed = transform(ast, source, filename, {
66
66
  collect: true,
67
67
  loose: !!options?.loose,
68
+ moduleScopedHookComponents: false,
68
69
  typeOnly: true,
69
70
  errors,
70
71
  comments,
package/src/transform.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  builders,
7
7
  clone_expression_node,
8
8
  clone_identifier,
9
+ contains_component_jsx,
9
10
  CREATE_REF_PROP_INTERNAL_NAME,
10
11
  create_generated_identifier,
11
12
  componentToFunctionDeclaration,
@@ -47,6 +48,13 @@ const vue_platform = {
47
48
  'Vue TSRX does not support `pending` blocks in component templates yet. Vue Suspense uses fallback slots rather than a `fallback` prop, so `try { ... } pending { ... }` cannot be lowered correctly for this target yet.',
48
49
  },
49
50
  hooks: {
51
+ // Hoist to module scope
52
+ // in the regular client transform — same trade-off as React, where one
53
+ // definition per helper keeps bundles small and source mappings 1:1
54
+ // for editor IntelliSense. The `compile_to_volar_mappings` entry point
55
+ // opts back out so Volar's type-only output keeps helpers inline,
56
+ // matching how it generates virtual TSX today.
57
+ moduleScopedHookComponents: true,
50
58
  initialState: () => ({
51
59
  needs_define_vapor_component: false,
52
60
  needs_vapor_for: false,
@@ -1038,59 +1046,6 @@ function to_jsx_expression_container(expression, source_node = expression) {
1038
1046
  return builders.jsx_expression_container(expression, source_node);
1039
1047
  }
1040
1048
 
1041
- /**
1042
- * @param {any} node
1043
- * @returns {boolean}
1044
- */
1045
- function contains_component_jsx(node) {
1046
- if (!node || typeof node !== 'object') {
1047
- return false;
1048
- }
1049
-
1050
- if (node.type === 'JSXElement') {
1051
- if (is_component_jsx_name(node.openingElement?.name)) {
1052
- return true;
1053
- }
1054
-
1055
- return node.children.some(contains_component_jsx);
1056
- }
1057
-
1058
- if (node.type === 'JSXFragment') {
1059
- return node.children.some(contains_component_jsx);
1060
- }
1061
-
1062
- if (node.type === 'JSXExpressionContainer') {
1063
- return contains_component_jsx(node.expression);
1064
- }
1065
-
1066
- if (Array.isArray(node)) {
1067
- return node.some(contains_component_jsx);
1068
- }
1069
-
1070
- return false;
1071
- }
1072
-
1073
- /**
1074
- * @param {any} name
1075
- * @returns {boolean}
1076
- */
1077
- function is_component_jsx_name(name) {
1078
- if (!name || typeof name !== 'object') {
1079
- return false;
1080
- }
1081
-
1082
- if (name.type === 'JSXIdentifier') {
1083
- const first = name.name?.[0];
1084
- return first != null && first >= 'A' && first <= 'Z';
1085
- }
1086
-
1087
- if (name.type === 'JSXMemberExpression') {
1088
- return true;
1089
- }
1090
-
1091
- return false;
1092
- }
1093
-
1094
1049
  /**
1095
1050
  * @param {import('estree').Program} program
1096
1051
  * @param {any} transform_context