Skip to content

CSS layers are incorrectly stripped from output #88533

@rossjrw

Description

@rossjrw

Link to the code that reproduces this issue

https://github.com/rossjrw/turbopack-css-layer-removal-mre

To Reproduce

npm install
npm run build
cat .next/**/*.css

Current vs. Expected behavior

Given the following raw CSS input:

@layer test1;
@import url("https://example.com/test1.css") layer(test1);

I expect the NextJS build process to preserve the import layer directive in the output.

This is the case in NextJS 15:

$ cat .next/**/*.css
@layer test1;@import url("https://example.com/test1.css") layer(test1);%

But not in NextJS 16:

$ cat .next/**/*.css
@import "https://example.com/test1.css";
@layer test1;

This looks like a bug introduced by NextJS 16 that exacerbates non-deterministic CSS ordering by removing one of the tools used to control it.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Mon Aug 25 21:17:56 PDT 2025; root:xnu-12377.1.9~3/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 24.10.0
  npm: 11.6.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

Tested against canary releases:

  • without --turbopack: introduced in v15.6.0-canary.40, which made turbopack the default
  • with --turbopack: introduced in v15.3.0-canary.11, which added --turbopack (unknown option in canary.10)

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions