Skip to content

Commit

Permalink
Make sure the CLI supports output plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 10, 2019
1 parent d11bae6 commit 6931b4f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/utils/mergeOptions.ts
Expand Up @@ -168,14 +168,15 @@ function addUnknownOptionErrors(
optionType: string,
ignoredKeys: RegExp = /$./
) {
const unknownOptions = options.filter(
key => validOptions.indexOf(key) === -1 && !ignoredKeys.test(key)
);
const validOptionSet = new Set(validOptions);
const unknownOptions = options.filter(key => !validOptionSet.has(key) && !ignoredKeys.test(key));
if (unknownOptions.length > 0)
errors.push(
`Unknown ${optionType}: ${unknownOptions.join(
', '
)}. Allowed options: ${validOptions.sort().join(', ')}`
`Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${Array.from(
validOptionSet
)
.sort()
.join(', ')}`
);
}

Expand Down Expand Up @@ -283,6 +284,7 @@ function getOutputOptions(
noConflict: getOption('noConflict'),
outro: getOption('outro'),
paths: getOption('paths'),
plugins: config.plugins as any,
preferConst: getOption('preferConst'),
sourcemap: getOption('sourcemap'),
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
Expand Down
@@ -0,0 +1,4 @@
module.exports = {
description: 'generates multiple output files, only one of which is minified',
command: 'rollup -c'
};
@@ -0,0 +1,7 @@
'use strict';

const Hello = 1;
console.log(Hello);
var main = 0;

module.exports = main;
@@ -0,0 +1 @@
"use strict";const Hello=1;console.log(1);var main=0;module.exports=main;
3 changes: 3 additions & 0 deletions test/cli/samples/multiple-targets-different-plugins/main.js
@@ -0,0 +1,3 @@
const Hello = 1;
console.log(Hello);
export default 0;
@@ -0,0 +1,16 @@
import { terser } from 'rollup-plugin-terser';

export default {
input: 'main.js',
output: [
{
format: 'cjs',
file: '_actual/main.js'
},
{
format: 'cjs',
file: '_actual/minified.js',
plugins: [terser()]
}
]
};
2 changes: 1 addition & 1 deletion test/misc/optionList.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6931b4f

Please sign in to comment.