Skip to content

Commit

Permalink
Add IPC definition for ssr watch method
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgenVatle committed Oct 24, 2024
1 parent cf2453b commit ad51c8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions npm-packages/meteor-vite/src/meteor/IPC/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface WorkerReplies {
viteConfig: ViteRuntimeConfig
refreshNeeded: void,
workerConfig: WorkerRuntimeConfig & { listening: boolean }
startSSRWatcher: { serverEntry: string }
}

export type WorkerResponse<TName extends WorkerReplyKind = WorkerReplyKind> = {
Expand Down
16 changes: 12 additions & 4 deletions npm-packages/meteor-vite/src/meteor/IPC/methods/vite-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export default defineIpcMethods({
await sendViteConfig();
},

async 'vite.watch.ssr'({ packageJson }: DevServerOptions) {
await MeteorServerBuilder({ packageJson });
},

async 'vite.server.start'({ packageJson, meteorParentPid, meteorConfig }: DevServerOptions) {
const ddpClient = DDPConnection.init(meteorConfig);
const backgroundWorker = await BackgroundWorker.init(meteorParentPid, ddpClient);
Expand Down Expand Up @@ -94,7 +98,15 @@ async function createViteServer({
?? packageJson?.meteor?.viteConfig,
}, 'serve');

if (viteConfig.meteor?.serverEntry) {
await IPC.reply({
kind: 'startSSRWatcher',
data: { serverEntry: viteConfig.meteor.serverEntry }
})
}

viteDevServer = await createServer({
mode: 'development',
configFile: viteConfig.configFile,
plugins: [
meteorWorker({
Expand Down Expand Up @@ -126,10 +138,6 @@ async function createViteServer({
],
});

if (viteConfig.meteor?.serverEntry) {
await MeteorServerBuilder({ packageJson });
}

process.on('warning', (warning) => {
if (warning.name !== RefreshNeeded.name) {
return;
Expand Down

0 comments on commit ad51c8b

Please sign in to comment.