Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[babel 8] Remove methods starting with _ in @babel/traverse#16504

Merged
nicolo-ribaudo merged 1 commit into
babel:mainfrom
liuxingbaoyu:remove-methods
Jul 10, 2024
Merged

[babel 8] Remove methods starting with _ in @babel/traverse#16504
nicolo-ribaudo merged 1 commit into
babel:mainfrom
liuxingbaoyu:remove-methods

Conversation

@liuxingbaoyu
Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu commented May 17, 2024

Q                       A
Fixed Issues? Ref: #16443
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#2918
Any Dependency Changes?
License MIT

@babel-bot
Copy link
Copy Markdown
Collaborator

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

@@ -249,13 +247,11 @@ const methods = {
_guessExecutionStatusRelativeTo:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It has a reference externally.

this._resyncParent();
this._resyncList();
this._resyncKey();
_resyncParent.call(this);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think of changing all these "private methods" to accept the NodePath as the first parameter instead of this, so that we can do _resyncParent(this) instead of _resyncParent.call(this)?

Then, in index.ts we have to do

Object.assign(NodePath_Final.prototype, {
  ...
  _resyncParent: thisify(NodePath_context._resyncParent)
  ...

where thisify is

function thisify(fn) {
  return function() {
    return fn(this, ...arguments);
  }
}

in practice those thisified functions will never be called anyway, since they are only called internally by @babel/traverse.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe we can do this after Babel 8 is more stable and avoid us needing to expose certain methods.

@liuxingbaoyu liuxingbaoyu requested a review from JLHwung July 4, 2024 22:12
@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Jul 9, 2024
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

I am good with this change. We should include this change in the migration documents: these methods are meant to be private so there is no real migration approach. But if your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released.

@nicolo-ribaudo nicolo-ribaudo merged commit c90bb0c into babel:main Jul 10, 2024
@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, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 10, 2024
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: Breaking Change 💥 A type of pull request used for our changelog categories for next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants