Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions packages/vite-plugin-node/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,25 @@ export const createMiddleware = async (
const requestHandler = getRequestHandler(config.adapter);

async function _loadApp(config: VitePluginNodeConfig) {
const appModule = await server.ssrLoadModule(config.appPath);
let app = appModule[config.exportName!];
if (!app) {
logger.error(
`Failed to find a named export ${config.exportName} from ${config.appPath}`,
);
process.exit(1);
} else {
// some app may be created with a function returning a promise
app = await app;
return app;
try {
const appModule = await server.ssrLoadModule(config.appPath);
let app = appModule[config.exportName!];
if (!app) {
logger.error(
`Failed to find a named export ${config.exportName} from ${config.appPath}`,
);
process.exit(1);
} else {
// some app may be created with a function returning a promise
app = await app;
return app;
}
} catch(e) {
if (config.reloadAppOnFileChange) {
logger.error("Loading app has failed. Waiting for an update.")
} else {
throw e
}
}
}

Expand Down