A few weeks ago, we randomly had our build start to fail with the error "ReferenceError: _styled is not defined" in the unit test step (and I truly mean randomly!). No code had been changed or merged. The pipeline on a pull request that was opened on Friday passed, and by Tuesday it started to fail with just a re-run. Our dev and main branches were also failing with the same issue, both locally and on GitHub.

We spent a lot of time looking into ways of fixing this from rebuilding our package locks with different node/nvm versions, to upgrading our emotion library and trying everything we could from the internet. Some solutions would pass the unit test step but fail later when trying to build our docs site. Ultimately, we found a temporary solution to globally import _styled and this suppressed the issue. The changes we made to fix the build can be found here:

https://github.com/cengage/react-magma/pull/1216/files

This seems to work fine for our build, but we recently learned that when a team tried to use a pre-release version on their app (v4.4.0-next.8 for example), all their unit tests failed with the same error message: "ReferenceError: _styled is not defined" .

We cannot release our next Magma version until this is fixed. We need to determine if our temporary solution is good enough and we can figure out a way so that our consumers don’t run into the same problem above, or if we need to approach this differently.

This should be reproducible locally by removing the changes in the PR above.

Some of the things that make this a little tricky is that react-magma-dom is part of a monorepo, and a lot of our package versions are old/out of date. Updating any package version could potentially cause problems in a different package, or conflict with other versions. We may, however, need to bite the bullet and make the upgrades necessary instead of the temporary solution.

Some other unsuccessful PR attempts for reference:

https://github.com/cengage/react-magma/pull/1215/files

https://github.com/cengage/react-magma/pull/1213/files