Skip to content

Concerns with async resolve hook #14

@guybedford

Description

@guybedford

Node.js started out with an asynchronous resolve hook and it was learnt through hard experience that this is the wrong design for a number of reasons - performance, sync import use cases, usability.

Resolve hooks on the web being sync is likely also a strong requirement to remain for browser implementers I would assume.

I would like to therefore suggest a separation into two hooks that allow for layering here:

  1. importHook: This hook gets called for both dynamic import and global.import() (if we were to have such a function). It is async but does not run for dependency modules. It is the job of this hook to ensure all sources for dependency modules are available by pre-resolving all modules and ensuring they are cached.
  2. resolveHook: With the import hook layering the async aspects, the resolve hook can always be called synchronously.

This is not a Stage 1 concern - but writing it up now to be clear that this would be a Stage 2 concern for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions