Skip to content
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

Replace lodash 'clone' usage with ES6 Spread initializer #11811

Merged
merged 2 commits into from Jul 9, 2020
Merged

Replace lodash 'clone' usage with ES6 Spread initializer #11811

merged 2 commits into from Jul 9, 2020

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Jul 9, 2020

Q                       A
Patch: Bug Fix? No
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? No
Any Dependency Changes? No
License MIT

Continues removal of lodash function dependencies identified per #11789.

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 9, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/25669/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 9, 2020

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 6da65ba:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jul 9, 2020
@existentialism existentialism merged commit 55ce749 into babel:main Jul 9, 2020
@@ -106,7 +105,7 @@ export function explode(visitor) {
if (existing) {
mergePair(existing, fns);
} else {
visitor[alias] = clone(fns);
visitor[alias] = { ...fns };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jayaddison Sorry I missed this while it was open but I think this could introduce an edge case behavior change if fns has any non-enumerable values in the prototype chain. A better replacement might be:

visitor[alias] = Object.create(Object.getPrototypeOf(fns));
Object.assign(visitor[alias], fns);

Here the cloned object is created with the prototype of fns, then Object.assign copies only the own iterable properties from fns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem at all, thanks for catching this. Fixup opened in #11820.

@jayaddison jayaddison deleted the dependencies/reduce-lodash-usage-clone branch July 10, 2020 16:24
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 10, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants