Suggest an idea for Knip
Knip treats the exports of all entries as used. However, not all exports are always used. For example, consider the following project:
// lib/exports.js
// This function is exported via `package.json` exports. So it’s actually used.
export function used() {}
// lib/bin.js
// This function is only exported via the `package.json` `bin` field. So it’s unused.
export function unused() {}
// knip.config.js
// This module is used by Knip. Only the default export is used.
export function unused() {}
export default {}
I imagine entry could be a mapping of file name patterns to export name patterns instead of an array. So this project structure would yield a Knip config equivalent to:
{
"entry": {
"lib/bin": [],
"lib/exports": ["*"],
"knip.config.js": ["default"]
}
}
For backwards compatibility, an array could be equivalent to a mapping where each entry maps to a value of ["*"].
Suggest an idea for Knip
Knip treats the exports of all entries as used. However, not all exports are always used. For example, consider the following project:
I imagine
entrycould be a mapping of file name patterns to export name patterns instead of an array. So this project structure would yield a Knip config equivalent to:{ "entry": { "lib/bin": [], "lib/exports": ["*"], "knip.config.js": ["default"] } }For backwards compatibility, an array could be equivalent to a mapping where each entry maps to a value of
["*"].