@tsrx/typescript-plugin 0.3.29 → 0.3.31
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/CHANGELOG.md +25 -0
- package/package.json +19 -3
- package/src/language.js +6 -0
- package/tests/compiler-resolution.test.js +33 -2
- package/tests/workspace-fixtures.js +89 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @tsrx/typescript-plugin
|
|
2
2
|
|
|
3
|
+
## 0.3.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#941](https://github.com/Ripple-TS/ripple/pull/941)
|
|
8
|
+
[`079617d`](https://github.com/Ripple-TS/ripple/commit/079617d639569e4cb2c79239011a6b892dbdbb45)
|
|
9
|
+
Thanks [@leonidaz](https://github.com/leonidaz)! - Add Preact compiler
|
|
10
|
+
resolution for `.tsrx` language service support.
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
[[`7529e1f`](https://github.com/Ripple-TS/ripple/commit/7529e1fe3f0870319bd3399501fd2eb43c516065)]:
|
|
14
|
+
- @tsrx/react@0.1.5
|
|
15
|
+
- @tsrx/preact@0.0.6
|
|
16
|
+
- @tsrx/solid@0.0.11
|
|
17
|
+
- @tsrx/ripple@0.0.13
|
|
18
|
+
|
|
19
|
+
## 0.3.30
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
[[`7f59ed8`](https://github.com/Ripple-TS/ripple/commit/7f59ed80d7b44c847fb9eb8bf00d4fe9835c3136)]:
|
|
25
|
+
- @tsrx/ripple@0.0.12
|
|
26
|
+
- @tsrx/react@0.1.4
|
|
27
|
+
|
|
3
28
|
## 0.3.29
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "TypeScript plugin for TSRX",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.31",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"homepage": "https://ripple-ts.com",
|
|
@@ -25,8 +25,24 @@
|
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"typescript": "^5.9.3",
|
|
28
|
-
"@tsrx/react": "0.1.
|
|
29
|
-
"@tsrx/ripple": "0.0.
|
|
28
|
+
"@tsrx/react": "0.1.5",
|
|
29
|
+
"@tsrx/ripple": "0.0.13",
|
|
30
|
+
"@tsrx/solid": "0.0.11",
|
|
31
|
+
"@tsrx/preact": "0.0.6"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"@tsrx/react": {
|
|
35
|
+
"optional": true
|
|
36
|
+
},
|
|
37
|
+
"@tsrx/solid": {
|
|
38
|
+
"optional": true
|
|
39
|
+
},
|
|
40
|
+
"@tsrx/ripple": {
|
|
41
|
+
"optional": true
|
|
42
|
+
},
|
|
43
|
+
"@tsrx/preact": {
|
|
44
|
+
"optional": true
|
|
45
|
+
}
|
|
30
46
|
},
|
|
31
47
|
"publishConfig": {
|
|
32
48
|
"access": "public"
|
package/src/language.js
CHANGED
|
@@ -48,6 +48,12 @@ export const COMPILER_CANDIDATES = [
|
|
|
48
48
|
['.tsrx'],
|
|
49
49
|
['@tsrx/solid', '@tsrx/vite-plugin-solid'],
|
|
50
50
|
],
|
|
51
|
+
[
|
|
52
|
+
'@tsrx/preact',
|
|
53
|
+
['node_modules', '@tsrx', 'preact'],
|
|
54
|
+
['.tsrx'],
|
|
55
|
+
['@tsrx/preact', '@tsrx/vite-plugin-preact'],
|
|
56
|
+
],
|
|
51
57
|
];
|
|
52
58
|
|
|
53
59
|
/**
|
|
@@ -27,20 +27,28 @@ describe('typescript-plugin compiler resolution', () => {
|
|
|
27
27
|
expect(RIPPLE_EXTENSIONS).toEqual(['.tsrx']);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it('maps
|
|
30
|
+
it('maps all compiler candidates to .tsrx', () => {
|
|
31
31
|
const ripple_candidate = COMPILER_CANDIDATES.find(
|
|
32
32
|
([package_name]) => package_name === '@tsrx/ripple',
|
|
33
33
|
);
|
|
34
34
|
const react_candidate = COMPILER_CANDIDATES.find(
|
|
35
35
|
([package_name]) => package_name === '@tsrx/react',
|
|
36
36
|
);
|
|
37
|
+
const solid_candidate = COMPILER_CANDIDATES.find(
|
|
38
|
+
([package_name]) => package_name === '@tsrx/solid',
|
|
39
|
+
);
|
|
40
|
+
const preact_candidate = COMPILER_CANDIDATES.find(
|
|
41
|
+
([package_name]) => package_name === '@tsrx/preact',
|
|
42
|
+
);
|
|
37
43
|
|
|
38
|
-
if (!ripple_candidate || !react_candidate) {
|
|
44
|
+
if (!ripple_candidate || !react_candidate || !solid_candidate || !preact_candidate) {
|
|
39
45
|
throw new Error('Missing compiler candidates');
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
expect(ripple_candidate[2]).toEqual(['.tsrx']);
|
|
43
49
|
expect(react_candidate[2]).toEqual(['.tsrx']);
|
|
50
|
+
expect(solid_candidate[2]).toEqual(['.tsrx']);
|
|
51
|
+
expect(preact_candidate[2]).toEqual(['.tsrx']);
|
|
44
52
|
});
|
|
45
53
|
});
|
|
46
54
|
|
|
@@ -81,6 +89,16 @@ describe('typescript-plugin compiler resolution', () => {
|
|
|
81
89
|
);
|
|
82
90
|
});
|
|
83
91
|
|
|
92
|
+
it('selects the preact compiler in a preact-only project', () => {
|
|
93
|
+
const workspace = create_fixture_workspace('preact-only');
|
|
94
|
+
const file_name = path.join(workspace, 'src', 'App.tsrx');
|
|
95
|
+
const expected = path.join(workspace, 'node_modules', '@tsrx', 'preact', 'src', 'index.js');
|
|
96
|
+
|
|
97
|
+
expect(find_workspace_compiler_entry_for_file(file_name, fs.existsSync, new Map())).toBe(
|
|
98
|
+
expected,
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
84
102
|
it('prefers the ripple compiler when both compilers exist in a ripple project', () => {
|
|
85
103
|
const workspace = create_fixture_workspace('both');
|
|
86
104
|
const file_name = path.join(workspace, 'src', 'App.tsrx');
|
|
@@ -101,6 +119,16 @@ describe('typescript-plugin compiler resolution', () => {
|
|
|
101
119
|
);
|
|
102
120
|
});
|
|
103
121
|
|
|
122
|
+
it('prefers the preact compiler when multiple compilers exist in a preact project', () => {
|
|
123
|
+
const workspace = create_fixture_workspace('both-preact');
|
|
124
|
+
const file_name = path.join(workspace, 'src', 'App.tsrx');
|
|
125
|
+
const expected = path.join(workspace, 'node_modules', '@tsrx', 'preact', 'src', 'index.js');
|
|
126
|
+
|
|
127
|
+
expect(find_workspace_compiler_entry_for_file(file_name, fs.existsSync, new Map())).toBe(
|
|
128
|
+
expected,
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
104
132
|
it('walks up nested directories to find the nearest compiler', () => {
|
|
105
133
|
const workspace = create_fixture_workspace('ripple-only');
|
|
106
134
|
const file_name = path.join(workspace, 'src', 'nested', 'components', 'App.tsrx');
|
|
@@ -154,8 +182,11 @@ describe('typescript-plugin compiler resolution', () => {
|
|
|
154
182
|
const cases = [
|
|
155
183
|
{ name: 'ripple-only', expected: ['@tsrx', 'ripple'] },
|
|
156
184
|
{ name: 'react-only', expected: ['@tsrx', 'react'] },
|
|
185
|
+
{ name: 'solid-only', expected: ['@tsrx', 'solid'] },
|
|
186
|
+
{ name: 'preact-only', expected: ['@tsrx', 'preact'] },
|
|
157
187
|
{ name: 'both', expected: ['@tsrx', 'ripple'] },
|
|
158
188
|
{ name: 'both-react', expected: ['@tsrx', 'react'] },
|
|
189
|
+
{ name: 'both-preact', expected: ['@tsrx', 'preact'] },
|
|
159
190
|
];
|
|
160
191
|
|
|
161
192
|
for (const test_case of cases) {
|
|
@@ -58,6 +58,62 @@ const COMPILER_STUBS = {
|
|
|
58
58
|
};
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
|
+
`,
|
|
62
|
+
solid: `module.exports = {
|
|
63
|
+
compile_to_volar_mappings(source, filename) {
|
|
64
|
+
const code = \`/* compiler:solid */\\nexport const filename = \${JSON.stringify(filename)};\\nexport default \${JSON.stringify(source)};\`;
|
|
65
|
+
return {
|
|
66
|
+
code,
|
|
67
|
+
mappings: [
|
|
68
|
+
{
|
|
69
|
+
sourceOffsets: [0],
|
|
70
|
+
generatedOffsets: [0],
|
|
71
|
+
lengths: [source.length],
|
|
72
|
+
generatedLengths: [source.length],
|
|
73
|
+
data: {
|
|
74
|
+
verification: false,
|
|
75
|
+
completion: true,
|
|
76
|
+
semantic: true,
|
|
77
|
+
navigation: true,
|
|
78
|
+
structure: true,
|
|
79
|
+
format: true,
|
|
80
|
+
customData: {},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
cssMappings: [],
|
|
85
|
+
errors: [],
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
`,
|
|
90
|
+
preact: `module.exports = {
|
|
91
|
+
compile_to_volar_mappings(source, filename) {
|
|
92
|
+
const code = \`/* compiler:preact */\\nexport const filename = \${JSON.stringify(filename)};\\nexport default \${JSON.stringify(source)};\`;
|
|
93
|
+
return {
|
|
94
|
+
code,
|
|
95
|
+
mappings: [
|
|
96
|
+
{
|
|
97
|
+
sourceOffsets: [0],
|
|
98
|
+
generatedOffsets: [0],
|
|
99
|
+
lengths: [source.length],
|
|
100
|
+
generatedLengths: [source.length],
|
|
101
|
+
data: {
|
|
102
|
+
verification: false,
|
|
103
|
+
completion: true,
|
|
104
|
+
semantic: true,
|
|
105
|
+
navigation: true,
|
|
106
|
+
structure: true,
|
|
107
|
+
format: true,
|
|
108
|
+
customData: {},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
cssMappings: [],
|
|
113
|
+
errors: [],
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
};
|
|
61
117
|
`,
|
|
62
118
|
};
|
|
63
119
|
|
|
@@ -85,6 +141,28 @@ export const WORKSPACE_CONFIGS = {
|
|
|
85
141
|
},
|
|
86
142
|
compilers: ['react'],
|
|
87
143
|
},
|
|
144
|
+
'solid-only': {
|
|
145
|
+
package_json: {
|
|
146
|
+
name: '@tsrx/fixture-solid-only-project',
|
|
147
|
+
private: true,
|
|
148
|
+
devDependencies: {
|
|
149
|
+
'@tsrx/solid': 'workspace:*',
|
|
150
|
+
'@tsrx/vite-plugin-solid': 'workspace:*',
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
compilers: ['solid'],
|
|
154
|
+
},
|
|
155
|
+
'preact-only': {
|
|
156
|
+
package_json: {
|
|
157
|
+
name: '@tsrx/fixture-preact-only-project',
|
|
158
|
+
private: true,
|
|
159
|
+
devDependencies: {
|
|
160
|
+
'@tsrx/preact': 'workspace:*',
|
|
161
|
+
'@tsrx/vite-plugin-preact': 'workspace:*',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
compilers: ['preact'],
|
|
165
|
+
},
|
|
88
166
|
both: {
|
|
89
167
|
package_json: {
|
|
90
168
|
name: '@ripple-ts/fixture-ripple-project',
|
|
@@ -108,6 +186,17 @@ export const WORKSPACE_CONFIGS = {
|
|
|
108
186
|
},
|
|
109
187
|
compilers: ['ripple', 'react'],
|
|
110
188
|
},
|
|
189
|
+
'both-preact': {
|
|
190
|
+
package_json: {
|
|
191
|
+
name: '@tsrx/fixture-preact-project',
|
|
192
|
+
private: true,
|
|
193
|
+
devDependencies: {
|
|
194
|
+
'@tsrx/preact': 'workspace:*',
|
|
195
|
+
'@tsrx/vite-plugin-preact': 'workspace:*',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
compilers: ['ripple', 'react', 'solid', 'preact'],
|
|
199
|
+
},
|
|
111
200
|
};
|
|
112
201
|
|
|
113
202
|
/** @type {string[]} */
|