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
Remove lodash sortBy use #13021
Remove lodash sortBy use #13021
Conversation
This one `require` increases startup time by 100ms (coming from `loadOptions`).
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44528/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 23da89c:
|
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.
lodash/sort
is stable. However, Array#sort
is not stable util V8 7.0. We can polyfill it by lodash sortBy on Node.js < 11 like we did for other features:
Lines 259 to 270 in 21e8e59
replacement: template({ syntacticPlaceholders: true })` | |
((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))(process.versions.node, "8.9") | |
? require.resolve | |
: (/* request */ r, { paths: [/* base */ b] }, M = require("module")) => { | |
let /* filename */ f = M._findPath(r, M._nodeModulePaths(b).concat(b)); | |
if (f) return f; | |
f = new Error(\`Cannot resolve module '\${r}'\`); | |
f.code = "MODULE_NOT_FOUND"; | |
throw f; | |
} | |
`, | |
}, |
Hopefully we can switch to Array#sort
in Babel 8.
I added a simple bucket sorter. And it's faster! https://jsbench.github.io/#f32d70e88170ab4e165ac1f7f30df163 |
Good catch. We should add logical assignment to shippedProposals. |
Does this change the behavior when |
You're right. I've updated to not use an array. |
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.
Thanks!
This one
require
increases startup time by ~100ms (coming fromloadOptions
).Re: #11726