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

Add React.createContext to @babel/plugin-transform-react-pure-annotations #11684

Closed
1 task done
jessethomson opened this issue Jun 5, 2020 · 6 comments
Closed
1 task done
Labels
area: react i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jessethomson
Copy link
Contributor

Feature Request

  • I would like to work on this feature!
    (I don't actually care who works on this, but I'm happy to do it. Whatever is easier.)

Is your feature request related to a problem?

I have a React component library. When consuming applications use the library, a bunch of React.createContext calls are added to the bundle for components that aren't even being used. This shouldn't be the case as createContext simply takes in some parameters and returns an object.

Describe the solution you'd like

Super pumped about the new @babel/plugin-transform-react-pure-annotations package. I would like to add React.createContext to this PURE_CALLS map.

const PURE_CALLS = new Map([
[
"react",
[
"cloneElement",
"createElement",
"createFactory",
"createRef",
"forwardRef",
"isValidElement",
"memo",
"lazy",
],
],

Describe alternatives you've considered.

Nothing. I'm open to them, but this seems straightforward enough.

Documentation, Adoption, Migration Strategy

Adoption and Migration are simple a npm update. Not sure is this is something that is documented or not. I'm guessing not.

@babel-bot
Copy link
Collaborator

Hey @jessethomson! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@jessethomson
Copy link
Contributor Author

Created a PR for this: #11685

@mischnic
Copy link
Contributor

Can be closed now

@jessethomson
Copy link
Contributor Author

The @babel/preset-react still has the old version of this plugin. Will that eventually get updated to use the latest version that includes this change? Or should I create an issue or something for that?

@nicolo-ribaudo
Copy link
Member

@babel/preset-react uses ^ to specify the version of the plugin, so it can already download the latest one.

@jessethomson
Copy link
Contributor Author

Oh, I totally missed that. Awesome!

@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 Sep 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: react i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants