fix(rslib): resolve entry points from rslib config - #1695
Merged
webpro merged 3 commits intoApr 22, 2026
Conversation
The rslib plugin was a stub: resolveConfig always returned [] and the config glob was incorrectly listed under 'entry' (treating the config file itself as a source entry) rather than 'config' (a file to parse for entries). Fix mirrors the rolldown and tsdown plugins: - Change 'entry' key to 'config' so knip parses the file for entries - Add resolveFromAST using collectPropertyValues(program, 'entry') which walks the full AST and handles both object-map and array forms of rslib's source.entry config Tested against a real monorepo: reduced false-positive 'unused files' reports from 72 to 25 for rslib packages. All 256 plugin tests pass.
commit: |
Member
|
Thanks Ricardo! 👌 |
Member
|
🚀 This pull request is included in v6.6.1. See Release 6.6.1 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
The rslib plugin was a stub —
resolveConfigalways returned[]and the config glob was listed underentry(treatingrslib.config.tsas a source entry itself) instead ofconfig(a file to parse for entries). This meant knip never extracted source entry points fromrslib.config.ts, so all source files in rslib-based packages were reported as unused files.The fix
Mirrors the rolldown and tsdown plugins:
entrykey toconfigso knip parses the file rather than treating it as a source entryresolveFromASTusingcollectPropertyValues(program, 'entry'), which walks the full AST and handles both the object-map form (source.entry: { index: './src/index.ts' }) and the arraydefineConfig([...])formTesting
Two new tests and an expanded fixture:
source.entry: { index, browser })defineConfig([...])) — verifies deduplication when two lib configs share an entryTested against a real monorepo (12 rslib packages): reduced false-positive "unused files" reports from 72 to 25.
All 256 plugin tests pass.