diff --git a/src/Bundle.js b/src/Bundle.js index d56f4a5..a4e8c53 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -431,6 +431,7 @@ export default class Bundle { timeEnd( 'sourceMap' ); } + if ( code[ code.length - 1 ] !== '\n' ) code += '\n'; return { code, map }; } diff --git a/src/rollup.js b/src/rollup.js index be39d0b..0868960 100644 --- a/src/rollup.js +++ b/src/rollup.js @@ -108,7 +108,7 @@ export function rollup ( options ) { promises.push( writeFile( dest + '.map', map.toString() ) ); } - code += `\n//# ${SOURCEMAPPING_URL}=${url}\n`; + code += `//# ${SOURCEMAPPING_URL}=${url}\n`; } promises.push( writeFile( dest, code ) ); diff --git a/test/test.js b/test/test.js index 5876435..52cc00e 100644 --- a/test/test.js +++ b/test/test.js @@ -102,6 +102,16 @@ describe( 'rollup', function () { plugins: [ loader({ x: `var a = null; a = 'a string';` }) ] }); }); + + it( 'includes a newline at the end of the bundle', () => { + return rollup.rollup({ + entry: 'x', + plugins: [ loader({ x: `console.log( 42 );` }) ] + }).then( bundle => { + const { code } = bundle.generate({ format: 'iife' }); + assert.ok( code[ code.length - 1 ] === '\n' ); + }); + }); }); describe( 'bundle.write()', () => {