You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-6Lines changed: 29 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -27,12 +27,39 @@ There is an **edge** from `v1` to `v2` if:
27
27
2.`v2` is imported from another module as `v1`
28
28
3.`v1` exports or re-exports `v2`
29
29
30
-
### Expanding Wildcard Imports and Re-Exports
30
+
### Expanding Wildcard Re-Exports
31
31
32
-
Expanding wildcard import and re-export statements simplifies parallel module parsing. Without expansion, any module containing such a statement would need to be parsed first, creating a bottleneck. Additionally, it's common in JavaScript projects to have numerous index.js files dedicated to re-exports, making this approach even more important for efficient processing.
32
+
```js
33
+
// assume a module named exports 'Foo', 'Bar'
34
+
// then this wildcard re-export statement gets turned into
35
+
// export { Foo, Bar } from 'a'
36
+
export*from"a";
37
+
```
38
+
39
+
Expanding wildcard re-export statements simplifies parallel module parsing. Without expansion, any module containing such a statement would need to be parsed first, creating a bottleneck. Additionally, it's common in JavaScript projects to have numerous index.js files dedicated to re-exports, making this approach even more important for efficient processing.
40
+
41
+
### Duplicating Local Variable Symbols for Exports or Default Exports
42
+
43
+
```js
44
+
// one named export symbol + one local variable symbol named "A"
45
+
exportconstA="A";
46
+
47
+
// one default export symbol + one local variable symbol named "B"
48
+
exportdefaultB="B";
49
+
```
50
+
51
+
Duplicating local variable symbols when they are exported or re-exported as default will increase the size of the serialized output, but it avoids introducing new edge rules. This is another trade-off to consider.
33
52
34
53
### Creating a Local Variable Symbol for Anonymous Default Exports
35
54
55
+
```js
56
+
// one default export symbol + one anonymous local variable symbol
57
+
exportdefault () => {}
58
+
exportdefaultfunction () {}
59
+
exportdefaultfunction* () {}
60
+
exportdefaultclass {}
61
+
```
62
+
36
63
This decision involves a trade-off: either introduce a new rule for edges or create a local variable symbol with a unique, impossible-to-collide name for the anonymous default export.
37
64
38
65
### Depending on Namespace Imports Means Depending on All Named Exports
@@ -48,10 +75,6 @@ function B() {
48
75
49
76
This presents a trade-off: either create a more fine-grained dependency graph or keep it simpler for now.
50
77
51
-
### Duplicating Local Variable Symbols for Exports or Default Exports
52
-
53
-
Duplicating local variable symbols when they are exported or re-exported as default will increase the size of the serialized output, but it avoids introducing new edge rules. This is another trade-off to consider.
54
-
55
78
## Problem Overview
56
79
57
80
Imagine an application with two routes: `/home` and `/account`.
0 commit comments