The styled-jsx integration relies on hoisting
See original GitHub issueBug report
Describe the bug
Next generates files that contain the following import statement:
import foo from 'styled-jsx/style';
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
- Fix
styled-jsxby:- adding a custom import path setting (it’s currently hardcoded).
- Fix
nextby:- adding a new file (let’s say
styled-jsx.js) that containsmodule.exports = require('styled-jsx/style')(it would basically re-export its own dependency) - updating the Babel configuration to use
next/styled-jsxinside the custom import path setting that we will have implemented in 1.
- adding a new file (let’s say
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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Next.js 4: React 16 and styled-jsx 2 - Vercel
styled-jsx 2 packs significant performance improvements. When used with static styles, it's the fastest way to use styles in your application.
Read more >Styled Jsx: Full CSS Support for JSX without Compromises
Full, scoped and component-friendly CSS support for JSX (rendered on the server or the client). Code and docs are for v3 which we...
Read more >Integrating with Other Libraries - React
This guide will examine some of the more common use cases, focusing on integration with jQuery and Backbone, but the same ideas can...
Read more >Releases - styled-components
switch back to mainline hoist-non-react-statics (#2934) … use funding field instead of post install script (#2931) props @koba04; fix usage of nested ...
Read more >Modern TypeScript and React Development in Vim - Thoughtbot
With a solid set of syntax highlighting in place, next up is to integrate the TypeScript language server. All the heavy lifting here...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

judging by the linked issues this should be fixed in
v9.5.3and above, but I’m having the same problem on that version. Is there anything missing still?steps to repro:
Thanks for the ping! Marked to be investigated soon. 🙏