Skip to content

Commit

Permalink
added: doc
Browse files Browse the repository at this point in the history
  • Loading branch information
binjospookie committed Jan 3, 2024
1 parent bc1ef24 commit 844c6c2
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 257 deletions.
140 changes: 0 additions & 140 deletions old.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/getConfig/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const mergeConfig = (x: Partial<Config>): Config => ({

const getConfig = async (): Promise<Config> => {
const result = (await lilconfig('pure-index', {
searchPlaces: ['package.json', '.pure-index.json', '.pure-index.js', '.pure-index.cjs'],
searchPlaces: ['.pure-index.json'],
}).search()) || { config: {} };

return mergeConfig({
Expand Down
54 changes: 0 additions & 54 deletions website/README.md

This file was deleted.

24 changes: 18 additions & 6 deletions website/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@ export default defineConfig({
base: '/pure-index',
integrations: [
starlight({
title: 'My Docs',
title: '🌿Pure Index',
social: {
github: 'https://github.com/withastro/starlight',
github: 'https://github.com/space307/pure-index',
},
sidebar: [
{
label: 'Guides',
label: 'Getting started',
items: [
// Each item here is one entry in the navigation menu.
{ label: 'Example Guide', link: '/guides/example/' },
{ label: 'Introduction', link: '/' },
{ label: 'CLI', link: '/intro/cli' },
],
},
{
label: 'How to',
items: [{ label: 'Find unused code inside a package', link: 'how-to/find-unused-code-inside-package' }],
},
{
label: 'Reference',
autogenerate: { directory: 'reference' },
items: [{ label: 'Configuration', link: 'reference/configuration' }],
},
{
label: 'Explanation',
items: [
{ label: 'How It Works', link: 'explanation/how-it-works' },
{ label: 'Limitations', link: 'explanation/limitations' },
],
},
],
customCss: ['./src/styles/layout.css'],
}),
],
});
6 changes: 5 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"@astrojs/starlight": "^0.15.2",
"astro": "^4.0.1",
"sharp": "^0.32.5"
},
"volta": {
"node": "20.10.0",
"npm": "10.2.4"
}
}
}
19 changes: 19 additions & 0 deletions website/src/content/docs/explanation/how-it-works.md
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
7 changes: 7 additions & 0 deletions website/src/content/docs/explanation/limitations.md
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.
11 changes: 0 additions & 11 deletions website/src/content/docs/guides/example.md

This file was deleted.

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.
Loading

0 comments on commit 844c6c2

Please sign in to comment.