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

Update "no component selectors" error message #2727

Merged
merged 4 commits into from Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .changeset/big-years-relate.md
@@ -0,0 +1,5 @@
---
'@emotion/serialize': patch
---

Changed the error message "Component selectors can only be used in conjunction with @emotion/babel-plugin" to reference the new swc Emotion plugin which will support component selectors soon.
Andarist marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions packages/css/test/no-babel/__snapshots__/index.test.js.snap
Expand Up @@ -12,11 +12,11 @@ exports[`css @supports 1`] = `
/>
`;

exports[`css component as selectors (object syntax) 1`] = `"Component selectors can only be used in conjunction with @emotion/babel-plugin."`;
exports[`css component as selectors (object syntax) 1`] = `"Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform."`;

exports[`css component as selectors (object syntax) 2`] = `"The above error occurred in the <Styled(div)> component:"`;

exports[`css component selectors without target 1`] = `"Component selectors can only be used in conjunction with @emotion/babel-plugin."`;
exports[`css component selectors without target 1`] = `"Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform."`;

exports[`css composition 1`] = `
.emotion-0 {
Expand Down
13 changes: 7 additions & 6 deletions packages/serialize/src/index.js
Expand Up @@ -106,6 +106,11 @@ if (process.env.NODE_ENV !== 'production') {
}
}

const noComponentSelectorMessage =
'Component selectors can only be used in conjunction with ' +
'@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' +
'compiler transform.'

function handleInterpolation(
mergedProps: void | Object,
registered: RegisteredCache | void,
Expand All @@ -119,9 +124,7 @@ function handleInterpolation(
process.env.NODE_ENV !== 'production' &&
interpolation.toString() === 'NO_COMPONENT_SELECTOR'
) {
throw new Error(
'Component selectors can only be used in conjunction with @emotion/babel-plugin.'
)
throw new Error(noComponentSelectorMessage)
}
return interpolation
}
Expand Down Expand Up @@ -247,9 +250,7 @@ function createStringFromObject(
key === 'NO_COMPONENT_SELECTOR' &&
process.env.NODE_ENV !== 'production'
) {
throw new Error(
'Component selectors can only be used in conjunction with @emotion/babel-plugin.'
)
throw new Error(noComponentSelectorMessage)
}
if (
Array.isArray(value) &&
Expand Down