Skip to content
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

Can not make linaria work in Nx+Next #1351

Open
gedaaaa opened this issue Sep 25, 2023 · 1 comment
Open

Can not make linaria work in Nx+Next #1351

gedaaaa opened this issue Sep 25, 2023 · 1 comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: monorepo 🔱 Issues related to usage of linaria in monorepo needs: complete repro 🖥️ Issue need to have complete repro provided platform: next.js 🛠️ Issue related to next.js

Comments

@gedaaaa
Copy link

gedaaaa commented Sep 25, 2023

Environment

  • NextJS: 12.2.5
  • React: 17.0.2
  • Node: 16.20.2
  • MacOS 13.4.1
  • Linaria version: 4.5.4
  • Bundler (+ version): webpack 5.75.0

Description

I'm trying to migrate from styled-components to linaria but can not make it work.
my code base is a monorepo with NX, and I use NextJS 12 and React 17.

I have added next-linaria, it will work if all related code is in same app.
but when I import component from libs, it throws error: Error: Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup

my next configuration file is like:

const { withLinaria: withNxLinaria } = require('nx-linaria');

const withLinaria = require('next-linaria');

const nextConfig = {
...
const plugins = [
  withBundleAnalyzer,
  [
    withLinaria,
    {
      swcMinify: true,
    },
  ],
  withNxLinaria,
  withNx,
];

module.exports = compose(plugins, nextConfig);

and I have added below section to package.json to app directory and lib directory.

"babel": {
    "presets": [
      "next/babel",
      "@babel/preset-env",
      "@babel/preset-react",
      "@linaria",
      [
        "@nrwl/react/babel",
        {
          "runtime": "automatic"
        }
      ]
    ]
  }

Reproducible Demo

I have essential code extracted to this repo:

https://github.com/gedaaaa/linaria-demo

@gedaaaa gedaaaa added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Sep 25, 2023
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler platform: next.js 🛠️ Issue related to next.js cat: monorepo 🔱 Issues related to usage of linaria in monorepo and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Sep 25, 2023
@gedaaaa gedaaaa changed the title Can not make linaria work in NX+Next Can not make linaria work in Nx+Next Sep 25, 2023
@EasonSoong
Copy link

same issue +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: monorepo 🔱 Issues related to usage of linaria in monorepo needs: complete repro 🖥️ Issue need to have complete repro provided platform: next.js 🛠️ Issue related to next.js
Projects
None yet
Development

No branches or pull requests

2 participants