From 8b32e2464424f78ce72fdff3075d11aac71b8bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Mon, 31 Aug 2015 11:12:53 +0200 Subject: [PATCH] Fix Module.name if id isn't a path --- src/Module.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Module.js b/src/Module.js index 57fb38b..e7a7ec1 100644 --- a/src/Module.js +++ b/src/Module.js @@ -37,6 +37,11 @@ export default class Module { // Implement Identifier interface. this.name = makeLegalIdentifier( basename( id ).slice( 0, -extname( id ).length ) ); + // HACK: If `id` isn't a path, the above code yields the empty string. + if ( !this.name ) { + this.name = makeLegalIdentifier( id ); + } + // By default, `id` is the filename. Custom resolvers and loaders // can change that, but it makes sense to use it for the source filename this.magicString = new MagicString( source, {