Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(remix-dev/vite): preload Vite ESM build in CLI #8339

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
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
fix(remix-dev/vite): preload Vite ESM build in CLI
  • Loading branch information
markdalgleish committed Dec 21, 2023
commit 57ba606e7e216d6b5f175bebd183982d539408ba
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