question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The styled-jsx integration relies on hoisting

See original GitHub issue

Bug 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

  1. Fix styled-jsx by:
    • adding a custom import path setting (it’s currently hardcoded).
  2. Fix next by:
    • adding a new file (let’s say styled-jsx.js) that contains module.exports = require('styled-jsx/style') (it would basically re-export its own dependency)
    • updating the Babel configuration to use 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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
therazorcommented, Sep 29, 2020

judging by the linked issues this should be fixed in v9.5.3 and above, but I’m having the same problem on that version. Is there anything missing still?

steps to repro:

yarn create next-app nextjs-starter--example "https://github.com/vercel/next-learn-starter/tree/master/learn-starter"
cd nextjs-starter
yarn set version berry
yarn dev
1reaction
Timercommented, Jan 21, 2020

Thanks for the ping! Marked to be investigated soon. 🙏

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found