Skip to content

fix: vite.config default export reachable under includeEntryExports (#282)#285

Merged
BartWaardenburg merged 1 commit intofallow-rs:mainfrom
ChrisJr404:fix/vite-config-default-export-282
May 5, 2026
Merged

fix: vite.config default export reachable under includeEntryExports (#282)#285
BartWaardenburg merged 1 commit intofallow-rs:mainfrom
ChrisJr404:fix/vite-config-default-export-282

Conversation

@ChrisJr404
Copy link
Copy Markdown
Contributor

Closes #282.

Problem

vite.config.{ts,js,mts,mjs} exports a defineConfig({...}) value as default, and Vite's CLI consumes that default export — that is the entry. With includeEntryExports: true, fallow flags it as unused:

// vite.config.mts
import { defineConfig } from "vite";
export default defineConfig({ /* ... */ });
//      ^^^^^^^ reported as unused

OP repro on #282: same shape as #271 (vitest), now for plain Vite configs.

Fix

Same approach as #271 (commit ce5580c): the vite plugin contributes used_exports for vite.config.{ts,js,mts,mjs} (default), so under --include-entry-exports the framework-supplied entry export is recognised as reachable.

Smallest viable diff — one used_exports: [(...)] line on VitePlugin plus a CONFIG_EXPORTS const, mirroring VitestPlugin.

Before / after (on the OP's repro)

Before: vite.config.mts default reported under unused-exports.
After: vite.config.mts default no longer reported.

Regression pin

Existing tests in crates/core/tests/integration_test/entry_export_validation.rs already cover the case where --include-entry-exports should flag genuinely-unused named exports on non-config entries (entry_exports_detected_when_include_entry_exports_enabled, entry_exports_detected_via_config_file_include_entry_exports). They continue to pass — the new used_exports rule is glob-scoped to vite.config.{ts,js,mts,mjs} only, so non-config entry files are unaffected.

Test coverage

New integration test vite_config_default_export_is_framework_used_with_include_entry_exports + fixture tests/fixtures/vite-include-entry-exports-workspace/ (workspace shape matches the vitest sibling fixture).

cargo test -p fallow-extract        → 1391 passed
cargo test -p fallow-cli --bin fallow → 1737 passed
cargo test -p fallow-core           → 316 passed
cargo test -p fallow-core --test integration_test -- entry_export → 6 passed (incl. new + #271 sibling)

Fixes fallow-rs#282. Mirrors the vitest fix in fallow-rs#271. With --include-entry-exports,
fallow flagged vite.config.* default exports as unused even though Vite's
CLI consumes that default export. The vite plugin now contributes
used_exports for vite.config.{ts,js,mts,mjs} (default), matching the
shape already used for vitest.config.* and vitest.workspace.*.

Adds a regression fixture (vite-include-entry-exports-workspace) and an
integration test that pins the new behavior. Existing entry-export
validation tests continue to ensure --include-entry-exports still flags
truly-unused named exports on non-config entries.
@BartWaardenburg BartWaardenburg merged commit 868d44d into fallow-rs:main May 5, 2026
18 checks passed
@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Merged in 868d44d. Thanks @ChrisJr404. vite.config.{ts,js,mts,mjs} default exports are now contributed as used_exports by the vite plugin, mirroring the existing vitest treatment, so --include-entry-exports no longer flags them. The reproducer test in your PR fails on main without the production change, so the regression coverage is solid.

@BartWaardenburg
Copy link
Copy Markdown
Collaborator

Released in v2.65.0. Thanks @ChrisJr404.

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.

Vite config default export reported when used with includeEntryExports

2 participants