Skip to content

Deeply propagate imported names#9

Closed
nicolo-ribaudo wants to merge 1 commit intomainfrom
implicit-defer-propagation
Closed

Deeply propagate imported names#9
nicolo-ribaudo wants to merge 1 commit intomainfrom
implicit-defer-propagation

Conversation

@nicolo-ribaudo
Copy link
Member

Marking as draft because this is quite handwavy and probably not fully correct (also, it does not support Evaluation or export { a as b } from).

It shows roughly what we would need to do for #5 (comment).

I actually don't think I like this approach. It introduces complexity both for engines and for developers reading code, because instead of looking at the files you are importing to figure out what's being filtered due to your import you need to look at their whole subtree.

Consider a cases like this:

flowchart TD
    A -->|"import { x } from"| B
    B -->|"export { x, y } from"| C
    C -->|"export { x, y } from"| D
    D -->|"export defer { x } from"| E
    D -->|"export defer { y } from"| F
    G -->|"import { y } from"| B
Loading

Assume that A is already loaded. Today, when loading G, G will try loading its dependency, which gets resolved to an already loaded module B, and it has nothing else to do.

If we do this change, when loading F and finding its dependency B we would need to check:

  • has anybody else already loaded the y specifier?
  • no: let's go to C. Has anybody else already loaded its y specifier?
  • no: let's go to D. Has anybody else already loaded its y specifier?
  • no: let's load G

Both for developers and engines it's good that these steps only happen when explicit: when they can look at C's source and see that there is a defer marker that means "actually, here you need to do recursion". Given that since ES6 export { ... } from doesn't need this extra recursion when importing already loaded modules, I don't think we should add it now.

@nicolo-ribaudo
Copy link
Member Author

Replaced by #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant