+4
-4
src/client/workspace-session.ts
+4
-4
src/client/workspace-session.ts
···
49
49
const worker = new WorkerClient(signal);
50
50
51
51
try {
52
-
const clientExports = parseClientModule(clientCode);
52
+
const clientExports = await parseClientModule(clientCode);
53
53
const manifest = buildManifest("client", clientExports);
54
-
const compiledClient = compileToCommonJS(clientCode);
54
+
const compiledClient = await compileToCommonJS(clientCode);
55
55
const clientModule = evaluateClientModule(compiledClient);
56
56
registerClientModule("client", clientModule);
57
57
58
-
const actionNames = parseServerActions(serverCode);
59
-
const compiledServer = compileToCommonJS(serverCode);
58
+
const actionNames = await parseServerActions(serverCode);
59
+
const compiledServer = await compileToCommonJS(serverCode);
60
60
61
61
await worker.deploy(compiledServer, manifest, actionNames);
62
62
const renderRaw = await worker.render();
+13
-10
vite.config.js
+13
-10
vite.config.js
···
68
68
};
69
69
}
70
70
71
-
function preloadCodemirrorPlugin() {
71
+
function preloadChunksPlugin() {
72
72
return {
73
-
name: "preload-codemirror",
73
+
name: "preload-chunks",
74
74
transformIndexHtml(html, { bundle, filename }) {
75
75
if (!bundle) return; // dev mode
76
76
const tags = [];
77
77
78
-
const cmChunk = Object.keys(bundle).find((k) => k.includes("codemirror"));
79
-
if (cmChunk) {
80
-
tags.push({
81
-
tag: "link",
82
-
attrs: { rel: "modulepreload", href: "/" + cmChunk },
83
-
injectTo: "head",
84
-
});
78
+
// Preload codemirror and babel chunks
79
+
for (const name of ["codemirror", "babel"]) {
80
+
const chunk = Object.keys(bundle).find((k) => k.includes(name));
81
+
if (chunk) {
82
+
tags.push({
83
+
tag: "link",
84
+
attrs: { rel: "modulepreload", href: "/" + chunk },
85
+
injectTo: "head",
86
+
});
87
+
}
85
88
}
86
89
87
90
// From index.html, prefetch embed resources for the iframe
···
104
107
}
105
108
106
109
export default defineConfig(({ mode }) => ({
107
-
plugins: [react(), rolldownWorkerPlugin(), serveEmbedPlugin(), preloadCodemirrorPlugin()],
110
+
plugins: [react(), rolldownWorkerPlugin(), serveEmbedPlugin(), preloadChunksPlugin()],
108
111
server: { port: 3333 },
109
112
define: {
110
113
"process.env.NODE_ENV": JSON.stringify(mode === "development" ? "development" : "production"),