nextjs - ✅(Solved) Fix _N_E_STYLE_LOAD insert function in CSS loader is not transpiled, breaks on old browsers [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#90518Fetched 2026-04-08 00:20:00
View on GitHub
Comments
1
Participants
2
Timeline
9
Reactions
0
Author
Timeline (top)
labeled ×2referenced ×2closed ×1commented ×1

Fix Action

Fixed

PR fix notes

PR #90556: fix(css): rewrite MiniCssExtractPlugin insert function to ES5 to support legacy browsers

Description (problem / solution / changelog)

What?

Rewrite the insert function passed to MiniCssExtractPlugin in packages/next/src/build/webpack/config/blocks/css/index.ts to use only ES5-compatible syntax.

Why?

The insert option of mini-css-extract-plugin serialises the function via Function#toString() and injects the resulting string directly into the webpack runtime chunk. This string bypasses all subsequent transpilation — it is not processed by Babel/SWC, and is not subject to the project's browserslist or output.environment webpack config.

The current function contains:

const { href, onload, onerror } = linkTag   // ES2015 destructuring
onload?.call(linkTag, ...)                  // ES2020 optional chaining

When the project targets legacy browsers (e.g. chrome >= 45) pages crash on load with:

Unexpected token {

before any CSS has been applied.

How?

Replace the destructuring with individual var declarations and replace optional chaining with explicit if null-checks:

Before:

const { href, onload, onerror } = linkTag
// ...
() => onload?.call(linkTag, { type: 'load' } as Event),
() => onerror?.call(linkTag, {} as Event)

After:

var href = linkTag.href
var onload = linkTag.onload
var onerror = linkTag.onerror
// ...
function () { if (onload) onload.call(linkTag, { type: 'load' } as Event) },
function () { if (onerror) onerror.call(linkTag, {} as Event) }

Runtime behavior is identical in all environments. The var style was intentionally chosen (over splitting const declarations) since no-var is disabled in the project ESLint config.

Fixes #90518

Changed files

  • packages/next/src/build/webpack/config/blocks/css/index.ts (modified, +14/-3)

Code Example

(function(linkTag) {
  if (typeof _N_E_STYLE_LOAD === 'function') {
    const { href, onload, onerror } = linkTag;  // ← not transpiled
    ...
  }
})(linkTag)

---

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 31815
  Available CPU cores: 22
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: export
Done in 0.84s.
RAW_BUFFERClick to expand / collapse

To Reproduce

  1. Create a Next.js app with any CSS imports
  2. Set a legacy browser target (e.g. chrome >= 45)
  3. Run next build --webpack
  4. Open the app in Chrome 45

Current vs. Expected behavior

Expected Behavior The insert function should be transpiled to ES5, or at minimum respect the project's browserslist/output.environment webpack configuration.

Actual Behavior The webpack runtime chunk contains untranspiled modern syntax injected directly as a serialized string from packages/next/src/build/webpack/config/blocks/css/index.ts:

(function(linkTag) {
  if (typeof _N_E_STYLE_LOAD === 'function') {
    const { href, onload, onerror } = linkTag;  // ← not transpiled
    ...
  }
})(linkTag)

This crashes on old browsers with Unexpected token {.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 31815
  Available CPU cores: 22
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.1.6 // Latest available version is detected (16.1.6).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: N/A
Next.js Config:
  output: export
Done in 0.84s.

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

CSS

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

next build (local)

Additional context

No response

extent analysis

Fix:

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING