What you did:
I use styled-components as the css-in-js library for a projects. I use it inside components that get pulled in by the MDX files as well.
What happened:
However I ran into an issue, where an error gets thrown and crashes the page that pulls in relevant mdx file:
Transforming const to the configured target environment ("es5") is not supported yet.
It gets thrown when a component that uses a styled component is used inside the mdx file.
I use Styled Components in an external component. I imported into my mdx file and the page errored out referencing styled components.
Reproduction:
The issue can be reproduced in this bare-bones repo that I created purely for reproduction purposes. Just run yarn install and yarn dev and then access http://localhost:3000/posts/second-post to see the error.
Potential solution:
Through experimentation I found a solution where setting options.target to ['esnext'] or ['es6']. I know that the standard is to transpile everything to es5 usually. Is there anything wrong with using es6 given that most modern browsers now support it?
mdx-bundler
version: 8.0.1node
version: v14.17.6npm
version: 6.14.15Relevant code or config:
What you did: I use styled-components as the css-in-js library for a projects. I use it inside components that get pulled in by the MDX files as well.
What happened:
However I ran into an issue, where an error gets thrown and crashes the page that pulls in relevant mdx file:
It gets thrown when a component that uses a styled component is used inside the mdx file.
I use Styled Components in an external component. I imported into my mdx file and the page errored out referencing styled components.
Reproduction: The issue can be reproduced in this bare-bones repo that I created purely for reproduction purposes. Just run
yarn install
andyarn dev
and then access http://localhost:3000/posts/second-post to see the error.Potential solution:
Through experimentation I found a solution where setting
options.target
to['esnext']
or['es6']
. I know that the standard is to transpile everything toes5
usually. Is there anything wrong with usinges6
given that most modern browsers now support it?