webpack / enhanced-resolve

Offers an async require.resolve function. It's highly configurable.
MIT License
922 stars 186 forks source link

Feature Request: Support file urls #430

Open latin-1 opened 1 month ago

latin-1 commented 1 month ago
const resolve = require("enhanced-resolve");
resolve.sync("file:///path/to/project", "module");
resolve.sync("file:///path/to/project", "file:///path/to/module");
alexander-akait commented 1 month ago

Why you need it here? Currently we work only with paths, schemas support implemented in webpack

latin-1 commented 1 month ago

I think this would better align with Node.js behavior. AFAICT import in Node.js accepts file URLs.

const url = import.meta.resolve("./some-module.mjs");
// "file:///path/to/some-module.mjs"
await import(url);
alexander-akait commented 1 month ago

Feel free to send a PR https://github.com/webpack/enhanced-resolve/blob/main/lib/Resolver.js#L729, just check it is a scheme URL and remove it before parseIdentifier