-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
@compiled/babel-plugin
to not silently skip cssMap()
extracti…
…on in a few common edge-cases. (#1773) * Fix `@compiled/babel-plugin` to not require `cssMap()` to be called prior to use. Example: this code failed before for no reason other than the fact that our `state.cssMap` was generated _after_ `JSXElement` and `JSXOpeningElement` were ran. ```tsx import { cssMap } from "@compiled/react"; export default () => <div css={styles.root} />; const styles = cssMap({ root: { padding: 8 } }); ``` * Attempt to resolve 'cssMap' calls when we hit a MemberExpression that does not have this defined. * Throw an error when compiling a `cssMap` object where we expect a `css` or nested `cssMap` object. (#1774) * Throw an error when compiling a `cssMap` object where we expect a `css` or nested `cssMap` object. Fixes #1642 Example of code that silently fails today, using `styles` directly: ```tsx import { cssMap } from '@compiled/react'; const styles = cssMap({ root: { padding: 8 } }); export default () => <div css={styles} />; ``` What we expect to see instead, using `styles.root` instead: ```tsx import { cssMap } from '@compiled/react'; const styles = cssMap({ root: { padding: 8 } }); export default () => <div css={styles.root} />; ``` * Handle the scenario where we use `css={styles}` before `cssMap()` is called Also, just update the tests which muddy `cssMap` vs. `css` scope — technically a missed scenario, but one that we shouldn't hit as this throws an error if compiled in one go.
- Loading branch information
1 parent
b000220
commit 34e5339
Showing
8 changed files
with
155 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
'@compiled/babel-plugin': minor | ||
--- | ||
|
||
Fix `@compiled/babel-plugin` to not require `cssMap()` to be called prior to use. | ||
|
||
Example, this failed before for no reason other than the fact that our `state.cssMap` was generated _after_ `JSXElement` and `JSXOpeningElement` were ran. | ||
|
||
```tsx | ||
import { cssMap } from '@compiled/react'; | ||
export default () => <div css={styles.root} />; | ||
const styles = cssMap({ root: { padding: 8 } }); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
'@compiled/babel-plugin': minor | ||
--- | ||
|
||
Throw an error when compiling a `cssMap` object where we expect a `css` or nested `cssMap` object. | ||
|
||
Example of code that silently fails today, using `styles` directly: | ||
|
||
```tsx | ||
import { cssMap } from '@compiled/react'; | ||
const styles = cssMap({ root: { padding: 8 } }); | ||
export default () => <div css={styles} />; | ||
``` | ||
|
||
What we expect to see instead, using `styles.root` instead: | ||
|
||
```tsx | ||
import { cssMap } from '@compiled/react'; | ||
const styles = cssMap({ root: { padding: 8 } }); | ||
export default () => <div css={styles.root} />; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters