Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
add test for export 'default' warning
Browse files Browse the repository at this point in the history
  • Loading branch information
otolab committed Oct 13, 2017
1 parent c6a0d0e commit 14bdcf2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions test/samples/es-modules-without-default-export/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { a } = require('./other.js');

assert.equal( a, 1 );
1 change: 1 addition & 0 deletions test/samples/es-modules-without-default-export/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 1;
21 changes: 19 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe( 'rollup-plugin-commonjs', () => {
( config.solo ? it.only : it )( dir, async () => {
const options = Object.assign({
input: `function/${dir}/main.js`,
plugins: [ commonjs( config.pluginOptions ) ]
plugins: [ commonjs( config.pluginOptions ) ],
}, config.options || {} );

const bundle = await rollup( options );
Expand Down Expand Up @@ -432,5 +432,22 @@ describe( 'rollup-plugin-commonjs', () => {
await executeBundle( bundle, { context: { window } } );
assert.notEqual( window.b.default, undefined );
});

it( 'does not warn even if the ES module not export "default"', async () => {
const warns = [];
await rollup({
input: 'samples/es-modules-without-default-export/main.js',
plugins: [ commonjs() ],
onwarn: (warn) => warns.push( warn )
});
assert.equal( warns.length, 0 );

await rollup({
input: 'function/bare-import/bar.js',
plugins: [ commonjs() ],
onwarn: (warn) => warns.push( warn )
});
assert.equal( warns.length, 0 );
});
});
});
});

0 comments on commit 14bdcf2

Please sign in to comment.