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

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle missing default export even if first pass matched
Closes #255.
  • Loading branch information
adrianheine committed Jan 27, 2018
1 parent d195bab commit f3b488c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Expand Up @@ -183,7 +183,10 @@ export default function commonjs ( options = {} ) {
}

const transformed = transformCommonjs( code, id, entryModuleIds.indexOf(id) !== -1, ignoreGlobal, ignoreRequire, customNamedExports[ id ], sourceMap, allowDynamicRequire, ast );
if ( !transformed ) return;
if ( !transformed ) {
esModulesWithoutDefaultExport.push( id );
return;
}

commonjsModules.set( id, true );
return transformed;
Expand Down
2 changes: 2 additions & 0 deletions test/function/bare-import-comment/bar.js
@@ -0,0 +1,2 @@
// Great module
Math.bar = 42;
1 change: 1 addition & 0 deletions test/function/bare-import-comment/foo.js
@@ -0,0 +1 @@
require( './bar.js' );
3 changes: 3 additions & 0 deletions test/function/bare-import-comment/main.js
@@ -0,0 +1,3 @@
import './foo.js';

assert.equal( Math.bar, 42 );
7 changes: 7 additions & 0 deletions test/test.js
Expand Up @@ -481,6 +481,13 @@ describe( 'rollup-plugin-commonjs', () => {
onwarn: (warn) => warns.push( warn )
});
assert.equal( warns.length, 0 );

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

0 comments on commit f3b488c

Please sign in to comment.