From bc521bfaf8f23fad34c37ee5ec7d6447f30a656c Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Tue, 10 May 2016 10:50:10 -0700 Subject: [PATCH] Don't process the entry file, it causes explosions See #63 for an explanation of why. --- src/index.js | 2 +- test/test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 376577c..3a93f31 100644 --- a/src/index.js +++ b/src/index.js @@ -64,7 +64,7 @@ export default function commonjs ( options = {} ) { return { resolveId ( importee, importer ) { - if ( importee[0] !== '.' ) return; // not our problem + if ( importee[0] !== '.' || !importer ) return; // not our problem const resolved = resolve( dirname( importer ), importee ); const candidates = getCandidates( resolved, extensions ); diff --git a/test/test.js b/test/test.js index 21846d8..bd60079 100644 --- a/test/test.js +++ b/test/test.js @@ -254,4 +254,11 @@ describe( 'rollup-plugin-commonjs', () => { assert.equal( global.setImmediate, mod.immediate, generated.code ); }); }); + + it( 'does not process the entry file when it has a leading "." (issue #63)', () => { + return rollup({ + entry: './samples/basic/main.js', + plugins: [ commonjs() ] + }).then( executeBundle ); + }); });