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 'defaults' usage with ES6 Spread initializer #11797

Merged
merged 15 commits into from Oct 14, 2020
Merged

Replace lodash 'defaults' usage with ES6 Spread initializer #11797

merged 15 commits into from Oct 14, 2020

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented Jul 6, 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

This change is a follow-up to #11790 and proposes removal of usages of lodash/defaults from the codebase, to be replaced by the ES6 spread operator.

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 6, 2020

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 6, 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 201e82f:

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

@jayaddison
Copy link
Contributor Author

⚠️ Nope, this isn't ready as-is; the ordering of arguments are still a problem in at least one case, I think.

@jayaddison
Copy link
Contributor Author

(...and perhaps even the logic around undefined property handling via lodash.defaults could make it hard/impossible to simply drop-in the spread operator as a replacement)

@jayaddison jayaddison marked this pull request as draft July 6, 2020 15:53
@kaicataldo
Copy link
Member

Do we want to do this? The documentation for _.defaults says

Once a property is set, additional values of the same property are ignored.

So if any of the objects we’re merging in contain the same key twice, this would change the behavior.

@existentialism
Copy link
Member

@kaicataldo check out the now collapsed/outdated discussion

@existentialism existentialism added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jul 6, 2020
@jayaddison
Copy link
Contributor Author

I do think this is still a little risky and would agree with @kaicataldo's concern, even if technically the code should be safe from a readthrough and with tests passing.

@jayaddison jayaddison marked this pull request as ready for review July 6, 2020 20:24
@existentialism
Copy link
Member

I'm fine with closing and sticking with _.defaults (though I don't see it as being that risky)

@jayaddison
Copy link
Contributor Author

Would changes like this tend to be caught by manual testing of release candidates / betas before a full release?

If the CLI & library paths here get a decent amount of pre-release exercise I think that'd tend to de-risk the changes a lot.

Copy link
Contributor

@coreyfarrell coreyfarrell left a comment

Choose a reason for hiding this comment

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

I took another look, made a suggestion for babel-traverse. From what I can tell babel-cli changes are fine (I think existing behavior is maintained).

packages/babel-traverse/src/scope/index.js Outdated Show resolved Hide resolved
packages/babel-traverse/src/scope/index.js Outdated Show resolved Hide resolved
jayaddison and others added 2 commits July 10, 2020 13:59
Co-authored-by: Corey Farrell <git@cfware.com>
Co-authored-by: Corey Farrell <git@cfware.com>
@nicolo-ribaudo nicolo-ribaudo merged commit 94b5f92 into babel:main Oct 14, 2020
@nicolo-ribaudo
Copy link
Member

Thanks!

@jayaddison jayaddison deleted the dependencies/reduce-lodash-usage-defaults branch October 14, 2020 19: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 Jan 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2021
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

7 participants