File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
packages/plugin-react/src Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -306,8 +306,18 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
306306
307307viteReact . preambleCode = preambleCode
308308
309- function loadPlugin ( path : string ) : Promise < any > {
310- return import ( path ) . then ( ( module ) => module . default || module )
309+ const loadedPlugin = new Map < string , any > ( )
310+ function loadPlugin ( path : string ) : any {
311+ const cached = loadedPlugin . get ( path )
312+ if ( cached ) return cached
313+
314+ const promise = import ( path ) . then ( ( module ) => {
315+ const value = module . default || module
316+ loadedPlugin . set ( path , value )
317+ return value
318+ } )
319+ loadedPlugin . set ( path , promise )
320+ return promise
311321}
312322
313323function createBabelOptions ( rawOptions ?: BabelOptions ) {
You can’t perform that action at this time.
0 commit comments