Skip to content

Commit

Permalink
feat: ignore falsy plugins (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored and shellscape committed Sep 19, 2018
1 parent 520668a commit fbc0aba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/rollup/index.ts
Expand Up @@ -90,7 +90,11 @@ function getInputOptions(rawInputOptions: GenericConfigObject): any {

checkInputOptions(inputOptions);
const plugins = inputOptions.plugins;
inputOptions.plugins = Array.isArray(plugins) ? plugins : plugins ? [plugins] : [];
inputOptions.plugins = Array.isArray(plugins)
? plugins.filter(Boolean)
: plugins
? [plugins]
: [];
inputOptions = inputOptions.plugins.reduce(applyOptionHook, inputOptions);

if (!inputOptions.experimentalCodeSplitting) {
Expand Down
11 changes: 8 additions & 3 deletions test/misc/index.js
Expand Up @@ -565,14 +565,19 @@ describe('misc', () => {
})
)
.then(() => {
const relevantWarnings = warnings.filter(
warning => warning.code === 'MISSING_GLOBAL_NAME'
);
const relevantWarnings = warnings.filter(warning => warning.code === 'MISSING_GLOBAL_NAME');
assert.equal(relevantWarnings.length, 1);
assert.equal(
relevantWarnings[0].message,
`No name was provided for external module 'lodash' in output.globals – guessing 'lodash'`
);
});
});

it('ignores falsy plugins', () => {
return rollup.rollup({
input: 'x',
plugins: [loader({ x: `console.log( 42 );` }), null, false, undefined]
});
});
});

0 comments on commit fbc0aba

Please sign in to comment.