Skip to content

Commit

Permalink
Support Node-style format aliases (#2783)
Browse files Browse the repository at this point in the history
* support Node-style format aliases

* remove unnecessary fallback

* add formats to typings
  • Loading branch information
guybedford authored and lukastaegert committed Apr 2, 2019
1 parent f5a6c30 commit 8825cdb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/rollup/types.d.ts
Expand Up @@ -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<string, string> | ((id: string) => string);

Expand Down
12 changes: 11 additions & 1 deletion src/utils/mergeOptions.ts
Expand Up @@ -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 },
Expand Down

0 comments on commit 8825cdb

Please sign in to comment.