browser-resolve-sync

synchronous resolve algorithm with browser field support

Usage no npm install needed!

<script type="module">
  import browserResolveSync from 'https://cdn.skypack.dev/browser-resolve-sync';
</script>

README

browser-resolve-sync Build Status

Node.js resolve algorithm with browser field support.

This is 1:1 port of Roman Shtylman's asynchronous browser-resolve module.

API

resolve(pkg, opts={})

Resolve a module and return the full path.

Options:

  • filename - the calling filename where the require call originated (in the source)
  • paths - require.paths array to use if nothing is found on the normal node_modules recursive walk
  • packageFilter - transform the parsed package.json contents before looking at the "main" field
  • modules - object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)
  • extensions - array of file extensions to search in order

License

MIT