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 importMap to the babel plugin #293

Merged
merged 2 commits into from
Jul 8, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/babel-preset-emotion-css-prop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default (
sourceMap,
autoLabel,
labelFormat,
importMap,
instances = [],
...options
} = {},
Expand All @@ -40,6 +41,7 @@ export default (
sourceMap,
autoLabel,
labelFormat,
importMap,
instances: ['@xstyled/emotion', ...instances],
cssPropOptimization: true,
},
Expand Down
19 changes: 8 additions & 11 deletions website/pages/docs/getting-started/migrate-from-emotion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,30 +221,27 @@ To avoid the `/** @jsx jsx */` you can use `@xstyled/babel-preset-emotion-css-pr

You may want to use [Emotion Babel plugin](https://emotion.sh/docs/babel) for minification of styles, dead code elimination, components as selectors, and a nicer debugging experience.

You have to specify xstyled inside the `importMap`:

**.babelrc**

```js
{
...,
"plugins": [
"presets": [
[
"@emotion/babel-plugin",
"@xstyled/babel-preset-emotion-css-prop",
{
"importMap": {
"@xstyled/emotion": {
"default": {
"canonicalImport": ["@emotion/styled", "default"]
}
}
}
// @emotion/babel-plugin options
// https://emotion.sh/docs/@emotion/babel-plugin
}
]
]
}
```

Note: `importMap` has some known issues coming from Emotion side
- [Emotion not compatible with styled.box](https://github.com/gregberge/xstyled/issues/286)
- [CSS prop doesnt have access to the theme](https://github.com/gregberge/xstyled/issues/285)

### Difference in `css` prop usage

`css` prop with `@xstyled/emotion` is slightly different from `css` prop with `@emotion/react`.
Expand Down