Skip to content

Commit

Permalink
remove pre-existing sourcemap comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Aug 2, 2015
1 parent 41cd743 commit 9164f80
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Module.js
Expand Up @@ -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 = [];

Expand Down
3 changes: 3 additions & 0 deletions test/form/removes-existing-sourcemap-comments/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'removes existing sourcemap comments'
};
@@ -0,0 +1,9 @@
define(function () { 'use strict';

function foo () {
return 42;
}

console.log( foo() );

});
@@ -0,0 +1,7 @@
'use strict';

function foo () {
return 42;
}

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

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

function foo () {
return 42;
}

console.log( foo() );

})();
13 changes: 13 additions & 0 deletions 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 changes: 5 additions & 0 deletions test/form/removes-existing-sourcemap-comments/foo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/form/removes-existing-sourcemap-comments/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9164f80

Please sign in to comment.