Skip to content

Commit 919c468

Browse files
committed
Only re-use injected build manifest
1 parent 5be35b5 commit 919c468

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/react-router-dev/vite/plugin.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,21 +615,15 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
615615
}
616616

617617
// This `injectedPluginContext` logic is so we can support injecting an
618-
// already-resolved plugin context into the build. This is so we can resolve
619-
// the plugin context once for the entire build process and avoid resolving
620-
// it every time the Vite config is resolved. This is most important for
621-
// resolving the `buildManifest` object since it involves executing the
622-
// `serverBundles` function, which we want to avoid doing multiple times.
623-
// Note that this logic is redundant when using the Vite Environment API
624-
// since our plugin is instantiated once and shared across all builds.
618+
// already-resolved plugin context into the build in case we want to re-use
619+
// any resolved values. Currently this is used so that we can re-use the
620+
// `buildManifest` object across multiple builds without having to
621+
// re-execute the `serverBundles` function.
625622
let injectedPluginContext =
626623
!reactRouterConfig.future.unstable_viteEnvironmentApi &&
627624
viteCommand === "build"
628625
? extractPluginContext(viteUserConfig)
629626
: undefined;
630-
if (injectedPluginContext) {
631-
ctx = injectedPluginContext;
632-
}
633627

634628
let { entryClientFilePath, entryServerFilePath } = await resolveEntryFiles({
635629
rootDirectory,
@@ -658,7 +652,8 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
658652

659653
let buildManifest =
660654
viteCommand === "build"
661-
? await getBuildManifest({ reactRouterConfig, rootDirectory })
655+
? injectedPluginContext?.buildManifest ??
656+
(await getBuildManifest({ reactRouterConfig, rootDirectory }))
662657
: null;
663658

664659
let environmentBuildContext: ResolvedEnvironmentBuildContext | null =

0 commit comments

Comments
 (0)