We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c4bf35 commit fbf722fCopy full SHA for fbf722f
1 file changed
packages/plugin-react/src/index.ts
@@ -306,8 +306,18 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
306
307
viteReact.preambleCode = preambleCode
308
309
-function loadPlugin(path: string): Promise<any> {
310
- return import(path).then((module) => module.default || module)
+const loadedPlugin = new Map<string, any>()
+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
321
}
322
323
function createBabelOptions(rawOptions?: BabelOptions) {
0 commit comments