Browse Source

remove pre-existing sourcemap comments

contingency-plan
Rich-Harris 10 years ago
parent
commit
9164f80487
  1. 7
      src/Module.js
  2. 3
      test/form/removes-existing-sourcemap-comments/_config.js
  3. 9
      test/form/removes-existing-sourcemap-comments/_expected/amd.js
  4. 7
      test/form/removes-existing-sourcemap-comments/_expected/cjs.js
  5. 5
      test/form/removes-existing-sourcemap-comments/_expected/es6.js
  6. 9
      test/form/removes-existing-sourcemap-comments/_expected/iife.js
  7. 13
      test/form/removes-existing-sourcemap-comments/_expected/umd.js
  8. 5
      test/form/removes-existing-sourcemap-comments/foo.js
  9. 5
      test/form/removes-existing-sourcemap-comments/main.js

7
src/Module.js

@ -41,6 +41,13 @@ export default class Module {
filename: id
});
// remove existing sourceMappingURL comments
const pattern = /\/\/#\s+sourceMappingURL=.+\n?/g;
let match;
while ( match = pattern.exec( source ) ) {
this.magicString.remove( match.index, match.index + match[0].length );
}
this.suggestedNames = blank();
this.comments = [];

3
test/form/removes-existing-sourcemap-comments/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'removes existing sourcemap comments'
};

9
test/form/removes-existing-sourcemap-comments/_expected/amd.js

@ -0,0 +1,9 @@
define(function () { 'use strict';
function foo () {
return 42;
}
console.log( foo() );
});

7
test/form/removes-existing-sourcemap-comments/_expected/cjs.js

@ -0,0 +1,7 @@
'use strict';
function foo () {
return 42;
}
console.log( foo() );

5
test/form/removes-existing-sourcemap-comments/_expected/es6.js

@ -0,0 +1,5 @@
function foo () {
return 42;
}
console.log( foo() );

9
test/form/removes-existing-sourcemap-comments/_expected/iife.js

@ -0,0 +1,9 @@
(function () { 'use strict';
function foo () {
return 42;
}
console.log( foo() );
})();

13
test/form/removes-existing-sourcemap-comments/_expected/umd.js

@ -0,0 +1,13 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
factory();
}(this, function () { 'use strict';
function foo () {
return 42;
}
console.log( foo() );
}));

5
test/form/removes-existing-sourcemap-comments/foo.js

@ -0,0 +1,5 @@
export default function () {
return 42;
}
//# sourceMappingURL=foo.js.map

5
test/form/removes-existing-sourcemap-comments/main.js

@ -0,0 +1,5 @@
import foo from './foo';
console.log( foo() );
//# sourceMappingURL=main.js.map
Loading…
Cancel
Save