Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: migrate with-linaria example to next-with-linaria for Next.js 13 support #45835

Closed
wants to merge 2 commits into from

Conversation

dlehmhus
Copy link
Contributor

Bug

  • Related issues linked using fixes #number
  • Integration tests added
  • Errors have a helpful link attached, see contributing.md

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • e2e tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have a helpful link attached, see contributing.md

Documentation / Examples

  • Make sure the linting passes by running pnpm build && pnpm lint
  • The "examples guidelines" are followed from our contributing doc

This PR updates the with-linaria template to use next-with-linaria instead of next-linaria for Next.js 13 support. Furthermore, this PR migrates the example to typescript and replaces the minimal example with the default Next.js starter template (Linaria edition).

@ijjk ijjk added the examples Issue was opened via the examples template. label Feb 12, 2023
@dlehmhus dlehmhus changed the title feat: migrate with-linaria to next-with-linaria for Next.js 13 support feat: migrate with-linaria example to next-with-linaria for Next.js 13 support Feb 12, 2023
@dlehmhus dlehmhus force-pushed the update-next-linaria-example branch from 72f90c9 to 146bb38 Compare February 15, 2023 12:47
@juanferreras
Copy link

many, many thanks for your work @dlehmhus! It's great to see React Server Components compatible with (zero-runtime) CSS-in-JS.

I'd love to hear from any Next.js maintainers whether the current incompatibilities on the app-dir (beta) with webpack-inline-loaders are temporary (and we could still support @linaria through the native @linaria/webpack5-loader), or whether refactoring to use webpack-virtual-modules must be a necessary change.

Related issue on style9 SukkaW/style9-webpack#1

@dlehmhus dlehmhus force-pushed the update-next-linaria-example branch from 80276af to f7456d2 Compare February 21, 2023 20:42
@SukkaW
Copy link
Contributor

SukkaW commented Feb 24, 2023

or whether refactoring to use webpack-virtual-modules must be a necessary change.

@juanferreras FYI, Next.js 13 appDir doesn't support webpack-virtual-modules, and that's why I fallback to using the virtual-file-loader approach in my style9-webpack plugin. Here I quote from README of style9-webpack:

However, webpack-virtual-modules doesn't work well with Next.js. Next.js launches multiple webpack compiler instances to compile its server-side and client-side code separately. And webpack-virtual-modules just doesn't work when it is being shared between multiple webpack compiler instances.

On the other hand, I do have a temporary workaround for the missing loader inline query issue:

SukkaW/style9-webpack@f468bf8...696f4e0

@dlehmhus
Copy link
Contributor Author

@SukkaW you actually can use webpack-virtual-modules with Next.js 13, but you have to create a new instance of webpack-virtual-modules for every webpack instances that Next.js launches and then keep them in sync. That is basically how next-with-linaria works. (It is definitely hacky, but it works)
When I got some free time, I will take a look at your approach on how you worked around that multi-instance issue 🕵️

Copy link
Member

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this please be updated to latest Next.js with stable App Router?

@leerob
Copy link
Member

leerob commented Jun 15, 2023

Given this is a few months old, I'm going to close this out – but would happily review a new PR (please link back here) if you are open to fixing up this example for the stable App Router (a few changes needed here).

Thank you!

@leerob leerob closed this Jun 15, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
examples Issue was opened via the examples template. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants