rwsdk 0.1.12 → 0.1.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.
|
@@ -47,7 +47,6 @@ export const directivesPlugin = ({ projectRootDir, clientFiles, serverFiles, })
|
|
|
47
47
|
devServer.environments[environment].depsOptimizer?.registerMissingImport(resolvedId, fullPath);
|
|
48
48
|
if (isAfterFirstResponse && !hadFile) {
|
|
49
49
|
log("Invalidating cache for lookup module %s after adding module id=%s", lookupModule, id);
|
|
50
|
-
//invalidateModule(devServer, environment, `virtual:use-${kind}-lookup`);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
};
|
|
@@ -127,7 +127,7 @@ export const miniflareHMRPlugin = (givenOptions) => [
|
|
|
127
127
|
const virtualSSRModule = ctx.server.environments[environment].moduleGraph.idToModuleMap.get(VIRTUAL_SSR_PREFIX +
|
|
128
128
|
normalizeModulePath(givenOptions.rootDir, ctx.file));
|
|
129
129
|
if (virtualSSRModule) {
|
|
130
|
-
ctx.server.environments.
|
|
130
|
+
ctx.server.environments.worker.moduleGraph.invalidateModule(virtualSSRModule, new Set(), ctx.timestamp, true);
|
|
131
131
|
}
|
|
132
132
|
ctx.server.environments.client.hot.send({
|
|
133
133
|
type: "custom",
|
|
@@ -89,32 +89,23 @@ export const ssrBridgePlugin = ({ clientFiles, serverFiles, }) => {
|
|
|
89
89
|
log("Dev mode: fetching SSR module for realPath=%s", realId);
|
|
90
90
|
const result = await devServer?.environments.ssr.fetchModule(realId);
|
|
91
91
|
verboseLog("Fetch module result: id=%s, result=%O", realId, result);
|
|
92
|
-
if (!result) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
92
|
const code = "code" in result ? result.code : undefined;
|
|
96
93
|
log("Fetched SSR module code length: %d", code?.length || 0);
|
|
97
|
-
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const { imports, dynamicImports } = findSsrImportSpecifiers(realId, code, verboseLog);
|
|
94
|
+
const { imports, dynamicImports } = findSsrImportSpecifiers(realId, code || "", verboseLog);
|
|
101
95
|
const allSpecifiers = [...new Set([...imports, ...dynamicImports])];
|
|
102
96
|
const switchCases = allSpecifiers
|
|
103
97
|
.map((specifier) => ` case "${specifier}": return import("${VIRTUAL_SSR_PREFIX}${specifier}");`)
|
|
104
98
|
.join("\n");
|
|
105
99
|
const transformedCode = `
|
|
106
100
|
await (async function(__vite_ssr_import__, __vite_ssr_dynamic_import__) {${code}})(
|
|
107
|
-
(id, ...args) => ssrImport(id
|
|
108
|
-
(id, ...args) => ssrImport(id
|
|
101
|
+
(id, ...args) => {ssrImport(id); return __vite_ssr_import__('/@id/${VIRTUAL_SSR_PREFIX}' + id, ...args);},
|
|
102
|
+
(id, ...args) => {ssrImport(id); return __vite_ssr_dynamic_import__('/@id/${VIRTUAL_SSR_PREFIX}' + id, ...args);}
|
|
109
103
|
);
|
|
110
104
|
|
|
111
|
-
function ssrImport(id
|
|
105
|
+
function ssrImport(id) {
|
|
112
106
|
switch (id) {
|
|
113
107
|
${switchCases}
|
|
114
108
|
}
|
|
115
|
-
|
|
116
|
-
const virtualId = '/@id/${VIRTUAL_SSR_PREFIX}' + id;
|
|
117
|
-
return isDynamic ? __vite_ssr_dynamic_import__(virtualId, ...args) : __vite_ssr_import__(virtualId, ...args);
|
|
118
109
|
}
|
|
119
110
|
`;
|
|
120
111
|
log("Transformed SSR module code length: %d", transformedCode.length);
|