diff --git a/bin/src/runRollup.js b/bin/src/runRollup.js index c798634..cbfa064 100644 --- a/bin/src/runRollup.js +++ b/bin/src/runRollup.js @@ -242,7 +242,7 @@ function bundle ( options ) { let { code, map } = bundle.generate( options ); if ( options.sourceMap === 'inline' ) { - code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}`; + code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}\n`; } process.stdout.write( code ); diff --git a/src/rollup.js b/src/rollup.js index e3a91b2..1efa49a 100644 --- a/src/rollup.js +++ b/src/rollup.js @@ -94,7 +94,7 @@ export function rollup ( options ) { promises.push( writeFile( dest + '.map', map.toString() ) ); } - code += `\n//# ${SOURCEMAPPING_URL}=${url}`; + code += `\n//# ${SOURCEMAPPING_URL}=${url}\n`; } promises.push( writeFile( dest, code ) ); diff --git a/test/cli/sourcemap-newline/_config.js b/test/cli/sourcemap-newline/_config.js new file mode 100644 index 0000000..8605e29 --- /dev/null +++ b/test/cli/sourcemap-newline/_config.js @@ -0,0 +1,10 @@ +const assert = require( 'assert' ); + +module.exports = { + solo: true, + description: 'adds a newline after the sourceMappingURL comment (#756)', + command: 'rollup -i main.js -m inline', + result: code => { + assert.equal( code.slice( -1 ), '\n' ); + } +}; diff --git a/test/cli/sourcemap-newline/main.js b/test/cli/sourcemap-newline/main.js new file mode 100644 index 0000000..5c72ff3 --- /dev/null +++ b/test/cli/sourcemap-newline/main.js @@ -0,0 +1 @@ +console.log( 42 ); diff --git a/test/test.js b/test/test.js index c7ea116..61efcb2 100644 --- a/test/test.js +++ b/test/test.js @@ -439,6 +439,7 @@ describe( 'rollup', function () { else if ( config.result ) { try { config.result( code ); + done(); } catch ( err ) { done( err ); }