Skip to content

Commit

Permalink
Fix bail not being defined (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored Oct 8, 2022
1 parent 70fdb7e commit 2c929ac
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/builder-vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ 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 @@ -57,16 +69,6 @@ export const start: ViteBuilder['start'] = async ({ startTime, options, router,
router.use(await 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: null,
Expand Down

0 comments on commit 2c929ac

Please sign in to comment.