rev-dep 1.0.0-alpha.4 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +362 -53
- package/bin.js +1 -1
- package/dist/babel/index.d.ts +1 -0
- package/dist/cli/commonOptions.d.ts +23 -0
- package/dist/cli/createCommands.d.ts +2 -0
- package/dist/cli/docs/generate.d.ts +20 -0
- package/dist/cli/docs/index.d.ts +3 -0
- package/dist/cli/docs/template.d.ts +3 -0
- package/dist/cli/entryPoints/index.d.ts +2 -0
- package/dist/cli/entryPoints/types.d.ts +4 -0
- package/dist/cli/files/index.d.ts +2 -0
- package/dist/cli/files/types.d.ts +3 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/resolve/formatResults.d.ts +9 -0
- package/dist/cli/resolve/index.d.ts +2 -0
- package/dist/cli/resolve/index.js +2 -2
- package/dist/cli/resolve/types.d.ts +9 -0
- package/dist/lib/buildDepsGraph.d.ts +2 -0
- package/dist/lib/cleanupDpdmDeps.d.ts +3 -0
- package/dist/lib/getDepsSetWebpack.d.ts +6 -0
- package/dist/lib/getDepsTree.d.ts +1 -0
- package/dist/lib/getEntryPoints.d.ts +9 -0
- package/dist/lib/getMaxDepthInGraph.d.ts +4 -0
- package/dist/lib/resolve.d.ts +11 -0
- package/dist/lib/{find.js → resolve.js} +0 -0
- package/dist/lib/types.d.ts +10 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.js +7 -0
- package/package.json +19 -5
package/README.md
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
1
|
<h3 align="center">
|
|
2
|
-
<code>rev
|
|
2
|
+
<code>rev←dep</code>
|
|
3
3
|
</h3>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
|
-
|
|
6
|
+
Dependency debugging tool for JavaScript and TypeScript projects
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
11
|
<img alt="rev-dep version" src="https://img.shields.io/npm/v/rev-dep"> <img alt="rev-dep license" src="https://img.shields.io/npm/l/rev-dep"> <img alt="rev-dep PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square">
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## About
|
|
14
|
+
|
|
15
|
+
The tool was created help with daily dev struggles by answering these questions:
|
|
16
|
+
|
|
17
|
+
- What entry points my codebase have
|
|
18
|
+
- Which entry points uses a given file
|
|
19
|
+
- Which dependencies a given file has
|
|
20
|
+
|
|
21
|
+
This helps to debug project dependencies, plan refactoring, optimize bundles or plan code splitting.
|
|
22
|
+
|
|
23
|
+
It's especially useful in JS world without TypeScript or tests coverage.
|
|
24
|
+
|
|
25
|
+
It also helps to identify and eliminate dead files, understand the complexity of the file dependencies
|
|
26
|
+
|
|
27
|
+
[Jump to CLI reference](#cli-reference)
|
|
28
|
+
|
|
29
|
+
[`export * from` problem](#export-from-problem)
|
|
30
|
+
|
|
31
|
+
### Use cases
|
|
32
|
+
|
|
33
|
+
- [You plan to refactor some file and you wonder which entry points are affected](#how-to-identify-where-a-file-is-used-in-the-project)
|
|
34
|
+
|
|
35
|
+
- [You are wondering wether a given source file is used](#how-to-check-if-a-file-is-used-in-the-project)
|
|
36
|
+
- [You wonder if there are any dead files in your project](#how-to-identify-dead-files-in-the-project)
|
|
37
|
+
- [You want to verify if a given entry point imports only the required files](#how-to-check-which-files-are-imported-by-a-given-file)
|
|
38
|
+
- [You want to optimize the amount of files imported by an entry point](#how-to-reduce-amount-of-files-imported-by-entry-point)
|
|
39
|
+
|
|
40
|
+
### How about dependency or bundle graphs?
|
|
41
|
+
|
|
42
|
+
There are tool that can output nice, visual representation of project dependencies like [webpack-bundle-analyzer](https://www.npmjs.com/package/webpack-bundle-analyzer) or [dependency-cruiser](https://www.npmjs.com/package/dependency-cruiser) (_which btw rev-dep uses for non-TS codebases_)
|
|
43
|
+
|
|
44
|
+
While graphs can be useful to identify major problems like too big bundle size or to visualize mess in your deps, it's hard to take any action based on them (_at least it was hard for me_ 🤷♂️)
|
|
45
|
+
|
|
46
|
+
`rev-dep` visualize dependencies as lists, so it's really easy to see where to cut the line to solve the problem.
|
|
47
|
+
|
|
48
|
+
## Getting Started
|
|
14
49
|
|
|
15
50
|
### Install globally to use as CLI tool
|
|
16
51
|
|
|
@@ -28,88 +63,307 @@ or
|
|
|
28
63
|
|
|
29
64
|
`npm install rev-dep`
|
|
30
65
|
|
|
31
|
-
##
|
|
66
|
+
## Recipes
|
|
32
67
|
|
|
33
|
-
|
|
68
|
+
### How to identify where a file is used in the project?
|
|
69
|
+
|
|
70
|
+
Just use `rev-dep resolve path/to/file.ts`
|
|
71
|
+
|
|
72
|
+
You will see all the entry points that implicitly require given file together with resolution path.
|
|
73
|
+
|
|
74
|
+
[`resolve` Command CLI reference](#command-resolve)
|
|
75
|
+
|
|
76
|
+
<details>
|
|
77
|
+
<summary>Example for the rev-dep repository</summary>
|
|
78
|
+
|
|
79
|
+
command:
|
|
80
|
+
|
|
81
|
+
`rev-dep resolve src/lib/utils.ts`
|
|
82
|
+
|
|
83
|
+
output:
|
|
84
|
+
|
|
85
|
+
```s
|
|
86
|
+
src/babel/index.js :
|
|
87
|
+
|
|
88
|
+
➞ src/babel/index.js
|
|
89
|
+
➞ src/lib/utils.ts
|
|
90
|
+
_____________________
|
|
91
|
+
|
|
92
|
+
src/cli/index.ts :
|
|
93
|
+
|
|
94
|
+
➞ src/cli/index.ts
|
|
95
|
+
➞ src/cli/createCommands.ts
|
|
96
|
+
➞ src/cli/resolve/index.ts
|
|
97
|
+
➞ src/lib/find.ts
|
|
98
|
+
➞ src/lib/getDepsTree.ts
|
|
99
|
+
➞ src/lib/getDepsSetWebpack.ts
|
|
100
|
+
➞ src/lib/utils.ts
|
|
101
|
+
_____________________
|
|
34
102
|
|
|
35
|
-
```sh
|
|
36
|
-
rev-dep resolve getDepsSet.js cli.js
|
|
37
103
|
```
|
|
38
104
|
|
|
39
|
-
|
|
105
|
+
</details>
|
|
106
|
+
|
|
107
|
+
#### Getting more details about file resolution in given entry point
|
|
108
|
+
|
|
109
|
+
To find out all paths combination use `rev-dep resolve` with `-a` flag
|
|
110
|
+
|
|
111
|
+
> You might be surprised how complex dependency tree can be!
|
|
112
|
+
|
|
113
|
+
<details>
|
|
114
|
+
<summary>Example for the rev-dep repository</summary>
|
|
115
|
+
|
|
116
|
+
command:
|
|
117
|
+
|
|
118
|
+
`rev-dep resolve src/lib/utils.ts src/cli/index.ts --all`
|
|
119
|
+
|
|
120
|
+
output:
|
|
121
|
+
|
|
122
|
+
```s
|
|
123
|
+
src/cli/index.ts :
|
|
124
|
+
|
|
125
|
+
➞ src/cli/index.ts
|
|
126
|
+
➞ src/cli/createCommands.ts
|
|
127
|
+
➞ src/cli/resolve/index.ts
|
|
128
|
+
➞ src/lib/find.ts
|
|
129
|
+
➞ src/lib/getDepsTree.ts
|
|
130
|
+
➞ src/lib/getDepsSetWebpack.ts
|
|
131
|
+
➞ src/lib/utils.ts
|
|
132
|
+
|
|
133
|
+
➞ src/cli/index.ts
|
|
134
|
+
➞ src/cli/createCommands.ts
|
|
135
|
+
➞ src/cli/resolve/index.ts
|
|
136
|
+
➞ src/lib/find.ts
|
|
137
|
+
➞ src/lib/getEntryPoints.ts
|
|
138
|
+
➞ src/lib/getDepsTree.ts
|
|
139
|
+
➞ src/lib/getDepsSetWebpack.ts
|
|
140
|
+
➞ src/lib/utils.ts
|
|
141
|
+
|
|
142
|
+
➞ src/cli/index.ts
|
|
143
|
+
➞ src/cli/createCommands.ts
|
|
144
|
+
➞ src/cli/entryPoints/index.ts
|
|
145
|
+
➞ src/lib/getEntryPoints.ts
|
|
146
|
+
➞ src/lib/getDepsTree.ts
|
|
147
|
+
➞ src/lib/getDepsSetWebpack.ts
|
|
148
|
+
➞ src/lib/utils.ts
|
|
149
|
+
|
|
150
|
+
➞ src/cli/index.ts
|
|
151
|
+
➞ src/cli/createCommands.ts
|
|
152
|
+
➞ src/cli/files/index.ts
|
|
153
|
+
➞ src/lib/getDepsTree.ts
|
|
154
|
+
➞ src/lib/getDepsSetWebpack.ts
|
|
155
|
+
➞ src/lib/utils.ts
|
|
156
|
+
|
|
157
|
+
➞ src/cli/index.ts
|
|
158
|
+
➞ src/cli/createCommands.ts
|
|
159
|
+
➞ src/cli/resolve/index.ts
|
|
160
|
+
➞ src/lib/find.ts
|
|
161
|
+
➞ src/lib/getEntryPoints.ts
|
|
162
|
+
➞ src/lib/utils.ts
|
|
163
|
+
|
|
164
|
+
➞ src/cli/index.ts
|
|
165
|
+
➞ src/cli/createCommands.ts
|
|
166
|
+
➞ src/cli/entryPoints/index.ts
|
|
167
|
+
➞ src/lib/getEntryPoints.ts
|
|
168
|
+
➞ src/lib/utils.ts
|
|
169
|
+
|
|
170
|
+
➞ src/cli/index.ts
|
|
171
|
+
➞ src/cli/createCommands.ts
|
|
172
|
+
➞ src/cli/resolve/index.ts
|
|
173
|
+
➞ src/lib/find.ts
|
|
174
|
+
➞ src/lib/utils.ts
|
|
175
|
+
|
|
176
|
+
➞ src/cli/index.ts
|
|
177
|
+
➞ src/cli/createCommands.ts
|
|
178
|
+
➞ src/cli/resolve/index.ts
|
|
179
|
+
➞ src/lib/utils.ts
|
|
180
|
+
|
|
181
|
+
➞ src/cli/index.ts
|
|
182
|
+
➞ src/cli/createCommands.ts
|
|
183
|
+
➞ src/cli/entryPoints/index.ts
|
|
184
|
+
➞ src/lib/utils.ts
|
|
185
|
+
|
|
186
|
+
➞ src/cli/index.ts
|
|
187
|
+
➞ src/cli/createCommands.ts
|
|
188
|
+
➞ src/cli/files/index.ts
|
|
189
|
+
➞ src/lib/utils.ts
|
|
40
190
|
|
|
41
191
|
```
|
|
192
|
+
|
|
193
|
+
</details>
|
|
194
|
+
|
|
195
|
+
### How to check if a file is used in the project?
|
|
196
|
+
|
|
197
|
+
Use `rev-dep resolve path/to/file.ts --compactSummary`
|
|
198
|
+
|
|
199
|
+
As a result you will see total amount of entry points requiring a given file.
|
|
200
|
+
|
|
201
|
+
> Note that among the entry points list there might be some dead files importing the searched file
|
|
202
|
+
|
|
203
|
+
[`resolve` Command CLI reference](#command-resolve)
|
|
204
|
+
|
|
205
|
+
<details>
|
|
206
|
+
<summary>Example for the rev-dep repository</summary>
|
|
207
|
+
|
|
208
|
+
command:
|
|
209
|
+
|
|
210
|
+
`rev-dep resolve src/lib/utils.ts --compactSummary`
|
|
211
|
+
|
|
212
|
+
output:
|
|
213
|
+
|
|
214
|
+
```s
|
|
42
215
|
Results:
|
|
43
216
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
217
|
+
__tests__/find.test.js : 0
|
|
218
|
+
babel.js : 0
|
|
219
|
+
bin.js : 0
|
|
220
|
+
scripts/addDocsToReadme.js : 0
|
|
221
|
+
src/babel/index.js : 1
|
|
222
|
+
src/cli/index.ts : 1
|
|
223
|
+
src/lib/getMaxDepthInGraph.ts : 0
|
|
224
|
+
types.d.ts : 0
|
|
225
|
+
|
|
226
|
+
Total: 2
|
|
47
227
|
```
|
|
48
228
|
|
|
49
|
-
|
|
229
|
+
</details>
|
|
50
230
|
|
|
51
|
-
|
|
231
|
+
### How to identify dead files in the project?
|
|
52
232
|
|
|
53
|
-
|
|
233
|
+
Use `rev-dep entry-points` to get list of all files that are not required by any other files in the project.
|
|
54
234
|
|
|
55
|
-
|
|
235
|
+
You might want to exclude some file paths that are meant to be actual entry point like `index.js` or `**/pages/**` in `next.js` projects using `--exclude` flag. The same for configuration files like `babel.config.js`
|
|
56
236
|
|
|
57
|
-
|
|
237
|
+
Review the list and look for suspicious files like `src/ui/components/SomeComponent/index.js`
|
|
58
238
|
|
|
59
|
-
|
|
239
|
+
[`entry-points` command CLI reference](#command-entry-points)
|
|
60
240
|
|
|
61
|
-
|
|
241
|
+
<details>
|
|
242
|
+
<summary>Example for the rev-dep repository</summary>
|
|
62
243
|
|
|
63
|
-
|
|
244
|
+
command:
|
|
64
245
|
|
|
65
|
-
|
|
246
|
+
`rev-dep entry-points --exclude '__tests__/**' 'types.d.ts'`
|
|
66
247
|
|
|
67
|
-
|
|
248
|
+
output:
|
|
249
|
+
|
|
250
|
+
```s
|
|
251
|
+
babel.js
|
|
252
|
+
bin.js
|
|
253
|
+
scripts/addDocsToReadme.js
|
|
254
|
+
src/babel/index.js
|
|
255
|
+
src/cli/index.ts
|
|
256
|
+
src/lib/getMaxDepthInGraph.ts
|
|
68
257
|
|
|
69
|
-
```sh
|
|
70
|
-
rev-dep resolve <filePath> <entryPoints...>
|
|
71
258
|
```
|
|
72
259
|
|
|
73
|
-
|
|
260
|
+
The last one `src/lib/getMaxDepthInGraph.ts` is the source file that is not used at the moment.
|
|
261
|
+
|
|
262
|
+
The rest of them looks legit!
|
|
263
|
+
|
|
264
|
+
</details>
|
|
265
|
+
|
|
266
|
+
### How to check which files are imported by a given file?
|
|
267
|
+
|
|
268
|
+
To get a full list of files imported by given entry point use `rev-dep files path/to/file.ts`.
|
|
269
|
+
|
|
270
|
+
You can use `--count` flag if you are interested in the amount.
|
|
271
|
+
|
|
272
|
+
This is a good indicator of how heavy a given entry point or component is
|
|
273
|
+
|
|
274
|
+
[`files` command CLI reference](#command-files)
|
|
74
275
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
276
|
+
<details>
|
|
277
|
+
<summary>Example for the rev-dep repository</summary>
|
|
278
|
+
|
|
279
|
+
command:
|
|
280
|
+
|
|
281
|
+
`rev-dep files files src/cli/index.ts`
|
|
282
|
+
|
|
283
|
+
output:
|
|
284
|
+
|
|
285
|
+
```s
|
|
286
|
+
src/cli/index.ts
|
|
287
|
+
src/cli/createCommands.ts
|
|
288
|
+
package.json
|
|
289
|
+
src/cli/resolve/index.ts
|
|
290
|
+
src/cli/docs/index.ts
|
|
291
|
+
src/cli/entryPoints/index.ts
|
|
292
|
+
src/cli/files/index.ts
|
|
293
|
+
src/lib/find.ts
|
|
294
|
+
src/cli/resolve/types.ts
|
|
295
|
+
src/cli/resolve/formatResults.ts
|
|
296
|
+
src/lib/utils.ts
|
|
297
|
+
src/cli/commonOptions.ts
|
|
298
|
+
src/cli/docs/generate.ts
|
|
299
|
+
src/cli/entryPoints/types.ts
|
|
300
|
+
src/lib/getEntryPoints.ts
|
|
301
|
+
src/lib/buildDepsGraph.ts
|
|
302
|
+
src/cli/files/types.ts
|
|
303
|
+
src/lib/getDepsTree.ts
|
|
304
|
+
src/lib/types.ts
|
|
305
|
+
src/cli/docs/template.ts
|
|
306
|
+
src/lib/getDepsSetWebpack.ts
|
|
307
|
+
src/lib/cleanupDpdmDeps.ts
|
|
308
|
+
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
As you can see cli even import `package.json`. This is to print version of the cli
|
|
312
|
+
|
|
313
|
+
</details>
|
|
314
|
+
|
|
315
|
+
### How to reduce amount of files imported by entry point?
|
|
316
|
+
|
|
317
|
+
There is no easy how to for this process, but you can do it iteratively using two of the `rev-dep` commands:
|
|
318
|
+
|
|
319
|
+
- `files`
|
|
320
|
+
- `resolve`
|
|
321
|
+
|
|
322
|
+
1. Get the list of files imported by entry-point
|
|
323
|
+
|
|
324
|
+
- `rev-dep files path/to/entry-point`
|
|
325
|
+
|
|
326
|
+
2. Identify some suspicious files on the list, components that should not be used on the given page or not related utility files
|
|
327
|
+
3. Get all resolution paths for a suspicious file
|
|
328
|
+
|
|
329
|
+
- `rev-dep resolve path/to/suspicious-file path/to/entry-point --all`
|
|
330
|
+
|
|
331
|
+
4. You would usually find out that there is some file, like directory `index` file that given entry point is using, which is mandatory, but as a side effect it imports a few files that are redundant for your entry point. In most cases you should be able to decouple the imports or reverse the dependency to cut off the resolution path for the unwanted file
|
|
332
|
+
|
|
333
|
+
## Usage
|
|
334
|
+
|
|
335
|
+
Project can be used as a CLI tool or as a module
|
|
336
|
+
|
|
337
|
+
### CLI Tool
|
|
338
|
+
|
|
339
|
+
For CLI usage see [CLI reference](#cli-reference)
|
|
78
340
|
|
|
79
341
|
### Module
|
|
80
342
|
|
|
81
|
-
#### `
|
|
343
|
+
#### `resolve` Function
|
|
82
344
|
|
|
83
|
-
```
|
|
84
|
-
import {
|
|
345
|
+
```ts
|
|
346
|
+
import { resolve } from "rev-dep";
|
|
85
347
|
|
|
86
|
-
const
|
|
348
|
+
const [paths] = await resolve({
|
|
87
349
|
entryPoints: ["index.js"],
|
|
88
350
|
filePath: "utils.js",
|
|
89
351
|
});
|
|
90
352
|
|
|
91
|
-
console.log(
|
|
353
|
+
console.log(paths);
|
|
92
354
|
```
|
|
93
355
|
|
|
94
|
-
#### `
|
|
95
|
-
|
|
96
|
-
- `entryPoints (Array)` - Array of entry points to build a tree for search. Usually it will be one entry point, but project can have many of them, eg. next.js application. **Required**
|
|
97
|
-
- `filePath (String)` - A file that we want to find path for. **Required**
|
|
98
|
-
- `skipRegex (String | RegExp)` - If a file path matches the pattern, we stop to traverse it's dependencies and do not include that file in the search tree. _Optional_, default: `'(node_modules|/__tests__|/__test__|/__mockContent__|.scss)'`
|
|
99
|
-
- `verbose (Boolean)` - when set to true, will print current operation performed by find function. _Optional_, default: `false`
|
|
100
|
-
- `cwd` - root for resolved files, must be an absolute path. _Optional_, default: `process.cwd()`
|
|
101
|
-
- `webpackConfig (String)` - path to webpack config to enable webpack aliases support
|
|
356
|
+
#### `getEntryPoints` Function
|
|
102
357
|
|
|
103
|
-
|
|
358
|
+
```ts
|
|
359
|
+
import { getEntryPoints } from "rev-dep";
|
|
104
360
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
In order to resolve implicit extensions for other JS based languages it look for available corresponding compiler in `package.json`. If compiler is available, then extension is supported.
|
|
109
|
-
|
|
110
|
-
If you installed `rev-dep` **globally**, you will have appropriate compiler installed **globally** as well. If you use it as a module, your project has to have compiler in it's package.json.
|
|
361
|
+
const [entryPoints] = await getEntryPoints({
|
|
362
|
+
cwd: process.cwd(),
|
|
363
|
+
});
|
|
111
364
|
|
|
112
|
-
|
|
365
|
+
console.log(entryPoints);
|
|
366
|
+
```
|
|
113
367
|
|
|
114
368
|
## CLI reference
|
|
115
369
|
|
|
@@ -196,6 +450,57 @@ rev-dep docs <outputPath> [options]
|
|
|
196
450
|
- `-hl, --headerLevel <value>` - Initial header level (_optional_)
|
|
197
451
|
<!-- cli-docs-end -->
|
|
198
452
|
|
|
453
|
+
## Export from problem
|
|
454
|
+
|
|
455
|
+
`rev-dep` attempts to also solve `export * from` by a babel plugin that can be used as follows
|
|
456
|
+
|
|
457
|
+
```js
|
|
458
|
+
// babel.config.js
|
|
459
|
+
module.exports = {
|
|
460
|
+
plugins: ["rev-dep/babel"],
|
|
461
|
+
};
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
The plugins is currently **experimental** and might not work for all codebases!
|
|
465
|
+
|
|
466
|
+
It helps by rewiring paths to re-exported modules
|
|
467
|
+
|
|
468
|
+
```ts
|
|
469
|
+
// file.ts
|
|
470
|
+
import { add } from "./utils";
|
|
471
|
+
|
|
472
|
+
// utils/index.ts
|
|
473
|
+
|
|
474
|
+
export * from "./math";
|
|
475
|
+
export * from "./otherModule";
|
|
476
|
+
export * from "./anotherModule";
|
|
477
|
+
|
|
478
|
+
// utils/math.ts
|
|
479
|
+
|
|
480
|
+
export const add = () => {};
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
And for `file.ts` it would rewire the import like this
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
// file.ts
|
|
487
|
+
import { add } from "./utils/math";
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
So as a result, we don't implicitly require `./otherModule` and `./anotherModule` which we will not use anyway
|
|
491
|
+
|
|
492
|
+
### Benefits
|
|
493
|
+
|
|
494
|
+
I don't have solid evidence for this, but I think it reduced RAM usage of the dev server I worked with (_blitz.js_). It crashed less often due to reaching heap size limit.
|
|
495
|
+
|
|
496
|
+
But for sure it reduced bundle size, _slightly_, but still 😀
|
|
497
|
+
|
|
498
|
+
It all depends on the the project dependencies structure.
|
|
499
|
+
|
|
500
|
+
By using the babel plugin you will reduce a risk of problems like implicitly importing `front-end` modules on the `server` or similar while still being able to benefit from short import paths.
|
|
501
|
+
|
|
502
|
+
Once I got an incident that, after a rebase with main branch, my project stopped compiling due to the problem caused by `export * from`. I spend a few hours debugging that, very frustrating.
|
|
503
|
+
|
|
199
504
|
## Contributing
|
|
200
505
|
|
|
201
506
|
Project is open to contributions, just rise an issue if you have some ideas about features or you noticed a bug. After discussion we can approach implementation :)
|
|
@@ -204,16 +509,20 @@ Project is open to contributions, just rise an issue if you have some ideas abou
|
|
|
204
509
|
|
|
205
510
|
1. Clone repo
|
|
206
511
|
2. Install deps using `yarn`
|
|
207
|
-
3. Run
|
|
512
|
+
3. Run `yarn build:watch`
|
|
208
513
|
4. Code!
|
|
209
514
|
|
|
210
|
-
For testing purpose
|
|
515
|
+
For testing purpose use
|
|
516
|
+
|
|
517
|
+
`yarn dev [command] --cwd path/to/some/codebase`
|
|
518
|
+
|
|
519
|
+
or you can install CLI tool from the file system using
|
|
211
520
|
|
|
212
|
-
`yarn global add
|
|
521
|
+
`yarn global add $PWD`
|
|
213
522
|
|
|
214
|
-
|
|
523
|
+
and then just run
|
|
215
524
|
|
|
216
|
-
`
|
|
525
|
+
`rev-dep`
|
|
217
526
|
|
|
218
527
|
## Made with 🧠 by [@jayu](https://github.com/jayu)
|
|
219
528
|
|
package/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('./dist/cli')
|
|
2
|
+
require('./dist/cli')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare type OptionMeta2 = [string, string];
|
|
2
|
+
declare type OptionMeta3 = [string, string, string];
|
|
3
|
+
export declare const webpackConfigOption: OptionMeta2;
|
|
4
|
+
export declare type WebpackConfigOptionType = {
|
|
5
|
+
webpackConfig?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const cwdOption: OptionMeta3;
|
|
8
|
+
export declare type CwdOptionType = {
|
|
9
|
+
cwd: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const reexportRewireOption: OptionMeta2;
|
|
12
|
+
export declare type ReexportRewireOptionType = {
|
|
13
|
+
reexportRewire?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const includeOption: OptionMeta2;
|
|
16
|
+
export declare type IncludeOptionType = {
|
|
17
|
+
include?: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare const excludeOption: OptionMeta2;
|
|
20
|
+
export declare type ExcludeOptionType = {
|
|
21
|
+
exclude?: string[];
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare type Command = {
|
|
2
|
+
name: string;
|
|
3
|
+
arguments: {
|
|
4
|
+
nameRaw: string;
|
|
5
|
+
name: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
description?: string;
|
|
8
|
+
}[];
|
|
9
|
+
description?: string;
|
|
10
|
+
options: {
|
|
11
|
+
shortName: string;
|
|
12
|
+
longName?: string;
|
|
13
|
+
argument?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
declare function generate(output: string, initialHeaderLevel: number): void;
|
|
20
|
+
export default generate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InputParams } from './types';
|
|
2
|
+
declare type Results = Array<Array<Array<string>>>;
|
|
3
|
+
export declare function formatResults({ results, filePath, entryPoints, compactSummary }: {
|
|
4
|
+
results: Results;
|
|
5
|
+
compactSummary: InputParams['compactSummary'];
|
|
6
|
+
entryPoints: string[];
|
|
7
|
+
filePath: string;
|
|
8
|
+
}): string;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const resolve_1 = require("../../lib/resolve");
|
|
4
4
|
const formatResults_1 = require("./formatResults");
|
|
5
5
|
const utils_1 = require("../../lib/utils");
|
|
6
6
|
const commonOptions_1 = require("../commonOptions");
|
|
@@ -20,7 +20,7 @@ function createResolve(program) {
|
|
|
20
20
|
.option('-a, --all', 'finds all paths combination of a given dependency. Might work very slow or crash for some projects due to heavy usage of RAM', false)
|
|
21
21
|
.action(async (filePath, entryPoints, data) => {
|
|
22
22
|
const { compactSummary, webpackConfig, all, cwd, exclude, include } = data;
|
|
23
|
-
const [results, resolveEntryPoints] = await (0,
|
|
23
|
+
const [results, resolveEntryPoints] = await (0, resolve_1.resolve)({
|
|
24
24
|
entryPoints,
|
|
25
25
|
filePath,
|
|
26
26
|
webpackConfig,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string): Promise<import("./types").MinimalDependencyTree>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MinimalDependencyTree } from './types';
|
|
2
|
+
export declare const getDirectoriesForEntryPointsSearch: (dir: string) => Promise<string[]>;
|
|
3
|
+
export declare const findEntryPointsInDepsTree: (deps: MinimalDependencyTree, exclude?: string[], include?: string[] | undefined) => string[];
|
|
4
|
+
export declare const getEntryPoints: ({ cwd, exclude, include, webpackConfigPath }: {
|
|
5
|
+
cwd: string;
|
|
6
|
+
exclude?: string[] | undefined;
|
|
7
|
+
include?: string[] | undefined;
|
|
8
|
+
webpackConfigPath?: string | undefined;
|
|
9
|
+
}) => Promise<[string[], MinimalDependencyTree]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare type ResolveParams = {
|
|
2
|
+
entryPoints: string[];
|
|
3
|
+
filePath: string;
|
|
4
|
+
webpackConfig?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
all: boolean;
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
include?: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare const resolve: ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd, all, include, exclude }: ResolveParams) => Promise<[string[][][], string[]]>;
|
|
11
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dependency } from 'dpdm';
|
|
2
|
+
export declare type Node = {
|
|
3
|
+
path: string;
|
|
4
|
+
children: Node[];
|
|
5
|
+
parents: Node[];
|
|
6
|
+
};
|
|
7
|
+
export declare type MinimalDependency = Pick<Dependency, 'id' | 'request'>;
|
|
8
|
+
export declare type MinimalDependencyTree = {
|
|
9
|
+
[key: string]: readonly MinimalDependency[] | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const removeInitialDot: (path: string) => string;
|
|
2
|
+
export declare const createResolveAbsolutePath: (cwd: string) => (p: string | undefined) => string | undefined;
|
|
3
|
+
export declare const asyncFilter: <T>(arr: T[], predicate: (el: T) => Promise<boolean>) => Promise<T[]>;
|
|
4
|
+
export declare const sanitizeUserEntryPoints: (entryPoints: string[]) => string[];
|
|
5
|
+
export declare const resolvePath: <P extends string | undefined>(p: P) => string | P;
|
|
6
|
+
export declare const findTsConfig: (cwd?: string) => string | undefined;
|
package/dist/module.d.ts
ADDED
package/dist/module.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEntryPoints = exports.resolve = void 0;
|
|
4
|
+
var resolve_1 = require("./lib/resolve");
|
|
5
|
+
Object.defineProperty(exports, "resolve", { enumerable: true, get: function () { return resolve_1.resolve; } });
|
|
6
|
+
var getEntryPoints_1 = require("./lib/getEntryPoints");
|
|
7
|
+
Object.defineProperty(exports, "getEntryPoints", { enumerable: true, get: function () { return getEntryPoints_1.getEntryPoints; } });
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rev-dep",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
|
+
"description": "Dependency debugging tool for JavaScript and TypeScript projects",
|
|
5
|
+
"main": "dist/module.js",
|
|
6
6
|
"bin": "bin.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/**",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"node": ">=10"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
+
"checks": "yarn lint && yarn typecheck",
|
|
24
25
|
"lint": "eslint --ext .js,.ts src",
|
|
25
26
|
"lint:fix": "yarn lint --fix",
|
|
26
27
|
"docs-gen": "node ./scripts/addDocsToReadme.js",
|
|
27
28
|
"dev": "node bin",
|
|
28
29
|
"test": "jest",
|
|
29
30
|
"release": "release-it",
|
|
30
|
-
"build": "tsc",
|
|
31
|
+
"build": "tsc --declaration",
|
|
31
32
|
"build:watch": "tsc --watch",
|
|
32
33
|
"typecheck": "tsc --noEmit"
|
|
33
34
|
},
|
|
@@ -59,5 +60,18 @@
|
|
|
59
60
|
"prettier": "^2.1.2",
|
|
60
61
|
"release-it": "^14.2.1",
|
|
61
62
|
"typescript": "^4.6.2"
|
|
62
|
-
}
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"dependencies",
|
|
66
|
+
"deps",
|
|
67
|
+
"dependency graph",
|
|
68
|
+
"dependency debugging",
|
|
69
|
+
"entry points",
|
|
70
|
+
"dependency resolution",
|
|
71
|
+
"reverse dependency resolution",
|
|
72
|
+
"dependency tree",
|
|
73
|
+
"import path",
|
|
74
|
+
"resolution path",
|
|
75
|
+
"dependency optimization"
|
|
76
|
+
]
|
|
63
77
|
}
|