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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/healthy-squids-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@emotion/babel-plugin': patch
'@emotion/css': patch
'@emotion/native': patch
'@emotion/primitives': patch
'@emotion/react': patch
'@emotion/styled': patch
---

Remove peer dependency on `@babel/core`
4 changes: 0 additions & 4 deletions packages/babel-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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

"@babel/plugin-syntax-jsx": "^7.17.12",
"@babel/runtime": "^7.18.3",
"@emotion/hash": "^0.9.0",
"@emotion/memoize": "^0.8.0",
Expand All @@ -30,9 +29,6 @@
"source-map": "^0.5.7",
"stylis": "4.1.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
Comment on lines -33 to -35
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.

"devDependencies": {
"@babel/core": "^7.18.5",
"babel-check-duplicated-nodes": "^1.0.0"
Expand Down
17 changes: 15 additions & 2 deletions packages/babel-plugin/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import syntaxJsx from '@babel/plugin-syntax-jsx'
import {
createEmotionMacro,
transformers as vanillaTransformers
Expand Down Expand Up @@ -90,7 +89,21 @@ export default function (babel: *, options: *) {
let t = babel.types
return {
name: '@emotion',
inherits: syntaxJsx,
// https://github.com/babel/babel/blob/0c97749e0fe8ad845b902e0b23a24b308b0bf05d/packages/babel-plugin-syntax-jsx/src/index.ts#L9-L18
manipulateOptions(opts: *, parserOpts: *) {
const { plugins } = parserOpts

if (
plugins.some(p => {
const plugin = Array.isArray(p) ? p[0] : p
return plugin === 'typescript' || plugin === 'jsx'
})
) {
return
}

plugins.push('jsx')
},
visitor: {
ImportDeclaration(path: *, state: *) {
const macro = state.pluginMacros[path.node.source.value]
Expand Down
9 changes: 0 additions & 9 deletions packages/css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,7 @@
"@emotion/sheet": "^1.2.1",
"@emotion/utils": "^1.2.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@definitelytyped/dtslint": "0.0.112",
"typescript": "^4.5.5"
},
Expand Down
7 changes: 0 additions & 7 deletions packages/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
],
"types": "types/index.d.ts",
"devDependencies": {
"@babel/core": "^7.18.5",
"@definitelytyped/dtslint": "0.0.112",
"@types/react-native": "^0.63.2",
"react": "16.14.0",
Expand All @@ -34,14 +33,8 @@
"@emotion/primitives-core": "^11.10.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"react-native": ">=0.14.0 <1"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
}
},
"homepage": "https://emotion.sh",
"license": "MIT",
"repository": "https://github.com/emotion-js/emotion/tree/main/packages/native",
Expand Down
7 changes: 0 additions & 7 deletions packages/primitives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@
"@emotion/primitives-core": "^11.10.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"react": ">=16.8.0",
"react-primitives": "^0.8.1"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.18.5",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"react": "16.14.0",
Expand Down
5 changes: 0 additions & 5 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,14 @@
"hoist-non-react-statics": "^3.3.1"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"react": ">=16.8.0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"@types/react": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@definitelytyped/dtslint": "0.0.112",
"@emotion/css": "11.10.5",
"@emotion/css-prettifier": "1.1.1",
Expand Down
5 changes: 0 additions & 5 deletions packages/styled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@
"@emotion/utils": "^1.2.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0",
"@emotion/react": "^11.0.0-rc.0",
"react": ">=16.8.0"
},
"peerDependenciesMeta": {
"@babel/core": {
"optional": true
},
"@types/react": {
"optional": true
}
},
"devDependencies": {
"@babel/core": "^7.18.5",
"@definitelytyped/dtslint": "0.0.112",
"@emotion/react": "11.10.5",
"react": "16.14.0",
Expand Down
27 changes: 0 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2350,7 +2350,6 @@ __metadata:
dependencies:
"@babel/core": ^7.18.5
"@babel/helper-module-imports": ^7.16.7
"@babel/plugin-syntax-jsx": ^7.17.12
"@babel/runtime": ^7.18.3
"@emotion/hash": ^0.9.0
"@emotion/memoize": ^0.8.0
Expand All @@ -2362,8 +2361,6 @@ __metadata:
find-root: ^1.1.0
source-map: ^0.5.7
stylis: 4.1.3
peerDependencies:
"@babel/core": ^7.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2409,19 +2406,13 @@ __metadata:
version: 0.0.0-use.local
resolution: "@emotion/css@workspace:packages/css"
dependencies:
"@babel/core": ^7.18.5
"@definitelytyped/dtslint": 0.0.112
"@emotion/babel-plugin": ^11.10.5
"@emotion/cache": ^11.10.5
"@emotion/serialize": ^1.1.1
"@emotion/sheet": ^1.2.1
"@emotion/utils": ^1.2.0
typescript: ^4.5.5
peerDependencies:
"@babel/core": ^7.0.0
peerDependenciesMeta:
"@babel/core":
optional: true
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2519,19 +2510,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "@emotion/native@workspace:packages/native"
dependencies:
"@babel/core": ^7.18.5
"@definitelytyped/dtslint": 0.0.112
"@emotion/primitives-core": ^11.10.0
"@types/react-native": ^0.63.2
react: 16.14.0
react-native: ^0.63.2
typescript: ^4.5.5
peerDependencies:
"@babel/core": ^7.0.0
react-native: ">=0.14.0 <1"
peerDependenciesMeta:
"@babel/core":
optional: true
languageName: unknown
linkType: soft

Expand All @@ -2552,7 +2538,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@emotion/primitives@workspace:packages/primitives"
dependencies:
"@babel/core": ^7.18.5
"@emotion/babel-plugin": ^11.10.0
"@emotion/is-prop-valid": ^1.2.0
"@emotion/primitives-core": ^11.10.0
Expand All @@ -2561,20 +2546,15 @@ __metadata:
react: 16.14.0
react-primitives: ^0.8.1
peerDependencies:
"@babel/core": ^7.0.0
react: ">=16.8.0"
react-primitives: ^0.8.1
peerDependenciesMeta:
"@babel/core":
optional: true
languageName: unknown
linkType: soft

"@emotion/react@11.10.5, @emotion/react@^11.4.1, @emotion/react@workspace:packages/react":
version: 0.0.0-use.local
resolution: "@emotion/react@workspace:packages/react"
dependencies:
"@babel/core": ^7.18.5
"@babel/runtime": ^7.18.3
"@definitelytyped/dtslint": 0.0.112
"@emotion/babel-plugin": ^11.10.5
Expand All @@ -2593,11 +2573,8 @@ __metadata:
svg-tag-names: ^1.1.1
typescript: ^4.5.5
peerDependencies:
"@babel/core": ^7.0.0
react: ">=16.8.0"
peerDependenciesMeta:
"@babel/core":
optional: true
"@types/react":
optional: true
languageName: unknown
Expand Down Expand Up @@ -2652,7 +2629,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@emotion/styled@workspace:packages/styled"
dependencies:
"@babel/core": ^7.18.5
"@babel/runtime": ^7.18.3
"@definitelytyped/dtslint": 0.0.112
"@emotion/babel-plugin": ^11.10.5
Expand All @@ -2664,12 +2640,9 @@ __metadata:
react: 16.14.0
typescript: ^4.5.5
peerDependencies:
"@babel/core": ^7.0.0
"@emotion/react": ^11.0.0-rc.0
react: ">=16.8.0"
peerDependenciesMeta:
"@babel/core":
optional: true
"@types/react":
optional: true
languageName: unknown
Expand Down