Skip to content

Commit

Permalink
fix(remix-dev/vite): preload Vite ESM build in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish committed Dec 21, 2023
1 parent 6a1c4ff commit 57ba606
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/remix-dev/vite/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type * as Vite from "vite";
import colors from "picocolors";

import { preloadViteEsm } from "./import-vite-esm-sync";
import type { ResolvedRemixVitePluginConfig } from "./plugin";

async function extractRemixPluginConfig({
Expand Down Expand Up @@ -56,6 +57,10 @@ export async function build(
mode,
}: ViteBuildOptions
) {
// Ensure Vite's ESM build is preloaded at the start of the process
// so it can be accessed synchronously via `importViteEsmSync`
await preloadViteEsm();

// For now we just use this function to validate that the Vite config is
// targeting Remix, but in the future the return value can be used to
// configure the entire multi-step build process.
Expand Down
6 changes: 6 additions & 0 deletions packages/remix-dev/vite/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type * as Vite from "vite";
import colors from "picocolors";

import { preloadViteEsm } from "./import-vite-esm-sync";

export interface ViteDevOptions {
clearScreen?: boolean;
config?: string;
Expand Down Expand Up @@ -29,6 +31,10 @@ export async function dev(
strictPort,
}: ViteDevOptions
) {
// Ensure Vite's ESM build is preloaded at the start of the process
// so it can be accessed synchronously via `importViteEsmSync`
await preloadViteEsm();

let vite = await import("vite");
let server = await vite.createServer({
root,
Expand Down

0 comments on commit 57ba606

Please sign in to comment.