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

Expose importMetaResolve(url, baseURL) from node:module, and stabilize it #61127

Open

Description

@nicolo-ribaudo

What is the problem this feature will solve?

In Node.js based tools it's common to need to "resolve url X as if it were imported from module Y".

Node.js does not expose this as an API, even though it implements it. It only exposes "resolve url X as if it were imported from this current module", through import.meta.resolve.

https://github.com/wooorm/import-meta-resolve is, for example, a library that is basically code copy&pasted from this repository and published on npm. The annoying part is that, as Node.js resolution rules change, libraries need to change too, and you need to basically check which version of Node.js you are on to know which rules to apply.

What is the feature you are proposing to solve the problem?

Node.js does have a solution to this: the version of import.meta.resolve that takes two arguments, gated behind a flag (--experimental-import-meta-resolve). The reason it's behind a flag is because it would be different from the import.meta.resolve implementation of browsers, that takes only one argument.

It'd be great if Node.js could expose the two-args version as an export of node:module, something like

import { resolveModuleURL } from "node:module"`;

resolveModuleURL(url, parent);

with resolveModuleURL(url, import.meta.url) being equivalent to import.meta.resolve(url).

What alternatives have you considered?

This is related to #55756, which implements a more complex/comprehensive API.

Activity

  1. added
    moduleIssues and PRs related to the module subsystem.
    on Dec 23, 2025
  2. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  3. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 20, 2026
  4. nicolo-ribaudo commented on Jul 20, 2026

    @nicolo-ribaudo
    ContributorAuthor

    Still wanting this!

  5. romainmenke commented on Jul 20, 2026

    @romainmenke
    Contributor

    We have the same use case in Stylelint and also still want this feature

  6. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jul 21, 2026
  7. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 90 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Oct 20, 2026
  9. romainmenke commented on Oct 20, 2026

    @romainmenke
    Contributor

    Not stale

  10. removed
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Oct 21, 2026
  11. thescientist13 commented on Oct 21, 2026

    @thescientist13
    Sponsor

    Would also love to see this

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

    feature requestIssues requesting new Node.js features.moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions