Open
Conversation
Add plugin for WXT (Web Extension Framework) that: - Resolves modules from the `modules` array in wxt.config.ts as dependencies - Defines entrypoints/**/* as entry file patterns - Enables automatic detection when `wxt` is a dependency This prevents false positive "unused dependency" reports for WXT modules like `@wxt-dev/module-react` and `wxt-module-console-forward` that are referenced in the WXT config but not directly imported in source code.
eb93625 to
0a06de5
Compare
webpro
reviewed
Mar 3, 2026
Member
webpro
left a comment
There was a problem hiding this comment.
Thank you! Happy to merge, left a few remarks though.
| import { hasDependency } from '../../util/plugin.ts'; | ||
| import type { WxtConfig } from './types.ts'; | ||
|
|
||
| // https://wxt.dev/guide/configuration.html |
Comment on lines
+17
to
+19
| const entry = ['entrypoints/**/*.{ts,tsx,js,jsx,html}']; | ||
|
|
||
| const production = ['entrypoints/**/*.{ts,tsx,js,jsx,html}']; |
Member
There was a problem hiding this comment.
Production entries are entry points in default mode as well:
Suggested change
| const entry = ['entrypoints/**/*.{ts,tsx,js,jsx,html}']; | |
| const production = ['entrypoints/**/*.{ts,tsx,js,jsx,html}']; | |
| const production = ['entrypoints/**/*']; |
This glob should target all files, right?
| localConfig?.modules?.reduce<Input[]>((acc, id) => { | ||
| if (typeof id === 'string') acc.push(toDependency(id)); | ||
| return acc; | ||
| }, []) ?? []; |
Member
There was a problem hiding this comment.
This is a bit hard to read. Perhaps a for..of iteration can do the job.
| assert.deepEqual(counters, { | ||
| ...baseCounters, | ||
| files: 1, | ||
| dependencies: 1, |
Member
There was a problem hiding this comment.
Ideally there are no unused files, as both the config file and the entry point should be consumed by the plugin.
Closed
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.
Summary
modulesarray entries inwxt.config.tsas dependenciesentrypoints/**/*as entry file patterns@wxt-dev/module-react,wxt-module-console-forward)Motivation
WXT uses a
modulesarray inwxt.config.tssimilar to Nuxt's module system. Without this plugin, knip reports these modules as unused devDependencies because they're only referenced in the WXT config and never directly imported in source code.Implementation
Follows the same pattern as the Nuxt plugin:
setup()defines a globaldefineConfighelper so knip can load the configresolveConfig()extracts string entries from themodulesarray as dependenciesentrypoints/directoryTest plan
node --test test/plugins/wxt.test.ts)moduleswxt.config.tsas unused