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

Add Module Loader runtime objects #1472

Closed

Conversation

boingoing
Copy link
Contributor

Based on the W3C Module Loader spec:
https://whatwg.github.io/loader

Includes more or less complete implementations of the runtime objects:
%Registry%
%RegistryPrototype%
%Loader%
%LoaderPrototype%
%ModuleStatus%
%ModuleStatusPrototype%

Includes a stub implementation of %Module%.

Most of the abstract operations in the spec are implemented completely but
we are missing some key ones such as SatisfyInstance. The next step will
be to merge the existing ModuleRecord implementation with the ModuleStatus
object and set of abstract operations.

In particular, this pull request does not plug-in any of the dependency
graph resolution or export name resolution because a refactor of existing
ModuleRecord code is required.

There are some open issues with the code in this change. For example, it's
not clear from the spec what we should do if transforming a promise object
with a fulfillment handler returns a non-promise object. It seems possible
that user code could replace the constructor property on the promise
instance which could cause the transformed promise to be anything. Should
we throw here? Should we just wrap whatever the object is in a resolved
promise? It's not clear. Most of the machinery in the spec requires
promise objects so I have taken the approach that we should throw anytime
an object is not a promise when we expect it should be.

Based on the W3C Module Loader spec:
https://whatwg.github.io/loader

Includes more or less complete implementations of the runtime objects:
%Registry%
%RegistryPrototype%
%Loader%
%LoaderPrototype%
%ModuleStatus%
%ModuleStatusPrototype%

Includes a stub implementation of %Module%.

Most of the abstract operations in the spec are implemented completely but
we are missing some key ones such as SatisfyInstance. The next step will
be to merge the existing ModuleRecord implementation with the ModuleStatus
object and set of abstract operations.

In particular, this pull request does not plug-in any of the dependency
graph resolution or export name resolution because a refactor of existing
ModuleRecord code is required.

There are some open issues with the code in this change. For example, it's
not clear from the spec what we should do if transforming a promise object
with a fulfillment handler returns a non-promise object. It seems possible
that user code could replace the constructor property on the promise
instance which could cause the transformed promise to be anything. Should
we throw here? Should we just wrap whatever the object is in a resolved
promise? It's not clear. Most of the machinery in the spec requires
promise objects so I have taken the approach that we should throw anytime
an object is not a promise when we expect it should be.
@boingoing
Copy link
Contributor Author

@Yongqu Please take a look over this one, thanks! 😀

BUILTIN(JavascriptLoader, GetterRegistry, EntryGetterRegistry, FunctionInfo::ErrorOnNew)
BUILTIN(JavascriptLoader, EnsureRegisteredAndEvaluatedFulfillmentHandler, EntryEnsureRegisteredAndEvaluatedFulfillmentHandler, FunctionInfo::ErrorOnNew | FunctionInfo::DoNotProfile)
BUILTIN(JavascriptLoader, EnsureRegisteredFulfillmentHandler, EntryEnsureRegisteredFulfillmentHandler, FunctionInfo::ErrorOnNew | FunctionInfo::DoNotProfile)
BUILTIN(JavascriptLoader, EnsureEvaluatedFulfillmentHandler, EntryEnsureEvaluatedFulfillmentHandler, FunctionInfo::ErrorOnNew | FunctionInfo::DoNotProfile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this an official builtin?

@Yongqu
Copy link
Contributor

Yongqu commented Sep 6, 2016

:shipit:

@dilijev
Copy link
Contributor

dilijev commented Feb 22, 2017

Followed up with @boingoing offline. Seems some design change might render this PR obsolete but salvageable. Adding Waiting label.

@boingoing
Copy link
Contributor Author

Closing this for now, it doesn't appear that we will be implementing this in the near future.

@boingoing boingoing closed this Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants