diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 9fec100e5fc..189c49e8265 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -287,7 +287,16 @@ export interface InputOptions { watch?: WatcherOptions; } -export type ModuleFormat = 'amd' | 'cjs' | 'system' | 'es' | 'esm' | 'iife' | 'umd'; +export type ModuleFormat = + | 'amd' + | 'cjs' + | 'commonjs' + | 'es' + | 'esm' + | 'iife' + | 'module' + | 'system' + | 'umd'; export type OptionsPaths = Record | ((id: string) => string); diff --git a/src/utils/mergeOptions.ts b/src/utils/mergeOptions.ts index 8f8c2629a98..00455edc6e9 100644 --- a/src/utils/mergeOptions.ts +++ b/src/utils/mergeOptions.ts @@ -229,7 +229,17 @@ function getOutputOptions( command: GenericConfigObject = {} ): OutputOptions { const getOption = createGetOption(config, command); - const format = getOption('format'); + let format = getOption('format'); + + // Handle format aliases + switch (format) { + case 'esm': + case 'module': + format = 'es'; + break; + case 'commonjs': + format = 'cjs'; + } return { amd: { ...config.amd, ...command.amd },