@hyperspan/plugin-preact 2.0.0-alpha.3 → 2.0.0-alpha.5
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 +5 -5
- package/src/index.ts +23 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperspan/plugin-preact",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.5",
|
|
4
4
|
"description": "Hyperspan Plugin for Preact",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
"url": "git+https://github.com/vlucas/hyperspan.git"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@hyperspan/vite-plugin": "^2.0.0-alpha.
|
|
33
|
+
"@hyperspan/vite-plugin": "^2.0.0-alpha.5",
|
|
34
34
|
"prettier": "^3.8.1",
|
|
35
35
|
"typescript": "^5.9.3",
|
|
36
36
|
"vite": "^6.3.5",
|
|
37
37
|
"vitest": "^3.2.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@hyperspan/html": "^2.0.0-alpha.
|
|
41
|
-
"@hyperspan/framework": "^2.0.0-alpha.
|
|
42
|
-
"@hyperspan/vite-plugin": "^2.0.0-alpha.
|
|
40
|
+
"@hyperspan/html": "^2.0.0-alpha.4",
|
|
41
|
+
"@hyperspan/framework": "^2.0.0-alpha.5",
|
|
42
|
+
"@hyperspan/vite-plugin": "^2.0.0-alpha.5",
|
|
43
43
|
"vite": "^6.0.0 || ^7.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isIslandModule,
|
|
14
14
|
islandPluginResolveId,
|
|
15
15
|
splitIslandId,
|
|
16
|
+
registerClientChunkAliases,
|
|
16
17
|
} from '@hyperspan/vite-plugin/islands';
|
|
17
18
|
import debug from 'debug';
|
|
18
19
|
|
|
@@ -134,6 +135,16 @@ function __hs_renderIsland_${componentName}(jsContent = '', ssrContent = '', opt
|
|
|
134
135
|
`;
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
const PREACT_CLIENT_SPECIFIERS = [
|
|
139
|
+
'preact',
|
|
140
|
+
'preact/hooks',
|
|
141
|
+
'preact/jsx-runtime',
|
|
142
|
+
'preact/jsx-dev-runtime',
|
|
143
|
+
'preact/compat',
|
|
144
|
+
'react',
|
|
145
|
+
'react-dom',
|
|
146
|
+
] as const;
|
|
147
|
+
|
|
137
148
|
/**
|
|
138
149
|
* Vite plugin for Preact islands.
|
|
139
150
|
*/
|
|
@@ -156,13 +167,18 @@ export function preactIslandPlugin(): Plugin {
|
|
|
156
167
|
|
|
157
168
|
configureServer() {
|
|
158
169
|
const clientUrl = '/islands/preact-client.js';
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
170
|
+
for (const spec of PREACT_CLIENT_SPECIFIERS) {
|
|
171
|
+
registerImport(spec, clientUrl);
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
generateBundle(_options, bundle) {
|
|
176
|
+
registerClientChunkAliases(
|
|
177
|
+
bundle,
|
|
178
|
+
(fileName) =>
|
|
179
|
+
fileName.includes('islands/preact-client') || fileName.endsWith('preact-client.js'),
|
|
180
|
+
PREACT_CLIENT_SPECIFIERS
|
|
181
|
+
);
|
|
166
182
|
},
|
|
167
183
|
|
|
168
184
|
async transform(code, id) {
|