rwsdk 0.2.0-alpha.0 → 0.2.0-alpha.10
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/lib/smokeTests/browser.mjs +13 -6
- package/dist/lib/smokeTests/utils.d.mts +9 -0
- package/dist/lib/smokeTests/utils.mjs +29 -0
- package/dist/runtime/client.js +3 -1
- package/dist/runtime/clientNavigation.js +23 -63
- package/dist/runtime/clientNavigation.test.js +2 -3
- package/dist/runtime/lib/db/DOWorkerDialect.d.ts +11 -13
- package/dist/runtime/lib/db/DOWorkerDialect.js +1 -1
- package/dist/runtime/lib/db/createDb.d.ts +2 -1
- package/dist/runtime/lib/db/createDb.js +9 -35
- package/dist/runtime/lib/db/index.d.ts +1 -0
- package/dist/runtime/lib/db/index.js +1 -0
- package/dist/runtime/lib/manifest.js +1 -4
- package/dist/runtime/lib/router.d.ts +6 -4
- package/dist/runtime/lib/router.js +117 -32
- package/dist/runtime/render/stylesheets.d.ts +0 -5
- package/dist/runtime/render/stylesheets.js +1 -11
- package/dist/runtime/requestInfo/types.d.ts +2 -0
- package/dist/runtime/requestInfo/worker.js +1 -1
- package/dist/runtime/script.d.ts +1 -1
- package/dist/runtime/script.js +1 -1
- package/dist/runtime/worker.js +28 -16
- package/dist/scripts/debug-sync.mjs +24 -137
- package/dist/scripts/smoke-test.mjs +4 -5
- package/dist/vite/findSsrSpecifiers.d.mts +8 -9
- package/dist/vite/findSsrSpecifiers.mjs +23 -21
- package/dist/vite/manifestPlugin.mjs +0 -71
- package/dist/vite/miniflareHMRPlugin.mjs +6 -4
- package/dist/vite/ssrBridgePlugin.mjs +22 -29
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import debug from "debug";
|
|
2
2
|
import { SSR_BRIDGE_PATH } from "../lib/constants.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { findSsrImportCallSites } from "./findSsrSpecifiers.mjs";
|
|
4
|
+
import MagicString from "magic-string";
|
|
4
5
|
const log = debug("rwsdk:vite:ssr-bridge-plugin");
|
|
5
6
|
export const VIRTUAL_SSR_PREFIX = "virtual:rwsdk:ssr:";
|
|
6
7
|
export const ssrBridgePlugin = ({ clientFiles, serverFiles, }) => {
|
|
@@ -108,35 +109,27 @@ export const ssrBridgePlugin = ({ clientFiles, serverFiles, }) => {
|
|
|
108
109
|
return "export default {};";
|
|
109
110
|
}
|
|
110
111
|
log("Fetched SSR module code length: %d", code?.length || 0);
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return isDynamic
|
|
132
|
-
? __vite_ssr_dynamic_import__("/@id/${VIRTUAL_SSR_PREFIX}" + id, ...args)
|
|
133
|
-
: __vite_ssr_import__("/@id/${VIRTUAL_SSR_PREFIX}" + id, ...args);
|
|
134
|
-
}
|
|
135
|
-
`;
|
|
136
|
-
log("Transformed SSR module code length: %d", transformedCode.length);
|
|
112
|
+
const s = new MagicString(code || "");
|
|
113
|
+
const callsites = findSsrImportCallSites(idForFetch, code || "", log);
|
|
114
|
+
for (const site of callsites) {
|
|
115
|
+
const normalized = site.specifier.startsWith("/@id/")
|
|
116
|
+
? site.specifier.slice("/@id/".length)
|
|
117
|
+
: site.specifier;
|
|
118
|
+
// context(justinvdm, 11 Aug 2025):
|
|
119
|
+
// - We replace __vite_ssr_import__ and __vite_ssr_dynamic_import__
|
|
120
|
+
// with import() calls so that the module graph can be built
|
|
121
|
+
// correctly (vite looks for imports and import()s to build module
|
|
122
|
+
// graph)
|
|
123
|
+
// - We prepend /@id/$VIRTUAL_SSR_PREFIX to the specifier so that we
|
|
124
|
+
// can stay within the SSR subgraph of the worker module graph
|
|
125
|
+
const replacement = `import("/@id/${VIRTUAL_SSR_PREFIX}${normalized}")`;
|
|
126
|
+
s.overwrite(site.start, site.end, replacement);
|
|
127
|
+
}
|
|
128
|
+
const out = s.toString();
|
|
129
|
+
log("Transformed SSR module code length: %d", out.length);
|
|
137
130
|
process.env.VERBOSE &&
|
|
138
|
-
log("Transformed SSR module code for realId=%s: %s", realId,
|
|
139
|
-
return
|
|
131
|
+
log("Transformed SSR module code for realId=%s: %s", realId, out);
|
|
132
|
+
return out;
|
|
140
133
|
}
|
|
141
134
|
}
|
|
142
135
|
process.env.VERBOSE && log("No load handling for id=%s", id);
|