From 4e671b72894f8467c30777c5675c327b04bedffa Mon Sep 17 00:00:00 2001 From: Alvis HT Tang Date: Tue, 13 Jun 2023 10:50:26 +0100 Subject: [PATCH] refactor(preset-rollup): normalize config in functional way --- source/rollup.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/source/rollup.ts b/source/rollup.ts index 03dad14..403f683 100644 --- a/source/rollup.ts +++ b/source/rollup.ts @@ -180,20 +180,15 @@ function transformConfigValue(key: string, value: unknown): unknown { function objectifyPlugins( plugins: PluginManifest, ): IntermediateRollupConfig['plugins'] { - const normalizedPlugin: PluginObject = {}; - const pluginList: PluginConfiguration[] = Array.isArray(plugins) ? arrayToPluginConfiguration(plugins) : objectToPluginConfiguration(plugins); - for (const [name, options] of pluginList) { - Object.assign( - normalizedPlugin, + return pluginList.reduce( + (normalizedPlugin, [name, options]) => merge(normalizedPlugin, { [name]: options }), - ); - } - - return normalizedPlugin; + {}, + ); } /**