ilearnio / module-alias

Register aliases of directories and custom module paths in Node
MIT License
1.76k stars 69 forks source link

Resolve longest match first #13

Closed thomas-p-wilson closed 7 years ago

thomas-p-wilson commented 7 years ago

Given:

moduleAlias.addAliases({
    "react-dom": "preact-compat-enzyme",
    "react-dom/server": "preact-render-to-string"
});

An attempt to require('react-dom/server') yields Error: Cannot find module 'preact-compat-enzyme/server'.

I believe the simple solution would be to evaluate possible matches, and choose the longest.