Unverified Commit 6f669f1a authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Skip loadBindings() Lightning CSS check during next start (#91538)

### What?

Skip the `loadBindings()` call that checks Lightning CSS support when
`loadConfig()` is called during `PHASE_PRODUCTION_SERVER` (`next
start`).

### Why?

`loadConfig()` currently calls `loadBindings()` (which loads the native
SWC `.node` binary) whenever `experimental.useLightningcss: true` is
set, in order to check whether the binary supports Lightning CSS. This
check gates a warning and a flag reset.

During `next start`, the app is already fully built — no CSS compilation
happens at serve time. Loading the native binary purely to run a
capability check that has no effect is wasted work, and it delays server
startup unnecessarily.

### How?

- Promote `PHASE_PRODUCTION_SERVER` from a type-only import to a value
import in `config.ts` so it can be used in a runtime comparison.
- Add `phase !== PHASE_PRODUCTION_SERVER &&` as the first condition of
the `if` block that calls `loadBindings()` for the Lightning CSS check.
When the phase is `PHASE_PRODUCTION_SERVER`, the block is skipped
entirely and `useLightningcss` is left as-is (unchanged).

All other phases (`PHASE_DEVELOPMENT_SERVER`, `PHASE_PRODUCTION_BUILD`,
`PHASE_EXPORT`, etc.) are unaffected — `loadBindings()` is still called
and the capability check runs as before.
Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
Co-authored-by: 's avatarClaude <noreply@anthropic.com>
parent 99d64f3a
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
PHASE_DEVELOPMENT_SERVER, PHASE_DEVELOPMENT_SERVER,
PHASE_EXPORT, PHASE_EXPORT,
PHASE_PRODUCTION_BUILD, PHASE_PRODUCTION_BUILD,
type PHASE_PRODUCTION_SERVER, PHASE_PRODUCTION_SERVER,
type PHASE_TYPE, type PHASE_TYPE,
} from '../shared/lib/constants' } from '../shared/lib/constants'
import { defaultConfig, normalizeConfig } from './config-shared' import { defaultConfig, normalizeConfig } from './config-shared'
...@@ -1796,7 +1796,10 @@ export default async function loadConfig( ...@@ -1796,7 +1796,10 @@ export default async function loadConfig(
) )
} }
if (userConfig.experimental?.useLightningcss) { if (
phase !== PHASE_PRODUCTION_SERVER &&
userConfig.experimental?.useLightningcss
) {
const { loadBindings } = const { loadBindings } =
require('../build/swc') as typeof import('../build/swc') require('../build/swc') as typeof import('../build/swc')
const isLightningSupported = ( const isLightningSupported = (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment