Skip to content

import.meta.resolve no longer available in loaders >= v20 #49198

Closed
@halfmatthalfcat

Description

@halfmatthalfcat

Version

20.0.0

Platform

Darwin ....* 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

package.json

{
  "name": "import-meta-resolve-test",
  "type": "module"
}

loader.mjs

export function load(url, _, next) {
  console.log(import.meta.resolve);
  return next(url);
}

index.mjs

console.log("hello world");

node --experimental-import-meta-resolve --experimental-loader ./loader.mjs ./index.mjs

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

  • Must be on Node v20 or above
  • Reproduced every time

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

console.log in loader should resolve import.meta.resolve

What do you see instead?

undefined is printed

Additional information

import.meta.resolve exists in <= Node v20, at least I checked in 16-19.

I didn't see anywhere in 20+ release notes of this capability being removed. If this is known, feel free to close this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.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