node-resolve-flow

0.8.0 • Public • Published

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 by fileURL exists and is a file
  • loadPkgJSON(fileURL): a user-supplied flow that should load the package.json file located at fileURL

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.

/node-resolve-flow/

    Package Sidebar

    Install

    npm i node-resolve-flow

    Weekly Downloads

    1

    Version

    0.8.0

    License

    MIT

    Unpacked Size

    15.1 kB

    Total Files

    4

    Last publish

    Collaborators

    • dmaevsky