-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix minified dist bundles #1094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2acb387
e16d2f7
d4f216f
f958b4f
1e98161
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
var STR_TO_REPLACE = 'require("+a(r)+");'; | ||
var STR_NEW = 'require("+ a(r) +");'; | ||
var ALPHABET = 'abcdefghijklmnopqrstuvwxyz'.split(''); | ||
var FRONT = 'require("+'; | ||
var BACK = '+");'; | ||
|
||
/* Uber hacky in-house fix to | ||
* | ||
|
@@ -11,5 +12,20 @@ var STR_NEW = 'require("+ a(r) +");'; | |
* | ||
*/ | ||
module.exports = function patchMinified(minifiedCode) { | ||
return minifiedCode.replace(STR_TO_REPLACE, STR_NEW); | ||
for(var i = 0; i < ALPHABET.length; i++) { | ||
var li = ALPHABET[i]; | ||
|
||
for(var j = 0; j < ALPHABET.length; j++) { | ||
var lj = ALPHABET[j]; | ||
|
||
var MIDDLE = li + '(' + lj + ')'; | ||
|
||
var strOld = FRONT + MIDDLE + BACK, | ||
strNew = FRONT + ' ' + MIDDLE + ' ' + BACK; | ||
|
||
minifiedCode = minifiedCode.replace(strOld, strNew); | ||
} | ||
} | ||
|
||
return minifiedCode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is hilarious. Do we need to check for uppercase letters or does it stick to all lowers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. Does uglify-js use uppercase lettes? I don't know. But anyway, @rreusser's solution should cover that case too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always forget the semantics of
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's a way to do using Regex, please let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rreusser 's got the answer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could also be done using
.split(strOld).join(strNew)
but I have no idea if it would be any faster in this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great tool for these things:
http://scriptular.com/#require%5C(%22%5C%2B(%5Cw)%5C((%5Cw)%5C)%5C%2B%22%5C)%7C%7C%7C%7C%7C%7C%7C%7C%5B%22require(%5C%22%2Bo(s)%2B%5C%22)%22%5D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slight modification for lower or uppercase:
/require\("\+([A-z])\(([A-z])\)\+"\)/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I counter with https://regex101.com/