-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The styled-jsx/babel Babel plugin incorrectly inserts ESM imports into CJS files #680
Comments
These seem to be the offending locations in the Babel plugin code:
|
Edit: Sorry, I wrote this comment in the wrong repo 😅 |
jaydenseric
added a commit
to jaydenseric/styled-jsx
that referenced
this issue
Nov 19, 2020
jaydenseric
added a commit
to jaydenseric/device-agnostic-ui
that referenced
this issue
Dec 23, 2020
…ew JSX transform. - Custom Babel plugins now run before and after the styled-jsx/babel plugin, to workaround vercel/styled-jsx#680 and vercel/styled-jsx#689 . - Temporarily remove size-limit due to ai/size-limit#205 .
Timer
added a commit
that referenced
this issue
Jan 14, 2021
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes #680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
wroy7860
added a commit
to wroy7860/styled-jsx-github-React-and-node
that referenced
this issue
Sep 19, 2022
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes vercel/styled-jsx#680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
ericbrown2716
added a commit
to ericbrown2716/styled-jsx-react-repo
that referenced
this issue
Sep 29, 2022
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes vercel/styled-jsx#680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
renawolford6
pushed a commit
to renawolford6/styled-jsx-development-react-and-node
that referenced
this issue
Oct 6, 2022
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes vercel/styled-jsx#680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
johnfrench3
pushed a commit
to johnfrench3/styled-jsx-Build-React
that referenced
this issue
Nov 2, 2022
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes vercel/styled-jsx#680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
JiachenSmith
pushed a commit
to JiachenSmith/styled-jsx
that referenced
this issue
Mar 21, 2023
* Make the styled-jsx/babel Babel plugin respect the Babel source type. Fixes vercel/styled-jsx#680 . * chore: retrigger Co-authored-by: Joe Haddad <timer150@gmail.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you want to request a feature or report a bug?
Bug!
What is the current behavior?
The
styled-jsx/babel
Babel plugin incorrectly inserts code usingimport
instead ofrequire
when the BabelsourceType
for the file isscript
(CJS).If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar
See this reproduction in the Babel REPL.
With this input:
Using the
@babel/preset-react
andstyled-jsx/babel
Babel plugins, with thesourceType
set toscript
(CJS), the output code is:Note that
import _JSXStyle from "styled-jsx/style";
has been inserted. Arequire
expression should have been inserted, not animport
statement.The CJS module format is now corrupted, resulting in code that can't be run by Node.js or be bundled correctly via webpack or other bundlers.
What is the expected behavior?
The
styled-jsx/babel
Babel plugin should always respect the module format indicated by the BabelsourceType
when transforming code. If thesourceType
isscript
, arequire
expression should be inserted, not animport
statement.Environment (include versions)
Did this work in previous versions?
The text was updated successfully, but these errors were encountered: