node-resolve-flow
v0.8.0
Published
Isomorphic node resolve algorithm for any file system (in-browser or Node)
Downloads
2
Maintainers
Readme
node-resolve-flow
Isomorphic node resolve algorithm for any file system (in-browser or Node)
This module abstracts the node module resolution algorithm (loosely following the spec at https://nodejs.org/api/esm.html#esm_resolver_algorithm_specification, correcting its "imprecisions") as a flow (a generator function) given an abstract file system interface
Usage:
import resolver from 'node-resolve-flow';
const resolve = resolver({ isFile, loadPkgJSON });
resolve
will be a flow (a generator function) which takes 2 parameters: importee
and importer
and returning the file URL of the resolved module if successful, and throws or returns undefined
if unsuccessful, where
isFile(fileURL)
: a user-supplied flow that should return true if object represented byfileURL
exists and is a fileloadPkgJSON(fileURL)
: a user-supplied flow that should load thepackage.json
file located atfileURL
Note: since the resolver is working with generators you would need a generator runner i.e ConclureJS or Redux Saga to make use of it.