Builds that nobody touched started printing a yellow block a few weeks ago:
(!) Your Vite config uses features that are unsupported by `configLoader: 'native'`,
which is planned to become the default in a future major version of Vite:
- `__dirname` (vite.config.ts:19:28). Use `import.meta.dirname` instead
Set `VITE_CONFIG_NATIVE_IGNORE_WARNING=true` to suppress this warning.
Nothing in that message is a deprecation notice for something you enabled. The loader you are running today is reporting on the loader you have not switched to, and its report is shorter than the list of things that actually break.
The short version
Vite's default configLoader is still bundle, and the warning comes from a Rolldown plugin named vite:native-config-compat-check that rides along in that bundle pass. It recognises seven construct types, all enumerated in nativeConfigCompat.ts, and a clean report does not mean configLoader: 'native' can load your config. The check that means something is running the build twice, once with --configLoader bundle and once with --configLoader native.
Where that warning is generated
Under bundle, Vite hands vite.config.ts to Rolldown, rewrites a handful of identifiers, writes the result to node_modules/.vite-temp/vite.config.ts.timestamp-<n>.mjs, imports that file, and deletes it. The rewrites are a transform.define map inside bundleConfigFile in config.ts: __dirname becomes __vite_injected_original_dirname, __filename becomes __vite_injected_original_filename, import.meta.url becomes __vite_injected_original_import_meta_url, import.meta.dirname and import.meta.filename map onto the first two, import.meta.resolve becomes __vite_injected_original_import_meta_resolve, and import.meta.main is replaced with the literal 'false'. A companion plugin, inject-file-scope-variables, prepends the const declarations those injected names need. No require shim exists, and there is no banner past those declarations.
The import.meta.url entry runs in the helpful direction. Bundled output executes from node_modules/.vite-temp, so without that rewrite a config asking for its own URL would resolve paths inside node_modules. Native loading has no temp file, so the same expression resolves to the real config path with nothing rewriting it.
The compatibility plugin arrived in PR #22850 and shipped in the 8.1.x line. On 11 November, PR #23714 made --configLoader stable, dropped the experimental label from native, and deprecated runner with the message ` The runner config loader is deprecated and will be removed in Vite 9. Use bundle or native instead. That work is currently only in v8.4.0-beta.1, tagged 16 November; stable is v8.3.8`.
One mechanical detail worth knowing before you test: configLoader is a CLI or inline-config option, never a field inside the file it loads, since deciding how to read the config cannot depend on having read it. The value therefore lives in --configLoader on the command line, or in inlineConfig for programmatic callers. npm has the mirror-image version of this in EUNKNOWNCONFIG, where validation only happens on one of the surfaces a flag can arrive on.
Seven detectors, and what they skip
nativeConfigCompat.ts defines exactly seven incompatibility types: dirname, filename, extensionless-import, directory-index-import, json-without-attributes, json-named-import and esm-syntax-in-cjs. The plugin hooks transform, parses with parseSync from rolldown/utils, walks the tree with estree-walker, finds free __dirname and __filename references through periscopic's analyze, and always returns null, so it reads without touching the output. It skips ids beginning with \0, skips files that fail to parse, and reports __dirname only in files it has classified as ESM, which is correct behaviour since Node still defines __dirname in CommonJS.
What you get out of that is an inventory of constructs, not a result from the loader. I had that distinction demonstrated to me in October. On Brotli patch day I ran the behavioural probe I was about to publish against my own server instead of trusting node -v: the invalid-block-switch vector out of Node's own test/parallel/test-zlib-invalid-input.js. It came back errno=-9, unpatched, on a box running Node v20.20.2, a line that reached end of life on 30 April 2026. The version string had been no help in either direction.
Six breaks that survive a clean report
Scale makes this worth doing properly. A single monorepo, Plone's Aurora, counted 28 tracked vite and vitest configs printing the warning in PR #177, and one vite.config.ts usually serves the dev server, the production build and Vitest at once. When native becomes the default, today's warning becomes a startup failure with the plain Node message __dirname is not defined in ES module scope, before any plugin runs.
Break under native | Why the scan stays quiet | What catches it |
|---|---|---|
Non-erasable TypeScript: enum, runtime namespace, parameter properties, import aliases, decorators, .tsx | The plugin parses the config but never asks whether it is erasable | erasableSyntaxOnly: true in tsconfig |
import { PluginOption } from './types.ts' with no type keyword | The import resolves, so the extension detectors are satisfied; whether the binding survives stripping is not checked | verbatimModuleSyntax: true |
A workspace plugin shipping .ts source under node_modules | Bare specifiers are skipped by the resolver check except for .json paths | realpathSync on the package directory |
require('./legacy.cjs') or createRequire in an ESM config | Only ImportDeclaration, re-exports with a source, and import() with a literal string source are collected | grep, then the native run |
| A Node version below 22.18 | Runtime support is not a syntax construct, so nothing inspects it | node -v |
The scan itself, once you adopt native | No bundle pass runs, so the transform hook never fires | keep one bundle run in CI |
Node's TypeScript documentation is blunt about the second row: "Without the type keyword, Node.js will treat the import as a value import, which will result in a runtime error." Type stripping removes the declaration file's contents and leaves a value import pointing at nothing. Everything in the first row raises ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX, except decorators, which fail earlier in the parser, and .tsx, which is unsupported outright.
The node_modules rule is a hard refusal, not a heuristic: Node declines to handle TypeScript files inside folders under a node_modules path. One row there I could not settle before publishing. Node resolves symlinks by default, so a pnpm-linked workspace package whose real path lands in packages/ should still strip, but I have not confirmed that against a native run on a linked workspace. Check your own layout with node -p "require('node:fs').realpathSync('node_modules/@scope/pkg')" and read whether node_modules is still in the printed path.
Template-literal sources in import() are not classified either, so a dynamically built specifier passes with no comment. And on Node 20 the question is moot in the other direction: Vite 8 supports Node 20.19+, while native TypeScript config loading wants 22.18+, where stripping became default-on, reaching stable in 24.12 and 25.2. That end-of-life box of mine could never have run it at all.
The last row is the one I would plan around. Adopting native removes the bundle pass, which removes the transform hook, which removes the report. Early adopters give up the lint; everyone else keeps it until the default moves underneath them. A green signal produced by a check that did not run has a long history: Terraform's -minimal-refresh exits 0 on drift it never looked for.
Where native is actually the better loader
I am not arguing against the migration. Native loading deletes a writable temp directory inside node_modules, removes the timestamp churn that comes with it, and makes the config you read the code Node executes, with no injected consts to reason about. Path expressions resolve against the real file instead of a staging copy. For a config that already uses import.meta.dirname and explicit extensions, the switch is one flag and it stays switched.
The warning is noisier than it is urgent, though, and that deserves saying out loud. It fires on configs that work perfectly under the current default, and for a team pinned to Node 20 there is no action available in Vite at all until the runtime moves. If that describes you, the honest sequence is runtime first, config second.
What runner users lose
runnerImportConfigFile calls runnerImport from ./ssr/runnerImport, which executes the config through Vite's own pipeline, plugin transforms and Vite resolution included. PR #23714 deprecated that loader, scheduled its removal for Vite 9, closed the request to support inlineConfig under it (#21524) as wont-fix, and deleted runner from the config documentation entirely, so the published page no longer describes a loader plenty of repositories still set.
Neither survivor reproduces that resolution model. bundle is Rolldown invoked with tsconfig: false, and native is raw Node resolution whose only aliasing mechanism is subpath imports beginning with #. If your config imports its own plugins through a resolve.alias path, migrating off runner is a resolution change rather than a flag change, and you have one major version to do it in. Scheduled default changes do land on time: ubuntu-latest became Ubuntu 26.04 on 19 November, and Java went to 25 with it.
What to run before Vite 9
- Check the runtime first with
node -v. Below 22.18, native with a.tsconfig is unavailable, and the upgrade is the only task on your list. - Run the same build twice with one changed value and keep both outputs:
npx vite build --configLoader bundle, thennpx vite build --configLoader native. The second command is the only evidence that counts. - Add that second command to CI now as a non-blocking job, while a failure is informational. After Vite 9 removes the choice, it fails on the critical path instead.
- Turn on the three tsconfig flags Node's own docs point at:
erasableSyntaxOnly,verbatimModuleSyntax, andmodule: "nodenext". Those cover the two break classes the Vite scan structurally cannot reach. - Do the real edits:
import.meta.dirnameandimport.meta.filename, file extensions on every relative import, index files imported by their full path,with { type: 'json' }plus a default import rather than named properties, and.mtsor"type": "module"for a config carrying ESM syntax. - Resolve any workspace package your config imports and confirm its real path is outside
node_modules. - If
VITE_CONFIG_NATIVE_IGNORE_WARNING=trueis already in your CI environment, attach an owner and a date to it in the same commit that explains why, and delete it when step 2 passes. - If you set
configLoader: 'runner', start the resolution work this quarter rather than when the removal lands.
The command that settles your repo today is npx vite build --configLoader native.
FAQ
Why am I seeing this warning when I never changed my Vite config? The check is a Rolldown plugin, vite:native-config-compat-check, added in PR #22850 and shipped in the 8.1.x line. It runs inside the default bundle loader, so a Vite upgrade turned it on without any config change from you.
Is VITE_CONFIG_NATIVE_IGNORE_WARNING=true safe to set in CI? Nothing breaks today if you set it. It suppresses the notice and not the removal, so it belongs in your repo as a waiver with an owner and a review date rather than as a fix.
I replaced __dirname with import.meta.dirname and the warning is gone. Am I native-ready? A clean report rules out seven construct types. Non-erasable TypeScript, a type import missing the type keyword, .ts files under node_modules, require() calls and an unsupported Node version all pass it and still fail the loader. Run the build with --configLoader native to find out.
What happens if I set configLoader: 'native' on Node 20? Native TypeScript config loading needs Node 22.18 or newer, where stripping is on by default. Vite 8 itself supports Node 20.19+, so on Node 20 the native path with a .ts config is simply not available.
Comments
Be the first to comment.