Skip to content

fix(rslib): resolve entry points from rslib config - #1695

Merged
webpro merged 3 commits into
webpro-nl:mainfrom
rpereira-anchor:fix/rslib-plugin-resolve-entries
Apr 22, 2026
Merged

fix(rslib): resolve entry points from rslib config#1695
webpro merged 3 commits into
webpro-nl:mainfrom
rpereira-anchor:fix/rslib-plugin-resolve-entries

Conversation

@rpereira-anchor

Copy link
Copy Markdown
Contributor

The problem

The rslib plugin was a stub — resolveConfig always returned [] and the config glob was listed under entry (treating rslib.config.ts as a source entry itself) instead of config (a file to parse for entries). This meant knip never extracted source entry points from rslib.config.ts, so all source files in rslib-based packages were reported as unused files.

The fix

Mirrors the rolldown and tsdown plugins:

  • Change entry key to config so knip parses the file rather than treating it as a source entry
  • Add resolveFromAST using collectPropertyValues(program, 'entry'), which walks the full AST and handles both the object-map form (source.entry: { index: './src/index.ts' }) and the array defineConfig([...]) form

Testing

Two new tests and an expanded fixture:

  • Single config with multiple named entries (source.entry: { index, browser })
  • Array config form (defineConfig([...])) — verifies deduplication when two lib configs share an entry

Tested against a real monorepo (12 rslib packages): reduced false-positive "unused files" reports from 72 to 25.

All 256 plugin tests pass.

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.
@pkg-pr-new

pkg-pr-new Bot commented Apr 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@1695
npm i https://pkg.pr.new/@knip/language-server@1695
npm i https://pkg.pr.new/@knip/mcp@1695

commit: 3745d6b

@webpro
webpro merged commit af83d68 into webpro-nl:main Apr 22, 2026
29 checks passed
@webpro

webpro commented Apr 22, 2026

Copy link
Copy Markdown
Member

Thanks Ricardo! 👌

@webpro

webpro commented Apr 22, 2026

Copy link
Copy Markdown
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.

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.

2 participants