Browse Source

Merge pull request #778 from rollup/gh-756

add newline after sourcemap comment
semi-dynamic-namespace-imports
Rich Harris 9 years ago
committed by GitHub
parent
commit
ff612af0b7
  1. 2
      bin/src/runRollup.js
  2. 2
      src/rollup.js
  3. 9
      test/cli/sourcemap-newline/_config.js
  4. 1
      test/cli/sourcemap-newline/main.js
  5. 1
      test/test.js

2
bin/src/runRollup.js

@ -242,7 +242,7 @@ function bundle ( options ) {
let { code, map } = bundle.generate( options ); let { code, map } = bundle.generate( options );
if ( options.sourceMap === 'inline' ) { if ( options.sourceMap === 'inline' ) {
code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}`; code += `\n//# ${SOURCEMAPPING_URL}=${map.toUrl()}\n`;
} }
process.stdout.write( code ); process.stdout.write( code );

2
src/rollup.js

@ -94,7 +94,7 @@ export function rollup ( options ) {
promises.push( writeFile( dest + '.map', map.toString() ) ); promises.push( writeFile( dest + '.map', map.toString() ) );
} }
code += `\n//# ${SOURCEMAPPING_URL}=${url}`; code += `\n//# ${SOURCEMAPPING_URL}=${url}\n`;
} }
promises.push( writeFile( dest, code ) ); promises.push( writeFile( dest, code ) );

9
test/cli/sourcemap-newline/_config.js

@ -0,0 +1,9 @@
const assert = require( 'assert' );
module.exports = {
description: 'adds a newline after the sourceMappingURL comment (#756)',
command: 'rollup -i main.js -m inline',
result: code => {
assert.equal( code.slice( -1 ), '\n' );
}
};

1
test/cli/sourcemap-newline/main.js

@ -0,0 +1 @@
console.log( 42 );

1
test/test.js

@ -439,6 +439,7 @@ describe( 'rollup', function () {
else if ( config.result ) { else if ( config.result ) {
try { try {
config.result( code ); config.result( code );
done();
} catch ( err ) { } catch ( err ) {
done( err ); done( err );
} }

Loading…
Cancel
Save