Skip to content

Commit

Permalink
Rename packages (#1675)
Browse files Browse the repository at this point in the history
* WIP codemod for renaming

* Lockfile changes

* emotion -> @emotion/css

* core -> react

* Server stuff

* Move removed packages to another directory

* More things

* More things

* Some more things

* Rename ESLint plugin

* Change name in @emotion/eslint-plugin CHANGELOG.md

* Jest package and Babel plugin renmaes

* Things

* Update eslint plugin migration error message

* Formatting things

* Fix some things

* Upgrade babel-eslint

* Add @emotion/pkg-renaming rule to ESLint config and run it

* Update existing changesets

* Add some changesets

* Update removed-packages/create-emotion/src/index.js

Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Update removed-packages/emotion/macro.js

Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Update removed-packages/eslint-plugin-emotion/src/index.js

Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Update CodeSandbox CI config

* Fix some things

* Fix more things

* Fix some stuff

* Fix some more things

* More fixes

* Some things

* Various updates for babel plugin

* Fix more things

* Fix another thing

* Things

* More stuff

* Bad linting rules.

* More things

* More changes

* Fix all the babel plugin stuff

* Test the Babel plugin in dist tests because it's built now

* Fix docs site building maybe

* Update some snapshots

* Fix some more things

* Hopefully actually fix it this time

* Replace @emotion/core with @emotion/react in a bunch of places

* Fix TS types for @emotion/server/create-instance

* Update snapshots

* Disable a TSLint rule

* More changesets

* Docs and things

* Fix more things

* Fix a thing

* Add a test:typescript script

* Use glob in CodeSandbox CI config

* Fix a thing

* Fix TS things

* ESLint plugin things

* Fix some things

* Fix @emotion/server pkg.json syntax error

* Update docs/package-summary.mdx

Co-Authored-By: Mateusz Burzyński <mateuszburzynski@gmail.com>

* Fix some things

* Add docs for creating instances of @emotion/css

* Fix some little things

* Comment out a test

* Fix some little things

* ts@next..........

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
  • Loading branch information
emmatown and Andarist authored Jan 5, 2020
1 parent 5936812 commit b8476e0
Show file tree
Hide file tree
Showing 533 changed files with 2,499 additions and 7,959 deletions.
6 changes: 6 additions & 0 deletions .changeset/brave-rice-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/eslint-plugin': major
'eslint-plugin-emotion': major
---

Rename `eslint-plugin-emotion` to `@emotion/eslint-plugin`. Please replace `"plugins": ["emotion"]` with `"plugins": ["@emotion"]` and `emotion/` with `@emotion/` in your rules config in your ESLint config.
2 changes: 1 addition & 1 deletion .changeset/clever-emus-watch.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': minor
'@emotion/babel-plugin': minor
'@emotion/babel-preset-css-prop': minor
---

Expand Down
5 changes: 5 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@
"linked": [
[
"@emotion/core",
"@emotion/react",
"@emotion/styled",
"@emotion/styled-base",
"@emotion/cache",
"@emotion/css",
"create-emotion",
"emotion",
"emotion-server",
"@emotion/server",
"create-emotion-server",
"babel-plugin-emotion",
"@emotion/babel-plugin",
"@emotion/babel-preset-css-prop",
"jest-emotion",
"@emotion/jest",
"@emotion/native",
"@emotion/primitives",
"@emotion/primitives-core",
"eslint-plugin-emotion",
"@emotion/eslint-plugin",
"emotion-theming"
]
],
Expand Down
5 changes: 5 additions & 0 deletions .changeset/eleven-apes-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/jest': minor
---

Improve support for Enzyme's shallow rendering with the addition of the @emotion/jest/enzyme snapshot serializer
2 changes: 1 addition & 1 deletion .changeset/flat-adults-add.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'jest-emotion': patch
'@emotion/jest': patch
---

Take specificity into account when matching styles
4 changes: 2 additions & 2 deletions .changeset/four-cars-tell.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
'@emotion/core': major
'@emotion/react': major
'@emotion/styled': major
---

Reworked TypeScript definitions so it's easier to provide a type for Theme. Instead of creating custom instances (like before) you can augment builtin Theme interface like this:

```ts
declare module '@emotion/core' {
declare module '@emotion/react' {
export interface Theme {
primaryColor: string
secondaryColor: string
Expand Down
2 changes: 1 addition & 1 deletion .changeset/giant-oranges-impress.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': major
'@emotion/babel-plugin': major
'@emotion/babel-preset-css-prop': major
---

Expand Down
6 changes: 6 additions & 0 deletions .changeset/grumpy-news-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/babel-plugin': major
'babel-plugin-emotion': major
---

Rename `babel-plugin-emotion` to `@emotion/babel-plugin`. Please replace `"plugins": ["emotion"]` with `"plugins": ["@emotion"]` in your Babel config.
2 changes: 1 addition & 1 deletion .changeset/large-snakes-ring.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': minor
'@emotion/babel-plugin': minor
'@emotion/babel-preset-css-prop': minor
---

Expand Down
2 changes: 1 addition & 1 deletion .changeset/lazy-elephants-stare.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': patch
'@emotion/react': patch
'@emotion/serialize': patch
---

Expand Down
2 changes: 1 addition & 1 deletion .changeset/light-mice-relate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': patch
'@emotion/babel-plugin': patch
---

Avoid transpiling vanilla emotion calls in already transpiled code to avoid double labels and such
2 changes: 1 addition & 1 deletion .changeset/long-apes-admire/changes.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": ["@emotion/serialize"]
},
{
"name": "@emotion/core",
"name": "@emotion/react",
"type": "patch",
"dependencies": [
"@emotion/css",
Expand Down
2 changes: 1 addition & 1 deletion .changeset/lovely-owls-remember.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': minor
'@emotion/react': minor
---

Support functions in arrays passed to css prop and Global's styles prop. This allows for composition of theme-accepting functions.
2 changes: 1 addition & 1 deletion .changeset/mean-deers-confess.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'jest-emotion': major
'@emotion/jest': major
---

Added the `T` parameter to the `Matchers` interface in the TypeScript definitions to make this module compatible with `@types/jest@^24.0.20`.
2 changes: 1 addition & 1 deletion .changeset/modern-grapes-obey.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': major
'@emotion/babel-plugin': major
---

Drop Babel 6 support
4 changes: 2 additions & 2 deletions .changeset/moody-stingrays-sort.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': minor
'@emotion/react': minor
---

`Global` imported from macro entry (`@emotion/core/macro`) gets source maps generated now when inline css-less expression is used as value of the `styles` prop.
`Global` imported from macro entry (`@emotion/react/macro`) gets source maps generated now when inline css-less expression is used as value of the `styles` prop.
2 changes: 1 addition & 1 deletion .changeset/neat-ligers-film.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': patch
'@emotion/babel-plugin': patch
---

Fix issue with not updating referenced import when bailing out on already transpiled vanilla emotion nodes (a regression introduced in #1602)
6 changes: 6 additions & 0 deletions .changeset/nervous-clouds-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/react': major
'@emotion/core': major
---

Rename `@emotion/core` to `@emotion/react`. Please change any imports of `@emotion/core` to import `@emotion/react` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
2 changes: 1 addition & 1 deletion .changeset/nine-mugs-care.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': patch
'@emotion/react': patch
'@emotion/is-prop-valid': patch
'@emotion/serialize': patch
---
Expand Down
6 changes: 6 additions & 0 deletions .changeset/odd-flowers-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/css': major
'create-emotion': major
---

Move create `create-emotion` to `@emotion/css/create-instance`. Please change any imports of `create-emotion` to import `@emotion/css/create-instance` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
2 changes: 1 addition & 1 deletion .changeset/polite-impalas-doubt.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': major
'@emotion/babel-plugin': major
'@emotion/babel-preset-css-prop': major
---

Expand Down
6 changes: 6 additions & 0 deletions .changeset/purple-teachers-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/jest': major
'jest-emotion': major
---

Rename `jest-emotion` to `@emotion/jest`. Please replace `"snapshotSerializers": ["jest-emotion"]` with `"snapshotSerializers": ["@emotion/jest"]` if you're using the snapshot serializer. Also replace any imports of `jest-emotion` with `@emotion/jest` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
6 changes: 4 additions & 2 deletions .changeset/rare-books-own.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
'babel-plugin-emotion': major
'@emotion/babel-plugin': major
'@emotion/cache': major
'@emotion/core': major
'@emotion/react': major
'create-emotion': major
'create-emotion-server': major
'@emotion/css': major
'emotion': major
'emotion-server': major
'@emotion/server': major
'emotion-theming': major
'@emotion/jest': major
'jest-emotion': major
'@emotion/native': major
'@emotion/primitives': major
Expand Down
2 changes: 1 addition & 1 deletion .changeset/rare-toes-grow.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'jest-emotion': patch
'@emotion/jest': patch
---

Match rules in declarations with component used as a selector
2 changes: 1 addition & 1 deletion .changeset/rich-hotels-sing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': patch
'@emotion/react': patch
---

Fix issue with published TypeScript test files augmenting Theme interface.
6 changes: 6 additions & 0 deletions .changeset/rotten-adults-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/server': major
'emotion-server': major
---

Rename `emotion-server` to `@emotion/server`. Please change any imports of `emotion-server` to import `@emotion/server` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
6 changes: 6 additions & 0 deletions .changeset/shaggy-cheetahs-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/css': major
'emotion': major
---

Rename `emotion` to `@emotion/css`. Please change any imports of `emotion` to import `@emotion/css` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
2 changes: 1 addition & 1 deletion .changeset/silver-bulldogs-beg.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'eslint-plugin-emotion': minor
'@emotion/eslint-plugin': minor
---

Respect `syntax-preference` rule when using css prop.
14 changes: 8 additions & 6 deletions .changeset/smooth-carpets-matter.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
---
'babel-plugin-emotion': major
'@emotion/core': major
'@emotion/babel-plugin': major
'@emotion/react': major
'@emotion/css': major
---

Removed `@emotion/css` - it's main purpose was to allow `css` to be a Babel macro, but since babel-plugin-macros allows us to keep imports nowadays this is no longer needed. `@emotion/core/macro` has been added to account for this use case and appropriate changes has been made to `babel-plugin-emotion` to facilitate those changes.
Removed default export from `@emotion/css` - it's main purpose was to allow `css` to be a Babel macro, but since babel-plugin-macros allows us to keep imports nowadays this is no longer needed. `@emotion/react/macro` has been added to account for this use case and appropriate changes has been made to `@emotion/babel-plugin` to facilitate those changes.

If you have used `@emotion/css` directly (it was always reexported from `@emotion/core`) or you have been using its macro then you should update your code like this:
If you have used `@emotion/css` directly (it was always reexported from `@emotion/react`) or you have been using its macro then you should update your code like this:

```diff
-import css from '@emotion/css'
+import { css } from '@emotion/core'
+import { css } from '@emotion/react'

// or
-import css from '@emotion/css/macro'
+import { css } from '@emotion/core/macro'
+import { css } from '@emotion/react/macro'
```

You can also use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin` to do this for you.
6 changes: 6 additions & 0 deletions .changeset/soft-moose-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@emotion/server': major
'create-emotion-server': major
---

Move `create-emotion-server` to `@emotion/server/create-instance`. Please change any imports of `create-emotion-server` to import `@emotion/server/create-instance` or use the `@emotion/pkg-renaming` ESLint rule from `@emotion/eslint-plugin`.
4 changes: 2 additions & 2 deletions .changeset/sour-poets-move.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': patch
'@emotion/react': patch
---

Warn if @emotion/core is initialized more than once in the same development environment.
Warn if @emotion/react is initialized more than once in the same development environment.
2 changes: 1 addition & 1 deletion .changeset/spotty-llamas-mate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': major
'@emotion/babel-plugin': major
'@emotion/styled-base': major
'@emotion/styled': major
---
Expand Down
4 changes: 2 additions & 2 deletions .changeset/stupid-radios-draw.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
'babel-plugin-emotion': minor
'@emotion/babel-plugin': minor
'@emotion/babel-preset-css-prop': minor
---

Added the `importMap` option which allows you to tell babel-plugin-emotion what imports it should look at to determine what it should transform so if you re-export Emotion's exports, you can still use the Babel transforms
Added the `importMap` option which allows you to tell @emotion/babel-plugin what imports it should look at to determine what it should transform so if you re-export Emotion's exports, you can still use the Babel transforms
2 changes: 1 addition & 1 deletion .changeset/two-baboons-mate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@emotion/core': major
'@emotion/react': major
'emotion-theming': major
'@emotion/native': major
'@emotion/primitives-core': major
Expand Down
2 changes: 1 addition & 1 deletion .changeset/two-kiwis-give.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'babel-plugin-emotion': minor
'@emotion/babel-plugin': minor
---

`Global` gets handled by the Babel plugin now - this gives inline css-less expressions source maps.
5 changes: 5 additions & 0 deletions .changeset/violet-spiders-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@emotion/eslint-plugin': minor
---

Add @emotion/pkg-renaming rule for Emotion 11 migration
4 changes: 2 additions & 2 deletions .changeset/weak-islands-confess.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
'@emotion/core': major
'@emotion/react': major
'emotion-theming': major
---

`emotion-theming` has been removed and all its exports were moved to `@emotion/core` package. Please import them like this `import { useTheme, ThemeProvider, withTheme } from '@emotion/core'` from now on.
`emotion-theming` has been removed and all its exports were moved to `@emotion/react` package. Please import them like this `import { useTheme, ThemeProvider, withTheme } from '@emotion/react'` from now on.
12 changes: 1 addition & 11 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{
"packages": [
"packages/babel-plugin-emotion",
"packages/cache",
"packages/core",
"packages/create-emotion",
"packages/css",
"packages/emotion",
"packages/emotion-theming",
"packages/serialize",
"packages/styled"
],
"packages": ["packages/*"],
"sandboxes": ["pk1qjqpw67"]
}
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/--bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ assignees: ''

**Environment information:**

<!-- Provide the `react` and `emotion` or `@emotion/*` packages versions -->
<!-- Provide the `react` and `@emotion/*` packages versions -->

- `react` version:
- `emotion` version:
- `@emotion/react` version:
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ Frequently viewed docs:
Get up and running with a single import.

```bash
npm install --save @emotion/core
npm install --save @emotion/react
```

```jsx
/** @jsx jsx */
import { jsx } from '@emotion/core'
import { jsx } from '@emotion/react'

let SomeComponent = props => {
return (
Expand All @@ -60,7 +60,7 @@ let SomeComponent = props => {

The babel plugin is not required, but enables some optimizations and customizations that could be beneficial for your project.

Look here 👉 _[emotion babel plugin feature table and documentation](https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin-emotion)_
Look here 👉 _[emotion babel plugin feature table and documentation](https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin)_

### Demo Sandbox

Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ module.exports = api => {
((!filename.includes('no-babel') &&
needsBabelPluginEmotion(filename)) ||
filename.includes(path.join('__tests__', 'babel'))),
plugins: ['babel-plugin-emotion']
plugins: ['@emotion/babel-plugin']
},
{
test: filename =>
filename &&
filename.includes('source-map') &&
needsBabelPluginEmotion(filename),
plugins: [['babel-plugin-emotion', { sourceMap: true }]]
plugins: [['@emotion/babel-plugin', { sourceMap: true }]]
}
]
}
Expand Down
Loading

0 comments on commit b8476e0

Please sign in to comment.