@guardian/ab-react | Use react jsx runtime instead of @emotion/react jsx runtime - #489
Conversation
🦋 Changeset detectedLatest commit: 5e1b8fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Okay that's interesting, it was building locally fine https://cloud.nx.app/runs/P4FM4RwGNr, but CI is failing 🤔 |
|
Interesting the build works when I build it by itself using
|
542f03c to
e81ab0b
Compare
|
Good luck with this one–I explored enforcing the order of builds in #373, which made CI pass, but was deemed utltimately a indadequate solution to this problem. Discussing with @joecowton1 it seemed like as we require Emotion for all consumers of Source, it was acceptable to make it a peer dependency of this project. For your information, |
|
yeah we should 100% not depend on build order to stop typescript breaking! we should probably not define defaults for JSX handlers at all #490 |
This seems like a better approach to me! |
c62b042 to
0cc0d0a
Compare
0cc0d0a to
5e1b8fa
Compare
|
@coldlink should we merge this one? |
sure merge it when you like! 😄 |
What are you changing?
@guardian/ab-reactto use the defaultreact/jsx-runtimeinstead of@emotion/reacttsconfig.base.json#490 to explicitly define the jsx handler in each projectWhy?
In identity we noticed an interesting error, where
@guardian/ab-reactwas doing some "interesting" emotion stuff when we imported it causing the bundle to break in the gateway project when attempting to update@guardian/ab-reactto a version greater than3.x.x.I noticed that at the top of
node_modules/@guardian/ab-react/esm/libs/@guardian/ab-react/src/context.jsin Gateway was importing jsx from emotion instead:I saw that the
@guardian/ab-reacthas a dev dependency on@emotion/react. Looking into why this was added I noticed this commit:02f8ac1(#371)While this allows the build to pass, it also adds a dependency on the emotion jsx runtime to the output file!
For
@guardian/ab-reactI think should be using the default react jsx runtime.So after some trial and error, I updated the local
tsconfig.jsonin@guardian/ab-reactto do this.With this
make buildcompiles correctly, and I see indist/libs/@guardian/ab-react/esm/context.jsthat the top of the file now uses, which should remove the dependency on@emotion/react!