Skip to content

prioritize module resolutions

Compare
Choose a tag to compare
@iambumblehead iambumblehead released this 06 Oct 16:15
· 56 commits to main since this release
20ab159

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: