-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[core-js-compat] Filter available modules without using an intermediate set #590
[core-js-compat] Filter available modules without using an intermediate set #590
Conversation
packages/core-js-compat/package.json
Outdated
"semver": "^6.1.3" | ||
}, | ||
"devDependencies": { | ||
"core-js-pure": "3.1.4", |
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 still used by packages/core-js-compat/src/build-entries.js
(which isn't included in the published package, so it can be a dev dependency).
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.
Since it's a similar case like in index
, it would be better also replace it.
@@ -19,7 +18,7 @@ function getModulesForEntryPoint(entry) { | |||
const relative = resolve(dir, dependency); | |||
result.push(...getModulesForEntryPoint(relative)); | |||
} | |||
return [...intersection(new Set(result), order)]; | |||
return result.sort((a, b) => order.indexOf(a) > order.indexOf(b) ? 1 : -1); |
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's slow -/
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.
Oh I tought that you meant to remove intersection
like this. Would it be ok to leave it there as it was before?
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.
Something like
const resultSet = new Set(result);
return order.filter(it => resultSet.has(it));
could be better.
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.
O(n)
vs O(n^2*log n)
if I understood correctly.
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.
Yeah good idea.
Thanks! |
Ref: babel/babel#10158 (comment)