-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix minified dist bundles #1094
Conversation
- bumping to node v6 disrupted the "a(r)" assumption
- so that both bundle.js and cibundle.js can use it.
- so that require.js test can be properly ran on each build!
var strOld = FRONT + MIDDLE + BACK, | ||
strNew = FRONT + ' ' + MIDDLE + ' ' + BACK; | ||
|
||
minifiedCode = minifiedCode.replace(strOld, strNew); |
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
minifiedCod.replace(/require\("\+(\w)\((\w)\)\+"\)/, 'require("+ $1($2) +")')
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:
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/
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.
Lgtm so long as we're happy with only lowercase.
💃
} | ||
} | ||
|
||
return minifiedCode; |
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 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
I always forget the semantics of A-z
vs. \W
vs. \w
. Okay:
\w
: Matches any alphanumeric character including the underscore. Equivalent to [A-Za-z0-9_].\W
: Matches any non-word character. Equivalent to[^A-Za-z0-9_]
. (= negation)[A-Za-z]
any lower or uppercase character[A-z]
maybe the same?
* | ||
*/ | ||
module.exports = function patchMinified(minifiedCode) { | ||
return minifiedCode.replace(STR_TO_REPLACE, STR_NEW); | ||
return minifiedCode.replace(PATTERN, NEW_SUBSTR); |
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.
🎉
The ugly
webworkify
+ Require.js bug strikes again 👻 The1.19.0
dist builds are broken in Require.js. In #914 (more specifically #914 (comment)) I chose to run the plotly.min.js + require.js test only on the main dist bundle because minifying plotly.js takes about 1 minute. That is, it was testing new code only on release builds (like this one).BUT, I should add: minifying plotly.js take about 1 minute, that's using node.js v4. Using node.js v6, the minifying time drops to about ~30 seconds. Good enough for me. Let's test this thing on every build!