Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions lib/jsminify.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,9 @@ exports.jsminify = function (code, config, callback) {
}
config = config || exports.config;
var comments = [],
token = '"yUglify: preserved comment block"',
token = 'function fn(){"yUglify: preserved comment block";}',
reMultiComments = /\/\*![\s\S]*?\*\//g,
/*
In some cases Uglify adds a comma, in others it doesn't
So we have to process the tokens twice, first with the comma
then without it to catch both cases and to be clear about it.
*/
reTokens1 = new RegExp(token + ',', 'g'),
reTokens = new RegExp(token, 'g'),
reTokens = new RegExp('function \\w+\\(\\)\\{\\"yUglify: preserved comment block\\";\\}', 'g'),
ast;

try {
Expand All @@ -63,12 +57,6 @@ exports.jsminify = function (code, config, callback) {
code = uglify.split_lines(code, config.max_line_length);
}

//First pass with comma (comment inside code somewhere)
code = code.replace(reTokens1, function () {
return '\n' + comments.shift() + '\n';
});

//Second pass without the comma to catch normal comments
code = code.replace(reTokens, function () {
return '\n' + comments.shift() + '\n';
});
Expand Down