Skip to content

Custom module loader for Workers #21667

Closed
@rumkin

Description

@rumkin

Node.js users has two problems:

  • Simple and powerful sandboxing.
  • Using ES modules.

Workers can solve both of them in very elegant way with custom resolvers which are the same as experimental es module resolver.

const worker = new Worker('./worker-path.js', {
    moduleLoader: {resolve, dynamicInstantiate},
});

It solves sandboxing with full dependency control in custom context. And it simplifies es modules usage with preserving usual code flow in main thread and es flow in worker thread.

/cc @addaleax @TimothyGu @Qard @aqrln @oe @benjamingr @nodejs/workers

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.staleworkerIssues and PRs related to Worker support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions