Skip to content

Commit

Permalink
docs: add examples for design decisions
Browse files Browse the repository at this point in the history
  • Loading branch information
wtlin1228 committed Oct 14, 2024
1 parent 6d93148 commit cdecac9
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,39 @@ There is an **edge** from `v1` to `v2` if:
2. `v2` is imported from another module as `v1`
3. `v1` exports or re-exports `v2`

### Expanding Wildcard Imports and Re-Exports
### Expanding Wildcard Re-Exports

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.
```js
// assume a module named exports 'Foo', 'Bar'
// then this wildcard re-export statement gets turned into
// export { Foo, Bar } from 'a'
export * from "a";
```

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.

### Duplicating Local Variable Symbols for Exports or Default Exports

```js
// one named export symbol + one local variable symbol named "A"
export const A = "A";

// one default export symbol + one local variable symbol named "B"
export default B = "B";
```

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.

### Creating a Local Variable Symbol for Anonymous Default Exports

```js
// one default export symbol + one anonymous local variable symbol
export default () => {}
export default function () {}
export default function* () {}
export default class {}
```

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.

### Depending on Namespace Imports Means Depending on All Named Exports
Expand All @@ -48,10 +75,6 @@ function B() {

This presents a trade-off: either create a more fine-grained dependency graph or keep it simpler for now.

### Duplicating Local Variable Symbols for Exports or Default Exports

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.

## Problem Overview

Imagine an application with two routes: `/home` and `/account`.
Expand Down

0 comments on commit cdecac9

Please sign in to comment.