vitest-browser-qwik 0.3.2 → 0.3.4
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/ssr-plugin.js +10 -13
- package/package.json +2 -2
package/dist/ssr-plugin.js
CHANGED
|
@@ -214,11 +214,9 @@ function hasCommandsImport(node) {
|
|
|
214
214
|
const getClientModule = async (viteServer, moduleId) => {
|
|
215
215
|
const clientEnv = viteServer.environments.client;
|
|
216
216
|
await clientEnv.fetchModule(moduleId);
|
|
217
|
-
const
|
|
218
|
-
const resolvedId = resolved?.[1];
|
|
217
|
+
const resolvedId = (await clientEnv.moduleGraph.resolveUrl(moduleId))?.[1];
|
|
219
218
|
if (!resolvedId) throw new Error(`Could not resolve module "${moduleId}" in client environment`);
|
|
220
219
|
const module = clientEnv.moduleGraph.getModuleById(resolvedId);
|
|
221
|
-
console.log("Resolved client module", moduleId, resolved, module);
|
|
222
220
|
if (!module) throw new Error(`Module "${moduleId}" not found in client module graph.`);
|
|
223
221
|
return module;
|
|
224
222
|
};
|
|
@@ -226,7 +224,8 @@ async function renderComponentToSSR(ctx, Component, props = {}) {
|
|
|
226
224
|
const viteServer = ctx.project.vite;
|
|
227
225
|
const { jsx } = await viteServer.ssrLoadModule("@qwik.dev/core");
|
|
228
226
|
const jsxElement = jsx(Component, props);
|
|
229
|
-
const
|
|
227
|
+
const serverModule = await viteServer.ssrLoadModule("@qwik.dev/core/server");
|
|
228
|
+
const { renderToStream } = serverModule;
|
|
230
229
|
const mapping = {};
|
|
231
230
|
if (!ctx.testPath) throw new Error("ctx.testPath is required for SSR rendering");
|
|
232
231
|
const module = await getClientModule(viteServer, ctx.testPath);
|
|
@@ -234,28 +233,26 @@ async function renderComponentToSSR(ctx, Component, props = {}) {
|
|
|
234
233
|
const meta = importedModule.info?.meta;
|
|
235
234
|
if (meta?.segment) {
|
|
236
235
|
const symbol = meta.segment.hash;
|
|
237
|
-
if (symbol && importedModule.id) mapping[symbol] =
|
|
236
|
+
if (symbol && importedModule.id) mapping[symbol] = importedModule.url;
|
|
238
237
|
}
|
|
239
238
|
}
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
242
|
-
const
|
|
243
|
-
for (const key of
|
|
239
|
+
const handlersUrl = (await getClientModule(viteServer, "@qwik.dev/core/handlers.mjs")).url;
|
|
240
|
+
if (!handlersUrl) throw new Error("Handlers module URL could not be resolved");
|
|
241
|
+
const handlerNames = Object.keys(serverModule).filter((key) => /^_[a-z]+$/.test(key));
|
|
242
|
+
for (const key of handlerNames) mapping[key] = handlersUrl;
|
|
244
243
|
const qwikManifest = {
|
|
245
244
|
manifestHash: "dev",
|
|
246
245
|
mapping
|
|
247
246
|
};
|
|
248
|
-
|
|
249
|
-
let html = "<script>var _import=(s)=>{console.log('importing', s);return import(s)}<\/script>";
|
|
247
|
+
let html = "";
|
|
250
248
|
await renderToStream(jsxElement, {
|
|
251
249
|
manifest: qwikManifest,
|
|
252
250
|
containerTagName: "div",
|
|
253
251
|
base: "/",
|
|
254
252
|
stream: { write(chunk) {
|
|
255
|
-
html += chunk
|
|
253
|
+
html += chunk;
|
|
256
254
|
} }
|
|
257
255
|
});
|
|
258
|
-
console.log("FINAL HTML", html);
|
|
259
256
|
return { html };
|
|
260
257
|
}
|
|
261
258
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-browser-qwik",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Render Qwik components using Vitest Browser Mode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@qwik.dev/core": "*",
|
|
56
56
|
"@types/node": "^22.15.17",
|
|
57
57
|
"@vitest/browser-playwright": "^4.0.18",
|
|
58
|
-
"magic-regexp": "^0.10.0",
|
|
59
58
|
"bumpp": "^10.1.0",
|
|
60
59
|
"ignore": "^7.0.5",
|
|
60
|
+
"magic-regexp": "^0.10.0",
|
|
61
61
|
"tsdown": "^0.15.9",
|
|
62
62
|
"typescript": "^5.8.3",
|
|
63
63
|
"vitest": "^4.0.18"
|