From c394a8b9de748bff98ed99ce25983e4925f95104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Segersv=C3=A4rd?= Date: Mon, 31 Aug 2015 10:59:46 +0200 Subject: [PATCH] Fix CJS finalizer bug, where too many newline was inserted. --- src/finalisers/cjs.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/finalisers/cjs.js b/src/finalisers/cjs.js index adf8ff1..8e065d2 100644 --- a/src/finalisers/cjs.js +++ b/src/finalisers/cjs.js @@ -5,10 +5,15 @@ export default function cjs ( bundle, magicString, { exportMode }, options ) { let intro = options.useStrict === false ? `` : `'use strict';\n\n`; // TODO handle empty imports, once they're supported - const importBlock = bundle.externalModules + let importBlock = bundle.externalModules .map( module => `var ${module.name} = require('${module.id}');`) - .concat( getInteropBlock( bundle ) ) - .join( '\n' ); + .join('\n'); + + const interopBlock = getInteropBlock( bundle ); + + if ( interopBlock ) { + importBlock += '\n' + interopBlock; + } if ( importBlock ) { intro += importBlock + '\n\n';