Skip to content

fix(vite): apply plugins from dependency nativescript.vite.mjs configs - #11669

Merged
NathanWalker merged 1 commit into
mainfrom
fix/vite-external-config-plugins
Nov 24, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/vite-external-config-plugins

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Dependencies can ship a nativescript.vite.mjs that @nativescript/vite merges into the build. Any plugins they returned were silently dropped. The rest of the config (aliases, define, …) still applied.

Cause: externalConfigsPlugin() merged those configs from a config hook, and Vite ignores plugins returned from config.

Fix: externalConfigsPlugin() now returns two entries that share one cached discovery.

  • The config hook merges each external config with its plugins removed.
  • A lazy thenable resolves to those plugins. Vite awaits and flattens it into the plugin list.

Discovery still runs at most once per process, and only when Vite resolves the config. The ESM import() fallback for configs with top-level await is unchanged.

Found with @nativescript/tanstack-router. Its tanstackRouter() plugin never ran, so routeTree.gen.ts was never regenerated, while its @solidjs/web alias did apply.

Tests

external-configs.spec.ts:

  • Config merge: the config hook result has no plugins key and still applies define.
  • Plugin registration: a plugin from a dependency config is listed in resolveConfig(...).plugins, and its hook runs.
  • Single load: the dependency config is loaded once across both entries.

The first two tests fail without the fix. The full packages/vite suite passes (1965 tests), and nx build vite succeeds.

Vite ignores `plugins` returned from a `config` hook, so plugins shipped by a
dependency's nativescript.vite.mjs were silently dropped while the rest of its
config (aliases, define, ...) applied.

externalConfigsPlugin() now returns two plugin entries sharing one cached
discovery: the config-hook plugin merges each external config without its
`plugins`, and a lazy thenable entry resolves to those plugins, which Vite
awaits and flattens into the plugin list.
@nx-cloud

nx-cloud Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 99efcf3

Command Status Duration Result
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-24 00:18:52 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11669
npm i https://pkg.pr.new/@nativescript/vite@11669
npm i https://pkg.pr.new/@nativescript/webpack@11669

commit: 99efcf3

@NathanWalker
NathanWalker merged commit 5f3baa7 into main Nov 24, 2026
13 checks passed
@NathanWalker
NathanWalker deleted the fix/vite-external-config-plugins branch November 24, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant