Skip to content

Commit

Permalink
Merge pull request #19405 from joshwooding/fix-bail-being-undefined-f…
Browse files Browse the repository at this point in the history
…or-vite-builder

Fix bail not being defined for the vite builder
  • Loading branch information
IanVS authored Oct 13, 2022
2 parents 9d9f9f0 + 4ab7f63 commit 6c907eb
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions code/lib/builder-vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,25 @@ function iframeMiddleware(options: ExtendedOptions, server: ViteDevServer): Requ
};
}

let server: ViteDevServer;

export async function bail(e?: Error): Promise<void> {
try {
return await server.close();
} catch (err) {
console.warn('unable to close vite server');
}

throw e;
}

export const start: ViteBuilder['start'] = async ({
startTime,
options,
router,
server: devServer,
}) => {
const server = await createViteServer(options as ExtendedOptions, devServer);
server = await createViteServer(options as ExtendedOptions, devServer);

// Just mock this endpoint (which is really Webpack-specific) so we don't get spammed with 404 in browser devtools
// TODO: we should either show some sort of progress from Vite, or just try to disable the whole Loader in the Manager UI.
Expand All @@ -75,16 +87,6 @@ export const start: ViteBuilder['start'] = async ({
router.use(iframeMiddleware(options as ExtendedOptions, server));
router.use(server.middlewares);

async function bail(e?: Error): Promise<void> {
try {
return await server.close();
} catch (err) {
console.warn('unable to close vite server');
}

throw e;
}

return {
bail,
stats: { toJson: () => null },
Expand Down

0 comments on commit 6c907eb

Please sign in to comment.