-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc1ef24
commit 844c6c2
Showing
14 changed files
with
226 additions
and
257 deletions.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: How It Works | ||
--- | ||
|
||
In fact, the task is to compare all exports and imports of the package. Anything not imported but exported are unused exports. | ||
|
||
#### Algorithm | ||
|
||
1. collect all package exports into _exports Set_ | ||
2. traverse all files where package import may occur | ||
3. if import is found, remove it from _exports Set_ | ||
4. if the size of exports _exports Set_ became equal to 0, then exit with success | ||
5. if _exports Set_ size is not equal to 0, then exit with an error | ||
|
||
### How It Optimized | ||
|
||
1. file reading is divided into batches | ||
2. file is not immediately converted to AST. First the import of the package is searched for in the file. _createReadStream_ is used | ||
3. there is an instant exit with success as soon as the size of _exports Set_ is equal to zero |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: Limitations | ||
--- | ||
|
||
## export \* | ||
|
||
Pure Index when getting a list of exports does not parse `export *` to find out what is exported from there. For projects with this syntax, it may result in an inability to use the library. But Pure Index can help with replacing `export *`. Just run it with the [--collect-usages flag](/pure-index/intro/cli) and replace `export *` with named exports. |
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
website/src/content/docs/how-to/find-unused-code-inside-package.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
title: How to find unused code inside a package | ||
--- | ||
|
||
1. Use Pure Index to find unused exports from packages. | ||
2. Use [knip](https://github.com/webpro/knip) or [ts-prune](https://github.com/nadeesha/ts-prune) to clean up unused code inside packages. |
Oops, something went wrong.