Skip to content

Commit

Permalink
Merge pull request #6764 from yurydelendik/rm-umd
Browse files Browse the repository at this point in the history
Collapses UMD headers in bundled files.
  • Loading branch information
Snuffleupagus committed Dec 16, 2015
2 parents 0a21c8c + 2f704f5 commit f01911f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ target.bundle = function(args) {
// contains a license header, so the header of bundleContent can be removed.
bundleContent = stripCommentHeaders('\n' + bundleContent);

// Removes AMD and CommonJS branches from UMD headers.
bundleContent = stripUMDHeaders(bundleContent);

// Append external files last since we don't want to modify them.
bundleContent += cat(EXT_SRC_FILES);

Expand Down Expand Up @@ -614,6 +617,14 @@ function stripCommentHeaders(content, filename) {
return content;
}

function stripUMDHeaders(content) {
var reg = new RegExp(
'if \\(typeof define === \'function\' && define.amd\\) \\{[^}]*' +
'\\} else if \\(typeof exports !== \'undefined\'\\) \\{[^}]*' +
'\\} else ', 'g');
return content.replace(reg, '');
}

function cleanupJSSource(file) {
var content = cat(file);

Expand Down

0 comments on commit f01911f

Please sign in to comment.