Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation to weak import proposal #8

Open
guybedford opened this issue Jan 30, 2021 · 3 comments
Open

Relation to weak import proposal #8

guybedford opened this issue Jan 30, 2021 · 3 comments

Comments

@guybedford
Copy link
Collaborator

@LeaVerou posted a related proposal in https://lea.verou.me/2020/11/the-case-for-weak-dependencies-in-js/.

It would likely be worthwhile to include a comparison to this proposal.

My own intuition would be that they are very much the same sort of thing - in that the imported bindings are bound to the unexecuted module but the module itself has just not executed yet. The tradeoff to consider between both proposals is then just when and how to do the actual execution given we have this import mode / attribute.

In the context of optional dependencies, the concept comes up that another module in the graph that happens to execute the optional dependency will define it for all the other importers. This then entirely moves the execution timing problem back away from the engine to the user API side which might offer more control - would be very useful to compare these execution models.

@bmeck
Copy link
Member

bmeck commented Jan 31, 2021

@guybedford this would still perform linkage as it is currently proposed. From what I can tell from that blog post it only checks if a module is already present not that it should try to load the module. So it seems like "weak dependencies" are a detection mechanism based on existing caches and not intended to populate the cache like this proposal intends.

@bmeck
Copy link
Member

bmeck commented Jan 31, 2021

Forgot to add that "weak dependencies" seem to be more in https://github.com/tc39/proposal-compartments 's importNow hook space.

@guybedford
Copy link
Collaborator Author

Yes something like an importNow function doing the population versus population on binding access sounds like the main difference.

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

No branches or pull requests

3 participants