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 integration relies on hoisting #10149
Comments
Thanks for the ping! Marked to be investigated soon. 🙏 |
Introduces a new plugin option to configure the module that the transpiled files should import. Should unblock vercel#10149 and support for yarn v2 once vercel#10149 is complete. https://github.com/zeit/styled-jsx/releases/tag/v3.3.0
Introduces a new plugin option to configure the module that the transpiled files should import. Should unblock #10149 and support for yarn v2 once #10149 is complete. https://github.com/zeit/styled-jsx/releases/tag/v3.3.0
Introduces a new plugin option to configure the module that the transpiled files should import. Should unblock vercel#10149 and support for yarn v2 once vercel#10149 is complete. https://github.com/zeit/styled-jsx/releases/tag/v3.3.0
Introduces a new plugin option to configure the module that the transpiled files should import. Should unblock vercel#10149 and support for yarn v2 once vercel#10149 is complete. https://github.com/zeit/styled-jsx/releases/tag/v3.3.0
judging by the linked issues this should be fixed in steps to repro:
|
@arcanis @therazor The issue is still unresolved. I get this error:
|
I solved my issue temporary with add |
As the error says, you're trying to require |
@merceyz I'm tried to import styled-jsx but I can't find any way to import it to my component. Do you have any idea that how to import it to a next.js component? I think in build time babel handle importing. |
Any thoughts on fixing this? I've created an example application that reproduces this issue: See: https://github.com/jordinl83/yarn-styled-jsx-bug To reproduce, just run:
And navigate to localhost:3000. You should see the error:
Also, in branch with-styled-jsx-installed I tried adding To reproduce:
Navigate to localhost:3000, open developer console and disable javascript. You'll notice that styles are not applied when reloading the page. cc @timneutkens |
@timneutkens @Timer Added failing test for Let me know if you would like me to attempt to fix it and what would be the best approach. I see @arcanis gave a recommendation in the description of this issue, so I could try that? |
When using pnpm / yarnPnP to install next.js, styled-jsx as dependency is not hoisted in the top level node_modules, it will fail when nodejs is trying to resolve `styled-jsx/style` from project directory. Re-export `styled-jsx/style` in next.js and let swc/babel plugin compile the import path it to `next/dist/shared/lib/styled-jsx` Resolves #10149 Closes #21320 Closes #9325 Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
Next generates files that contain the following import statement:
Since the output files belong to the project that depends on Next rather than Next itself, the
styled-jsx
dependency needs to be listed in the user project. Based on #9325, I think this isn't what you're looking for.Suggested fix
styled-jsx
by:next
by:styled-jsx.js
) that containsmodule.exports = require('styled-jsx/style')
(it would basically re-export its own dependency)next/styled-jsx
inside the custom import path setting that we will have implemented in 1.This solution isn't obtrusive, doesn't have breaking changes, and makes Next resilient to problems highlighted in #9325 (and, more importantly to me, makes the default
create-next-app
setup work with Yarn 2 😉).Note that I likely won't have the resources to make the fix myself right now.
The text was updated successfully, but these errors were encountered: