2.0.0 • Published 6 years ago

seebigs-resolve v2.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

seebigs-resolve

Resolve a target string to a single filepath and get the contents of the file at that location

Follows Node spec: https://nodejs.org/api/modules.html

Install

$ npm install seebigs-resolve

Resolve

var resolve = require('seebigs-resolve');
var fromFile = __filename;

resolve('/abs/module.js', fromFile);
resolve('../rel/module.js', fromFile);
resolve('npm_module', fromFile);

// returns { contents: '...', path: '/path/to/module.js' }

Paths

Modules can also be resolved from an optional array of paths

var resolve = require('seebigs-resolve');
var fromFile = __filename;
var paths = [
    '../one'
];

resolve('module.js', fromFile, paths);

Browser Field

Force resolve to use the browser field in package.json

var resolve = require('seebigs-resolve');
var fromFile = __filename;

resolve.browser('module.js', fromFile);
2.0.0

6 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago