Browse Source

Merge pull request #959 from rollup/gh-958

ensure bundle ends with newline
legacy-quote-reserved-properties
Rich Harris 8 years ago
committed by GitHub
parent
commit
568951c837
  1. 1
      src/Bundle.js
  2. 2
      src/rollup.js
  3. 10
      test/test.js

1
src/Bundle.js

@ -431,6 +431,7 @@ export default class Bundle {
timeEnd( 'sourceMap' );
}
if ( code[ code.length - 1 ] !== '\n' ) code += '\n';
return { code, map };
}

2
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 ) );

10
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()', () => {

Loading…
Cancel
Save