Skip to content

appDir + async server component + css-modules causes syntax error #42466

@mxmul

Description

@mxmul

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
Binaries:
  Node: 18.11.0
  npm: 8.19.2
  Yarn: 1.22.10
  pnpm: N/A
Relevant packages:
  next: 13.0.2
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Chrome, Safari

How are you deploying your application? (if relevant)

next dev

Describe the Bug

When using the experimental /app mode with the following setup, RSC seems to stream in a malformed script tag, causing a crash:

  • Uses /app directory
  • Root page has both a layout.tsx and a loading.tsx
  • page.tsx exports an async server component
  • page.tsx uses a class name from a CSS module, styles.module.css

Screenshot 2022-11-03 at 10 14 23 PM

Screenshot 2022-11-03 at 10 11 36 PM

Unexpected string literal ",". Parse error.

See minimal repro in code here: mxmul/next13-async-component-css-modules-repro@c562d4d

Expected Behavior

Page should render the loading state immediately, then the loaded content.

e.g.
Screenshot 2022-11-03 at 10 14 44 PM

Link to reproduction

https://github.com/mxmul/next13-async-component-css-modules-repro

To Reproduce

Clone the repo, and run yarn dev.

The first time you load the page, it seems to render properly. You see a loading state, then the rendered page:

Screenshot 2022-11-03 at 10 14 44 PM

After refreshing the page, you should see next crash with a syntax error:

Screenshot 2022-11-03 at 10 14 23 PM

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions