diff --git a/src/index.js b/src/index.js index f9c4f60..a0832e5 100644 --- a/src/index.js +++ b/src/index.js @@ -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; diff --git a/test/function/bare-import-comment/bar.js b/test/function/bare-import-comment/bar.js new file mode 100644 index 0000000..3acfdc3 --- /dev/null +++ b/test/function/bare-import-comment/bar.js @@ -0,0 +1,2 @@ +// Great module +Math.bar = 42; diff --git a/test/function/bare-import-comment/foo.js b/test/function/bare-import-comment/foo.js new file mode 100644 index 0000000..8578323 --- /dev/null +++ b/test/function/bare-import-comment/foo.js @@ -0,0 +1 @@ +require( './bar.js' ); diff --git a/test/function/bare-import-comment/main.js b/test/function/bare-import-comment/main.js new file mode 100644 index 0000000..07d5ba7 --- /dev/null +++ b/test/function/bare-import-comment/main.js @@ -0,0 +1,3 @@ +import './foo.js'; + +assert.equal( Math.bar, 42 ); diff --git a/test/test.js b/test/test.js index f7f8723..017528e 100644 --- a/test/test.js +++ b/test/test.js @@ -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 ); }); }); });