prioritize module resolutions
With this release resolvewithplus
supports optional isbrowser
, istypescript
and isimport
fields and when one of these is specified the resolver prioritizes browser-exported files, typecript and module files. By default, isimport
is true
resolvewithplus('react-dom/server', '/resolvewith/test/', {
isbrowser: true
}) // 'file:///resolvewith/node_modules/react-dom/server.browser.js'
resolvewithplus
now also supports an advanced priority
option. When a package.json is parsed, a default priority
list determines the priority of named-exports in this order: browser
(if isbrowser
), then import
then node
then default
. Define a custom priority
list to specify a custom ordering. If you are using nodejs, this is probably not needed,
resolvewithplus('react-dom/server', '/resolvewith/test/', {
priority: ['deno', 'default']
}) // 'file:///resolvewith/node_modules/react-dom/server.deno.js'
resolvewithplus('react-dom/server', '/resolvewith/test/', {
priority: ['browser', 'default']
}) // 'file:///resolvewith/node_modules/react-dom/server.browser.js'
changelog:
- add support for 'priority' configuration option
- explicitly prioritize "browser" then "import" then "default", when browser and import both true
- update README image link to use "main" repo path
- replace reducer function w/ simple recursion