refactor(preset-rollup): normalize config in functional way
This commit is contained in:
parent
2a87e456b0
commit
4e671b7289
|
@ -180,20 +180,15 @@ function transformConfigValue(key: string, value: unknown): unknown {
|
||||||
function objectifyPlugins(
|
function objectifyPlugins(
|
||||||
plugins: PluginManifest,
|
plugins: PluginManifest,
|
||||||
): IntermediateRollupConfig['plugins'] {
|
): IntermediateRollupConfig['plugins'] {
|
||||||
const normalizedPlugin: PluginObject = {};
|
|
||||||
|
|
||||||
const pluginList: PluginConfiguration[] = Array.isArray(plugins)
|
const pluginList: PluginConfiguration[] = Array.isArray(plugins)
|
||||||
? arrayToPluginConfiguration(plugins)
|
? arrayToPluginConfiguration(plugins)
|
||||||
: objectToPluginConfiguration(plugins);
|
: objectToPluginConfiguration(plugins);
|
||||||
|
|
||||||
for (const [name, options] of pluginList) {
|
return pluginList.reduce(
|
||||||
Object.assign(
|
(normalizedPlugin, [name, options]) =>
|
||||||
normalizedPlugin,
|
|
||||||
merge(normalizedPlugin, { [name]: options }),
|
merge(normalizedPlugin, { [name]: options }),
|
||||||
);
|
{},
|
||||||
}
|
);
|
||||||
|
|
||||||
return normalizedPlugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue