esm-imports-analyzer 0.1.0 → 0.1.2
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/LICENSE +21 -0
- package/README.md +14 -14
- package/dist/cli.js +0 -0
- package/package.json +11 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Patricio Palladino
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A CLI tool that captures all ESM imports during a Node.js application's executio
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
[Live demo](
|
|
7
|
+
[Live demo](https://patriciopalladino.com/esm-imports-analyzer/)
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -58,23 +58,23 @@ The generated report is a single HTML file with:
|
|
|
58
58
|
|
|
59
59
|
### Graph interactions
|
|
60
60
|
|
|
61
|
-
| Action
|
|
62
|
-
|
|
63
|
-
| Click a node
|
|
64
|
-
| Shift-click
|
|
65
|
-
| Double-click a package
|
|
66
|
-
| Double-click a folder
|
|
67
|
-
| Double-click a module
|
|
68
|
-
| Double-click empty space | Zoom to fit the entire graph.
|
|
69
|
-
| Right-click any node
|
|
70
|
-
| Hover a module
|
|
61
|
+
| Action | Effect |
|
|
62
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------- |
|
|
63
|
+
| Click a node | Select it. Highlights outgoing imports (blue), incoming importers (green), and cycle edges (yellow). Everything else dims. |
|
|
64
|
+
| Shift-click | Toggle a node in/out of the selection without affecting other selected nodes. |
|
|
65
|
+
| Double-click a package | Expand or collapse it. |
|
|
66
|
+
| Double-click a folder | Expand it (show its children inside the package). |
|
|
67
|
+
| Double-click a module | Zoom into it. |
|
|
68
|
+
| Double-click empty space | Zoom to fit the entire graph. |
|
|
69
|
+
| Right-click any node | Context menu: expand importer/imported files, copy absolute path, copy full import chain from root. |
|
|
70
|
+
| Hover a module | Tooltip with full path and import time. |
|
|
71
71
|
|
|
72
72
|
### Other UI elements
|
|
73
73
|
|
|
74
74
|
- **Cycles panel** (left sidebar) — lists all circular dependencies. Click one to reveal and highlight its members with orange.
|
|
75
75
|
- **Table** (bottom, resizable) — shows the slowest modules. Click a row to focus on it in the graph. Sortable by import time, import count, or name.
|
|
76
76
|
- **Expand all / Collapse all** — buttons in the header.
|
|
77
|
-
- **Auto re-layout** — checkbox (default: on). When enabled, the graph layout recomputes automatically after every expand/collapse. Disable it to manually control when layout runs via the Re-layout button.
|
|
77
|
+
- **Auto re-layout** — checkbox (default: on). When enabled, the graph layout recomputes automatically after every expand/collapse. Disable it to manually control when layout runs via the Re-layout button. Useful for very large graphs where automatic layout can be slow.
|
|
78
78
|
|
|
79
79
|
## How it works
|
|
80
80
|
|
|
@@ -84,11 +84,11 @@ The generated report is a single HTML file with:
|
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
// Your module's source
|
|
87
|
-
import { foo } from
|
|
87
|
+
import { foo } from "./bar.js";
|
|
88
88
|
doSomething();
|
|
89
89
|
|
|
90
90
|
// Injected at the end:
|
|
91
|
-
|
|
91
|
+
globalThis.__esm_analyzer_import_done__("<module-url>");
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
3. When the module finishes evaluating — after all its static dependencies have been resolved, loaded, and evaluated, and its own top-level code has run — the injected callback fires and records the elapsed time since the resolve hook started. This gives the **total import time**: the full wall-clock cost of importing that module, including everything it triggers.
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esm-imports-analyzer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A tool to generate an HTML visualization of the imports of an ESM Node.js application. It executes the application, tracks the imports during runtime, and creates the visualization after the execution is complete.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
"optimization"
|
|
11
11
|
],
|
|
12
12
|
"author": "Patricio Palladino <email@patriciopalladino.com>",
|
|
13
|
+
"repository": "github:alcuadrado/esm-imports-analyzer",
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"type": "module",
|
|
16
|
+
"packageManager": "pnpm@10.33.0",
|
|
15
17
|
"bin": {
|
|
16
18
|
"esm-imports-analyzer": "dist/cli.js"
|
|
17
19
|
},
|
|
@@ -19,15 +21,17 @@
|
|
|
19
21
|
"files": [
|
|
20
22
|
"dist"
|
|
21
23
|
],
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@types/node": "^25.5.0",
|
|
24
|
-
"typescript": "^6.0.2"
|
|
25
|
-
},
|
|
26
24
|
"scripts": {
|
|
27
25
|
"typecheck": "tsc --noEmit",
|
|
28
26
|
"build": "rm -rf dist && tsc && cp -r src/report/ui dist/report/ui && cp src/report/template.html dist/report/template.html",
|
|
27
|
+
"pretest": "bash scripts/pretest.sh",
|
|
29
28
|
"test": "node --test test/**/*.test.ts",
|
|
30
29
|
"test:unit": "node --test test/unit/**/*.test.ts",
|
|
31
|
-
"test:integration": "node --test test/integration/**/*.test.ts"
|
|
30
|
+
"test:integration": "node --test test/integration/**/*.test.ts",
|
|
31
|
+
"prepublishOnly": "npm run typecheck && npm run build"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.5.0",
|
|
35
|
+
"typescript": "^6.0.2"
|
|
32
36
|
}
|
|
33
|
-
}
|
|
37
|
+
}
|