Skip to content

Implementation feedback #24

@guybedford

Description

@guybedford

I've got a working implementation at https://github.com/ModuleLoader/es6-module-loader/blob/1.0/src/loader.js (PR ModuleLoader/es-module-loader#317).

Here are some notes of the minor corrections from the process:

  • 4.1.5 1 Instantiation must be called with a loader argument.
  • 4.1.5 1 instance is both an argument and a local variable.
  • 4.1.5 4 Resolve entry.[[Instantiate]] with instance. We're resolving the promise from outside of the scope of the promise which practically, means storing the instantiateResolve function on the entry. It can be easier to move this out to a return entry.module in 4.2.3 at the instantiate promise return and a Promise.resolve in the last line of 4.1.4.
  • 4.1.5 6 b For each dep in instance.[[ImportedModules]] is this a ReflectiveModuleRecord property? I couldn't see it defined anywhere.
  • 4.2.1 6 use payload instead of v for consistency?
  • 4.2.3 5 Should RequestTranslate directly, don't need RequestFetch as it is implicit in RequestTranslate
  • 4.2.3 Let p1 be the result of promise-calling hook(key, payload, source)
    Surely we just need source and not payload?
  • 4.2.4 entry intead of entry0
  • 4.2.4 Resolve is not defined anywhere? loader.[[resolve]]?
  • 4.2.4 Before running RequestInstantiate for dependencies, we need to do the check:
    _depEntry_ = ensureRegistered(loader, depKey, metadata); if _depEntry_.[[state]] is "ready" then use _depEntry_ for _dep_
    Otherwise requestInstantiate throws if the module is already defined
  • 4.2.5 module.Evaluate is not defined?
    Resolve is not defined?
  • 5.2.1 Let status be module.Instantiate(). I'm wondering about using the module object as both the execute function and the module instance?
  • 6.3.1 To confirm - if stage is fetch or translate, it never proceeds to next stage?
  • 6.4.2 Not sure how loader.prototype.error is to be implemented.
  • 6.5.2 Should probably set error property to null for installed entry.
  • 6.5.3 Reflect.loader.uninstall(key) not Reflect.loader.uninstall(module)

I also implemented the metadata piping. Having metadata available as soon as the resolve hook runs would really be the ideal here, but does mean that the first resolution takes precedence, which I know may not be ideal for the spec process.

To describe the implementation (for what its worth):

  • We add a third metadata argument to resolve, and pass it through to the request* calls
  • 4.1.1 Added metadata last argument to ensureRegistered. If already existing, it ignores, otherwise it sets on the entry if given, or an empty object
  • 4.2.1 - 4.2.5 all take metadata last argument and pass to ensureRegistered
  • 6.3.1 May also have to consider metadata option for Loader.load
  • 6.5.1 Lookup to return metadata as well.

If it would help to provide any of the above as a PR I'd be more than happy to assist, but would rather have the suggestions reviewed at a higher level first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions