Skip to content

esm loaders: getBuiltin() does not work with node:test #48516

Closed
@cjihrig

Description

@cjihrig

Version

latest main

Platform

all

Subsystem

esm, loaders

What steps will reproduce the bug?

Create an ESM loader, and in the globalPreload() hook, use getBuiltin() to access node:test (test without the node: scheme also does not work).

How often does it reproduce? Is there a required condition?

Always reproduces.

What is the expected behavior? Why is that the expected behavior?

node:test can be used with getBuiltin()

What do you see instead?

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'builtinName' is invalid. Received 'node:test'

Additional information

I imagine this is related to the use of BuiltinModule.canBeRequiredWithoutScheme(builtinName) in getBuiltin().

My use case is to attach the message port to the node:test module. For now, I have worked around this by attaching the port to globalThis instead. Once nodejs/loaders#147 is resolved, I won't need to do this, but I wanted to raise the issue in case the loaders team thinks it's important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loaders

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions