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

Remove peer dependency on @babel/core from most packages #2985

Merged
merged 2 commits into from Feb 16, 2023

Conversation

emmatown
Copy link
Member

@emmatown emmatown commented Feb 9, 2023

Closes #2921
Closes #2660

So the only reason there is a peer dependency on @babel/core is because of @babel/plugin-syntax-jsx. I don't really think doing we even need to make @emotion/babel-plugin inherit @babel/plugin-syntax-jsx tbh since the only case it would matter is if people were running @emotion/babel-plugin without a JSX transform but just to not change the behaviour, I've inlined @babel/plugin-syntax-jsx. I think the cost of inlining it is more than worth it for getting rid of a peer dependency warning for most users.

@changeset-bot
Copy link

changeset-bot bot commented Feb 9, 2023

🦋 Changeset detected

Latest commit: 42451cd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@emotion/babel-plugin Patch
@emotion/css Patch
@emotion/native Patch
@emotion/primitives Patch
@emotion/react Patch
@emotion/styled Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@emmatown emmatown force-pushed the remove-peer-dep-on-babel-core-from-most-packages branch from 28d6184 to 24a5e99 Compare February 9, 2023 04:07
@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 9, 2023

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 42451cd:

Sandbox Source
Emotion Configuration

@codecov
Copy link

codecov bot commented Feb 9, 2023

Codecov Report

Merging #2985 (4f84220) into main (88ce707) will decrease coverage by 0.03%.
The diff coverage is 87.50%.

❗ Current head 4f84220 differs from pull request most recent head 42451cd. Consider uploading reports for the commit 42451cd to get more accurate results

Impacted Files Coverage Δ
packages/babel-plugin/src/index.js 94.01% <87.50%> (-0.48%) ⬇️

@@ -18,7 +18,6 @@
],
"dependencies": {
"@babel/helper-module-imports": "^7.16.7",
Copy link
Member

Choose a reason for hiding this comment

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

this depends on @babel/types but I guess that it should be mostly OK since those are just factories for simple objects and they shouldn't rely on identity of any class or anything like that

Comment on lines -33 to -35
"peerDependencies": {
"@babel/core": "^7.0.0"
},
Copy link
Member

Choose a reason for hiding this comment

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

This feels off but I guess that it's not a big deal if we omit it from here - we mostly use Babel through what we are given by the caller anyway.

Copy link
Member

Choose a reason for hiding this comment

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

i'm also still curious though - is this removal technically needed to fix the mentioned issues? Isn't inling@babel/plugin-syntax-jsx already sufficient?

Copy link
Member

Choose a reason for hiding this comment

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

This comment indirectly answers this question. This is somewhat needed today because we have a direct dependency on @emotion/babel-plugin in some packages.

@Andarist
Copy link
Member

Andarist commented Feb 9, 2023

What do you think about moving macros completely out of the main packages in Emotion 12 (not that I currently plan to release a new version)?

@emmatown
Copy link
Member Author

emmatown commented Feb 9, 2023

Maybe? Could just make the babel plugin an optional peer dependency though? (Note currently @babel/core isn't an optional peer dependency regardless of those peerDependenciesMeta since it's a non-optional peerDependency of @babel/plugin-syntax-jsx)

@Andarist
Copy link
Member

Andarist commented Feb 9, 2023

Note currently @babel/core isn't an optional peer dependency regardless of those peerDependenciesMeta since it's a non-optional peerDependency of @babel/plugin-syntax-jsx)

Hm, isn't this a problem with the package manager? If we optionally depend in A on B that depends non-optionally on C that shouldn't transitively make C a required dependency of A 🤔

@emmatown
Copy link
Member Author

emmatown commented Feb 9, 2023

We non-optionally depend on B (@babel/plugin-syntax-jsx) in this case

@Andarist
Copy link
Member

I don't get it... @emotion/react has an optional peer dependency on @emotion/babel-plugin and that has a non-optional dependency on @babel/plugin-syntax-jsx. I don't understand how that non-optional dependency should be relevant for @emotion/react when it's only "pulled in" through an optional peer dep.

@emmatown
Copy link
Member Author

@emotion/react has a normal (non-peer) dependency on @emotion/babel-plugin

@Andarist
Copy link
Member

@emotion/react has a normal (non-peer) dependency on @emotion/babel-plugin

Ah, I see... I was focusing on the @babel/core itself.

@emmatown emmatown force-pushed the remove-peer-dep-on-babel-core-from-most-packages branch from 4f84220 to 42451cd Compare February 16, 2023 22:47
@emmatown emmatown enabled auto-merge (squash) February 16, 2023 22:51
@emmatown emmatown merged commit 4e172c2 into main Feb 16, 2023
@emmatown emmatown deleted the remove-peer-dep-on-babel-core-from-most-packages branch February 16, 2023 22:54
@github-actions github-actions bot mentioned this pull request Feb 16, 2023
@michaelgmiller1
Copy link

Amazing this was fixed!! This will get rid of our last peerDependency warning. Hoping for a version cut soon 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

undocumented peer dependencies (babel) Unnecessary @babel/core peer dependency?
3 participants