镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Incorrect parentURL for registerHooks when using require(esm) #60973

Closed

Description

@sxzz

Version

v25.2.1

Platform

Darwin Kevins-MacBook-Pro.local 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

Reproduction: https://github.com/sxzz/node-loader-require-esm

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

N/A

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

Expected: The parentURL of require(esm) should include the query ?test, matching the value of import.meta.url.

{
  specifier: './esm.mjs',
  url: 'file:///x/node-loader-require-esm/esm.mjs',
  parent: 'file:///x/node-loader-require-esm/mod.mjs?test'
}

Actual:

{
  specifier: './esm.mjs',
  url: 'file:///x/node-loader-require-esm/esm.mjs',
  parent: 'file:///x/node-loader-require-esm/mod.mjs'
}

What do you see instead?

{
  specifier: './mod.mjs?test',
  url: 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/mod.mjs?test',
  parent: 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/main.mjs'
}
{
  specifier: 'node:module',
  url: 'node:module',
  parent: 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/mod.mjs?test' // ✅
}
{
  'import.meta.url': 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/mod.mjs?test'
}
{
  specifier: './esm.mjs',
  url: 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/esm.mjs',
  parent: 'file:///Users/kevin/Developer/reproduction/node-loader-require-esm/mod.mjs' // ❌
}

Additional information

https://github.com/sxzz/import-without-cache needs this behavior.

/cc @joyeecheung

Activity

  1. changed the title [-]Incorrect `parentURL` of `registerHooks` with `require(esm)`[/-] [+]Incorrect `parentURL` for `registerHooks` when using `require(esm)`[/+] on Dec 6, 2025
  2. joyeecheung commented on Dec 6, 2025

    @joyeecheung
    Member

    Thanks for the report, fix in #60974

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions