@void/solid 0.7.12 → 0.7.13
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/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +24 -15
- package/package.json +3 -3
package/dist/plugin.d.mts
CHANGED
|
@@ -11,6 +11,6 @@ type VoidSolidOptions = Readonly<{
|
|
|
11
11
|
viewTransitions?: boolean;
|
|
12
12
|
prefetch?: PrefetchConfig;
|
|
13
13
|
}>;
|
|
14
|
-
declare function voidSolid(options?: VoidSolidOptions):
|
|
14
|
+
declare function voidSolid(options?: VoidSolidOptions): Array<Plugin>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { VoidSolidOptions, voidSolid };
|
package/dist/plugin.mjs
CHANGED
|
@@ -141,6 +141,22 @@ const COMPONENT_EXTENSIONS = [
|
|
|
141
141
|
".ts",
|
|
142
142
|
".js"
|
|
143
143
|
];
|
|
144
|
+
const ISLAND_IMPORT_RE = /import\s+([$_A-Za-z][$_\w]*)\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*,?\s*\}/g;
|
|
145
|
+
function findIslandImports(code) {
|
|
146
|
+
const imports = [];
|
|
147
|
+
let match;
|
|
148
|
+
ISLAND_IMPORT_RE.lastIndex = 0;
|
|
149
|
+
while ((match = ISLAND_IMPORT_RE.exec(code)) !== null) {
|
|
150
|
+
const specifierRaw = match[2];
|
|
151
|
+
imports.push({
|
|
152
|
+
statement: match[0],
|
|
153
|
+
importName: match[1],
|
|
154
|
+
specifier: specifierRaw.slice(1, -1),
|
|
155
|
+
hydrate: match[3].slice(1, -1)
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return imports;
|
|
159
|
+
}
|
|
144
160
|
/**
|
|
145
161
|
* Prefix for virtual island wrapper modules. Must NOT use the `\0` prefix
|
|
146
162
|
* because `vite-plugin-solid` skips `\0`-prefixed modules in its transform
|
|
@@ -178,7 +194,6 @@ function islandsPlugin(pagesDir) {
|
|
|
178
194
|
async buildStart() {
|
|
179
195
|
if (existsSync(pagesDir)) {
|
|
180
196
|
pageScan = await scanPages(root);
|
|
181
|
-
const importAttrRe = /import\s+\w+\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
182
197
|
const filesToScan = [
|
|
183
198
|
...pageScan.pages.map((page) => ({
|
|
184
199
|
filePath: page.componentPath,
|
|
@@ -198,11 +213,9 @@ function islandsPlugin(pagesDir) {
|
|
|
198
213
|
const filePath = resolve(pagesDir, entry.filePath);
|
|
199
214
|
const code = readFileSync(filePath, "utf-8");
|
|
200
215
|
const importerDir = dirname(filePath);
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
const spec = importMatch[1].slice(1, -1);
|
|
205
|
-
const strategy = importMatch[2].slice(1, -1);
|
|
216
|
+
for (const islandImport of findIslandImports(code)) {
|
|
217
|
+
const spec = islandImport.specifier;
|
|
218
|
+
const strategy = islandImport.hydrate;
|
|
206
219
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
207
220
|
if (absPath) {
|
|
208
221
|
const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
|
|
@@ -265,16 +278,12 @@ function islandsPlugin(pagesDir) {
|
|
|
265
278
|
filter: { id: /\.island\.(tsx|jsx)$/ },
|
|
266
279
|
handler(code, id) {
|
|
267
280
|
if (/import\s+\{[^}]*\buseForm\b/.test(code)) this.warn(`islands: useForm cannot be imported in island page '${id}'. Use useIslandForm instead.`);
|
|
268
|
-
const importAttrRe = /import\s+(\w+)\s+from\s+("[^"]+"|'[^']+')\s+with\s*\{\s*island\s*:\s*("[^"]+"|'[^']+')\s*\}/g;
|
|
269
281
|
const importerDir = dirname(id);
|
|
270
282
|
let transformed = code;
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const strategyRaw = match[3];
|
|
276
|
-
const spec = specRaw.slice(1, -1);
|
|
277
|
-
const strategy = strategyRaw.slice(1, -1);
|
|
283
|
+
for (const islandImport of findIslandImports(code)) {
|
|
284
|
+
const name = islandImport.importName;
|
|
285
|
+
const spec = islandImport.specifier;
|
|
286
|
+
const strategy = islandImport.hydrate;
|
|
278
287
|
const absPath = resolveSpecifier(spec, importerDir, COMPONENT_EXTENSIONS);
|
|
279
288
|
if (absPath) {
|
|
280
289
|
const islandId = normalizePath(relative(root, absPath)).replace(/\.[^.]+$/, "");
|
|
@@ -292,7 +301,7 @@ function islandsPlugin(pagesDir) {
|
|
|
292
301
|
hydrate: strategy
|
|
293
302
|
});
|
|
294
303
|
const replacement = `import ${name} from ${JSON.stringify(wrapperUrl)}`;
|
|
295
|
-
transformed = transformed.replace(
|
|
304
|
+
transformed = transformed.replace(islandImport.statement, replacement);
|
|
296
305
|
}
|
|
297
306
|
if (transformed !== code) return {
|
|
298
307
|
code: transformed,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@void/solid",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/voidzero-dev/void.git",
|
|
@@ -43,12 +43,12 @@
|
|
|
43
43
|
"solid-js": "^1.9.12",
|
|
44
44
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.20",
|
|
45
45
|
"vite-plus": "^0.1.20",
|
|
46
|
-
"void": "0.7.
|
|
46
|
+
"void": "0.7.13"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"solid-js": "^1.9.0",
|
|
50
50
|
"vite": "^8.0.0",
|
|
51
|
-
"void": "0.7.
|
|
51
|
+
"void": "0.7.13"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "vp pack",
|