File tree Expand file tree Collapse file tree 2 files changed +15
-23
lines changed
packages/react-router-dev Expand file tree Collapse file tree 2 files changed +15
-23
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,9 @@ export type ServerBundlesBuildManifest = BaseBuildManifest & {
8383
8484type ServerModuleFormat = "esm" | "cjs" ;
8585
86- interface FutureConfig { }
86+ interface FutureConfig {
87+ unstable_optimizeDeps : boolean ;
88+ }
8789
8890export type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest ;
8991
@@ -475,7 +477,10 @@ async function resolveConfig({
475477 ) ;
476478 }
477479
478- let future : FutureConfig = { } ;
480+ let future : FutureConfig = {
481+ unstable_optimizeDeps :
482+ reactRouterUserConfig . future ?. unstable_optimizeDeps ?? false ,
483+ } ;
479484
480485 let reactRouterConfig : ResolvedReactRouterConfig = deepFreeze ( {
481486 appDirectory,
Original file line number Diff line number Diff line change @@ -395,27 +395,6 @@ export let setReactRouterDevLoadContext = (
395395 reactRouterDevLoadContext = loadContext ;
396396} ;
397397
398- // Inlined from https://github.com/jsdf/deep-freeze
399- let deepFreeze = ( o : any ) => {
400- Object . freeze ( o ) ;
401- let oIsFunction = typeof o === "function" ;
402- let hasOwnProp = Object . prototype . hasOwnProperty ;
403- Object . getOwnPropertyNames ( o ) . forEach ( function ( prop ) {
404- if (
405- hasOwnProp . call ( o , prop ) &&
406- ( oIsFunction
407- ? prop !== "caller" && prop !== "callee" && prop !== "arguments"
408- : true ) &&
409- o [ prop ] !== null &&
410- ( typeof o [ prop ] === "object" || typeof o [ prop ] === "function" ) &&
411- ! Object . isFrozen ( o [ prop ] )
412- ) {
413- deepFreeze ( o [ prop ] ) ;
414- }
415- } ) ;
416- return o ;
417- } ;
418-
419398type ReactRouterVitePlugin = ( ) => Vite . Plugin [ ] ;
420399/**
421400 * React Router [Vite plugin.](https://vitejs.dev/guide/using-plugins.html)
@@ -825,6 +804,14 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => {
825804 } ,
826805 } ,
827806 optimizeDeps : {
807+ entries : ctx . reactRouterConfig . future . unstable_optimizeDeps
808+ ? [
809+ ctx . entryClientFilePath ,
810+ ...Object . values ( ctx . reactRouterConfig . routes ) . map ( ( route ) =>
811+ path . join ( ctx . reactRouterConfig . appDirectory , route . file )
812+ ) ,
813+ ]
814+ : [ ] ,
828815 include : [
829816 // Pre-bundle React dependencies to avoid React duplicates,
830817 // even if React dependencies are not direct dependencies.
You can’t perform that action at this time.
0 commit comments