Skip to content

mufancom/module-lens

Repository files navigation

NPM Package Build Status Coverage Status

Module Lens

Installation

yarn add module-lens

Usage

import {resolve} from 'module-lens';

let path = resolve('foo/bar', {
  sourceFileName: __filename,
  baseUrlDirName: __dirname,
});

console.log(path);

let specifier = build(path, {
  sourceFileName: __filename,
  baseUrlDirName: __dirname,
});

console.log(specifier);

Difference from Package "resolve" by Browserify

The popular module resolving package resolve resolves a module specifier to a file, and throws an error if not being able to resolve to the final entry point. The resolve of Module Lens, however, does only minimal checks to determine where should the specifier be resolved to.

Module Lens resolve does not resolve a specifier to the final entry point, for example:

// if we have module "rxjs" installed:
resolve('rxjs/not-exists', {sourceFileName: __filename}); // -> 'node_modules/rxjs/not-exists'

License

MIT License.

About

Simple module specifier utilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published