webpack / enhanced-resolve

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

align with esm spec on resolving an array of targets #420

Open vankop opened 1 month ago

vankop commented 1 month ago

cc @alexander-akait

fixes #400

alexander-akait commented 1 month ago

Node.js's implementation picks the first valid path (without attempting to resolve it) and throws an error if it can't be resolved. Node.js's fallback array is designed for forward compatibility with features (e.g. protocols) that can be syntactically validated:

try this repo using Node.js https://github.com/Boshen/test-esm-exports-array

alexander-akait commented 1 month ago

Also we need to seach what is bad-specifier, maybe we can use regexp for perf instead full parsing

vankop commented 1 month ago

@alexander-akait I have added same test case in this commit https://github.com/webpack/enhanced-resolve/pull/420/commits/0d428c916786ae579be02a3ee472b06dfb5024d5

we are slicing paths until first absolute or relative path

Also we need to seach what is bad-specifier, maybe we can use regexp for perf instead full parsing

we dont parse full string only first 2 chars, see getType in util/path ( this function is already exist, I just reuse it )