We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
Unused commonjs exports are not detected when they are exported using the exports alias.
For example, this unused export would be detected :
module.exports.add = () => {};
while this one won't be :
exports.add = () => {};
Thanks
The text was updated successfully, but these errors were encountered:
That's correct, also see https://knip.dev/guides/commonjs for recommendations.
This is another subtle caveat with the dynamic nature of CommonJS. Using module.exports is generally preferred over exports (also see e.g. https://www.hacksparrow.com/nodejs/exports-vs-module-exports.html).
module.exports
exports
Not sure if Knip should still try to support this, but at least we can update the docs.
Sorry, something went wrong.
Thanks for the link. The best is to avoid reassigning module.exports as much as possible, because anyway any previous export will be lost.
That would be great if Knip could support this. It would avoid refactoring every exports of big codebases before cleaning up unused one :)
404236b
🚀 This issue has been resolved in v5.8.0. See Release 5.8.0 for release notes.
Using Knip in a commercial project? Please consider sponsoring me.
Alright then :)
No branches or pull requests
Hi,
Unused commonjs exports are not detected when they are exported using the exports alias.
For example, this unused export would be detected :
while this one won't be :
Thanks
The text was updated successfully, but these errors were encountered: