Skip to content
This repository has been archived by the owner on Mar 15, 2020. It is now read-only.

Commit

Permalink
feat(banner): ensure that banner plugin cooperates with others
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer committed Nov 22, 2018
1 parent 4d42839 commit 67fbf72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ function minify( options = {} ) {
const bannerContent = getCommentContent( banner );
let isAlreadyInserted = false;

babelConf.plugins = [
babelConf.plugins = babelConf.plugins.concat( [
[ bannerPlugin, {
banner
} ]
];
] );

if ( !babelConf.comments ) {
babelConf.shouldPrintComment = ( comment ) => {
Expand Down
20 changes: 20 additions & 0 deletions tests/banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,24 @@ describe( 'banner and comments support', () => {
expect( bundle.code ).to.match( /^\/\* hublabubla \*\/[^\n]/ );
} );
} );

// #138
it ( 'works with other plugins', () => {
return createTransformTest( {
skipBabel: true,
fixture: 'dynamicImport',
rollupOptions: {
plugins: [
plugin( {
plugins: [
'@babel/plugin-syntax-dynamic-import'
],
banner: '/* hublabubla */'
} )
]
}
} ).then( ( { bundle } ) => {
expect( bundle.code ).to.match( /^\/\* hublabubla \*\// );
} );
} );
} );
3 changes: 2 additions & 1 deletion tests/helpers/createTransformTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ function getFixturePath( fixtureName ) {

function createTransformTest( {
fixture = defaultFixture,
skipBabel = false,
babelOptions = defaultBabelOptions,
rollupOptions = defaultRollupOptions,
bundleOptions = defaultBundleOptions
} = {} ) {
const path = getFixturePath( fixture );
const code = readFileSync( path, 'utf8' );
const babeledCode = transform( code, babelOptions );
const babeledCode = skipBabel !== true ? transform( code, babelOptions ) : null;

rollupOptions.input = path;

Expand Down

0 comments on commit 67fbf72

Please sign in to comment.