Skip to content

Commit

Permalink
hoist, so returned function is sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 17, 2022
1 parent 8e65e86 commit af28ffc
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/kit/src/vite/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,28 +286,28 @@ export async function dev(vite, vite_config, svelte_config, illegal_imports) {
}
});

return async () => {
const runtime_base = runtime_directory.startsWith(process.cwd())
? `/${path.relative('.', runtime_directory)}`
: `/@fs${
// Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
runtime_directory.startsWith('/') ? '' : '/'
}${runtime_directory}`;

const { set_private_env } = await vite.ssrLoadModule(`${runtime_base}/env-private.js`);
const { set_public_env } = await vite.ssrLoadModule(`${runtime_base}/env-public.js`);

const env = get_env(vite_config.mode, svelte_config.kit.env.publicPrefix);
set_private_env(env.private);
set_public_env(env.public);

return () => {
const serve_static_middleware = vite.middlewares.stack.find(
(middleware) =>
/** @type {function} */ (middleware.handle).name === 'viteServeStaticMiddleware'
);

remove_static_middlewares(vite.middlewares);

const runtime_base = runtime_directory.startsWith(process.cwd())
? `/${path.relative('.', runtime_directory)}`
: `/@fs${
// Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
runtime_directory.startsWith('/') ? '' : '/'
}${runtime_directory}`;

const { set_private_env } = await vite.ssrLoadModule(`${runtime_base}/env-private.js`);
const { set_public_env } = await vite.ssrLoadModule(`${runtime_base}/env-public.js`);

const env = get_env(vite_config.mode, svelte_config.kit.env.publicPrefix);
set_private_env(env.private);
set_public_env(env.public);

vite.middlewares.use(async (req, res) => {
try {
const base = `${vite.config.server.https ? 'https' : 'http'}://${
Expand Down

0 comments on commit af28ffc

Please sign in to comment.