Browse Source

Merge pull request #1163 from rollup/gh-1132

only remove valid sourcemapping URL comments
gh-1008
Rich Harris 8 years ago
committed by GitHub
parent
commit
dfe874d34f
  1. 2
      src/Bundle.js
  2. 2
      src/Module.js
  3. 3
      test/function/sourcemapping-url-comment/_config.js
  4. 3
      test/function/sourcemapping-url-comment/main.js

2
src/Bundle.js

@ -429,7 +429,7 @@ export default class Bundle {
const bundleSourcemapChain = [];
code = transformBundle( code, this.plugins, bundleSourcemapChain, options )
.replace( new RegExp( `\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'g' ), '' );
.replace( new RegExp( `^\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'gm' ), '' );
if ( options.sourceMap ) {
timeStart( 'sourceMap' );

2
src/Module.js

@ -72,7 +72,7 @@ export default class Module {
});
// remove existing sourceMappingURL comments
const pattern = new RegExp( `\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'g' );
const pattern = new RegExp( `^\\/\\/#\\s+${SOURCEMAPPING_URL}=.+\\n?`, 'gm' );
let match;
while ( match = pattern.exec( code ) ) {
this.magicString.remove( match.index, match.index + match[0].length );

3
test/function/sourcemapping-url-comment/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'only removes valid sourcemapping URL comments (#1132)'
};

3
test/function/sourcemapping-url-comment/main.js

@ -0,0 +1,3 @@
////# sourceMappingURL=foo
var val = 42;
assert.equal( val, 42 );
Loading…
Cancel
Save