You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But whenever I try to import components from design-system that uses nested components (even the same components that we shown above), I'm getting the following error:
Uncaught Error: Component selectors can only be used in conjunction with @emotion/babel-plugin.
Package "A" which imports a component from package "B" which creates the component (with component selector) using emotion from package "C" should be able to successfully render the component.
In other words, my-app should be able to import Wrapper and Child and render them.
Environment information:
react version: 18.1.0
@emotion/react version: 11.9.0
@emotion/styled version: 11.8.1
@emotion/babel-plugin version: 11.9.2
The text was updated successfully, but these errors were encountered:
(Disclaimer, I don't know how Vite works, but...) The most likely cause of this problem is that Babel is only being run on my-app, not design-system.
I looked at the compiled files for your application using the Sources tab of the browser dev tools and saw this.
design-system/src/index.ts does not appear to have been compiled by Babel:
While my-app/src/App.tsx has been compiled by Babel:
So I'm pretty sure this is a Vite configuration problem rather than a bug in Emotion.
One option could be to run Babel on each package except my-app to compile all the TypeScript to plain JavaScript, and then have Vite compile & bundle my-app.
Current behavior:
(Sorry in advance if the title isn't clear enough)
I have a monorepo with 3 packages:
emotion/styled
andemotion/react
to the other packages with the theme.packages/theming
theming
anddesign-system
.In addition,
my-app
is configured with the following babel config (via @vitejs/plugin-react):When writing the following code, everything seems to be ok:
But whenever I try to import components from
design-system
that uses nested components (even the same components that we shown above), I'm getting the following error:For simplicity, here's the flow:
To reproduce:
pnpm reproduce
(this will install the dependencies and start a dev server in my-app)Expected behavior:
Package "A" which imports a component from package "B" which creates the component (with component selector) using
emotion
from package "C" should be able to successfully render the component.In other words,
my-app
should be able to importWrapper
andChild
and render them.Environment information:
react
version: 18.1.0@emotion/react
version: 11.9.0@emotion/styled
version: 11.8.1@emotion/babel-plugin
version: 11.9.2The text was updated successfully, but these errors were encountered: