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

[appDir] Next.js appDir can not resolve virtual CSS files injected by webpack-virtual-modules #44266

Open
1 task done
SukkaW opened this issue Dec 22, 2022 · 1 comment
Open
1 task done
Labels
bug Issue was opened via the bug report template.

Comments

@SukkaW
Copy link
Contributor

SukkaW commented Dec 22, 2022

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.2.0: Tue Nov  8 21:14:46 PST 2022; root:xnu-8792.60.55.131.1~1/RELEASE_X86_64
Binaries:
  Node: 18.12.1
  npm: 8.19.3
  Yarn: 1.22.19
  pnpm: 7.18.1
Relevant packages:
  next: 13.0.8-canary.4
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/SukkaW/nextjs-issue-virtual-css

To Reproduce

git clone https://github.com/SukkaW/nextjs-issue-virtual-css
cd nextjs-issue-virtual-css
npm run dev

Open https://localhost:3001

Describe the Bug

Next.js' fails to collect CSS injected by webpack-virtual-modules from appDir, resulting in a Module not found error:

image

https://github.com/SukkaW/nextjs-issue-virtual-css/blob/a191e1cc9a0afcae2331b691dd6b11066940679a/next.config.js


I am porting a CSS-in-JS Next.js plugin to Next.js appDir (johanholmerin/style9#83). And it is common for CSS-in-JS to utilize webpack-virtual-modules to emit virtual CSS files (E.g. WindiCSS).

However, Next.js 13 can not collect virtual CSS from appDir. Which would break all existing AoT CSS-in-JS plugins. And I have created a minimal re-production above.

cc @shuding

Expected Behavior

The emitted virtual CSS files should be collected and resolved, just like the pages dir.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@SukkaW SukkaW added the bug Issue was opened via the bug report template. label Dec 22, 2022
@SukkaW SukkaW changed the title [appDir] Next.js appDir can not resolve virtual CSS files injected by webpack-virtual-modules` [appDir] Next.js appDir can not resolve virtual CSS files injected by webpack-virtual-modules Dec 22, 2022
@asos-tomp
Copy link

Try disabling the SWC compiler, using:

{
  "presets": ["next/babel"]
}

...which appears to allow webpack-virtual-modules to function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants