diff --git a/packages/core/src/config.ts b/packages/core/src/config.ts index bda53e190..b99b640dd 100644 --- a/packages/core/src/config.ts +++ b/packages/core/src/config.ts @@ -7,7 +7,6 @@ import { mergeRsbuildConfig, } from '@rsbuild/core'; import glob from 'fast-glob'; -import { pluginDts } from 'rsbuild-plugin-dts'; import { DEFAULT_CONFIG_NAME, DEFAULT_EXTENSIONS } from './constant'; import type { Format, @@ -294,14 +293,15 @@ const getBundleConfig = (bundle = true): RsbuildConfig => { }; }; -const getDefaultDtsConfig = ( +const getDefaultDtsConfig = async ( libConfig: LibConfig, entryConfig: RsbuildConfig, -): RsbuildConfig => { +): Promise => { const { dts, bundle, output } = libConfig; if (dts === false || dts === undefined) return {}; + const { pluginDts } = await import('rsbuild-plugin-dts'); return { plugins: [ pluginDts({ @@ -353,7 +353,10 @@ async function postUpdateRsbuildConfig( dirname(configPath), ); - const defaultDtsConfig = getDefaultDtsConfig(libConfig, defaultEntryConfig); + const defaultDtsConfig = await getDefaultDtsConfig( + libConfig, + defaultEntryConfig, + ); return mergeRsbuildConfig( defaultTargetConfig,