From 72e1e54bd7207b8d6702cf1f8663152df05ce470 Mon Sep 17 00:00:00 2001 From: Alexandre BODIN Date: Thu, 12 Sep 2024 18:00:33 +0200 Subject: [PATCH] fix: use dynamic import to avoid vite warning (#16) * fix: use dynamic import to avoid vite warning * chore: use dynamic import to avoid vite warning --- .changeset/green-bottles-sparkle.md | 5 +++++ src/node/tasks/vite/config.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/green-bottles-sparkle.md diff --git a/.changeset/green-bottles-sparkle.md b/.changeset/green-bottles-sparkle.md new file mode 100644 index 0000000..f9e19ae --- /dev/null +++ b/.changeset/green-bottles-sparkle.md @@ -0,0 +1,5 @@ +--- + +--- + +fix: use dynamic import to avoid vite warning diff --git a/src/node/tasks/vite/config.ts b/src/node/tasks/vite/config.ts index 5e737ff..15c3fa4 100644 --- a/src/node/tasks/vite/config.ts +++ b/src/node/tasks/vite/config.ts @@ -2,7 +2,6 @@ import react from '@vitejs/plugin-react-swc'; import { builtinModules } from 'node:module'; import path from 'path'; -import { mergeConfig } from 'vite'; import { resolveConfigProperty } from '../../core/config'; @@ -134,7 +133,9 @@ const resolveViteConfig = async (ctx: BuildContext, task: ViteBaseTask) => { plugins: [...basePlugins, ...plugins], } satisfies InlineConfig; - return mergeConfig(config, ctx.config.unstable_viteConfig ?? {}); + return import('vite').then(({ mergeConfig }) => + mergeConfig(config, ctx.config.unstable_viteConfig ?? {}) + ); }; export { resolveViteConfig };