emotion version: 9.1.3
react version:16.3.2
babel-plugin-emotion@9.1.2
What you did:
I have a project that uses Typescript & React with Babel for testing, and Webpack to build.
I had a basic component, using emotion.div({styles}, and was attempting to write a basic snapshot test.
To accomplish the testing, I use TS-jest as recommended in the tsconfig repo. That is, according to the last couple of paragraphs here.
TS loader compiles the modules to commonjs (cjs). Then the babel plugin is run on the cjs code. At this point, I began to get errors and struggle.
What happened:
At this point, I was getting errors about needing to include the babel-plugin-emotion . This confused me, as I had it in my babelrc, and it was working when I built the code with Webpack.
It appears to be erroring because babel-plugin-emotion cannot run on cjs code.
Reproduction:
https://github.com/samcooke98/tsjest-emotion-issue
Problem description:
As ts-jest will silently update the module format to be commonjs, unless the user specifies a different one. According to #535 - Babel-plugin-emotion doesn't work on commonjs. This can result in confusing errors and difficulty getting the right configuration for Typescript and Jest.
Suggested solution:
I believe the first step would be to place something in the documentation about configuring Emotion with Typescript\Jest
I think a better solution, would be to make babel-plugin-emotion work with cjs code, but I am unsure of the technical complexity.
Hopefully, this is all clear.
emotionversion: 9.1.3reactversion:16.3.2babel-plugin-emotion@9.1.2
What you did:
I have a project that uses Typescript & React with Babel for testing, and Webpack to build.
I had a basic component, using
emotion.div({styles}, and was attempting to write a basic snapshot test.To accomplish the testing, I use TS-jest as recommended in the tsconfig repo. That is, according to the last couple of paragraphs here.
TS loader compiles the modules to commonjs (cjs). Then the babel plugin is run on the cjs code. At this point, I began to get errors and struggle.
What happened:
At this point, I was getting errors about needing to include the babel-plugin-emotion . This confused me, as I had it in my babelrc, and it was working when I built the code with Webpack.
It appears to be erroring because babel-plugin-emotion cannot run on cjs code.
Reproduction:
https://github.com/samcooke98/tsjest-emotion-issue
Problem description:
As ts-jest will silently update the module format to be commonjs, unless the user specifies a different one. According to #535 - Babel-plugin-emotion doesn't work on commonjs. This can result in confusing errors and difficulty getting the right configuration for Typescript and Jest.
Suggested solution:
I believe the first step would be to place something in the documentation about configuring Emotion with Typescript\Jest
I think a better solution, would be to make babel-plugin-emotion work with cjs code, but I am unsure of the technical complexity.
Hopefully, this is all clear.