Skip to content

Provide a way to dynamically change loader hook #33903

Description

@sloonz

I am looking at the possibility at doing something like mitogen in node.

How it would work, in really broad strokes, is :

  • Spawn an child node process through sudo/ssh/whatever. Initial code is passed with -e.
  • This initial code reads commands from stdin, push results on stdout
  • One command is EVAL, which just evals a javascript string
  • ESM modules imported by the evaluated code are expected to be imported from the parent context. It therefore needs a loader hook which would communicate (via stdin/stdout) to get the module from the parent

However, it's impossible generally to pass a meaningful --loader argument to the child : think of the case of a read-only file-system where we cannot write a temporary loader.mjs that does the job, for example.

In the Python world, mitogen just dynamically add a module loader. It would be nice if we could do the same thing, something in the lines of :

import.meta.hooks = {
async resolve() { ... },
...
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions