https://github.com/seebigs/seebigs-resolve
https://github.com/seebigs/seebigs-resolve
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/seebigs/seebigs-resolve
- Owner: seebigs
- Created: 2016-09-09T12:50:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-31T21:38:08.000Z (over 7 years ago)
- Last Synced: 2025-02-16T02:34:03.894Z (over 1 year ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://nodejs.org/api/modules.html)*
## Install
```
$ npm install seebigs-resolve
```
## Resolve
```js
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
```js
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
```js
var resolve = require('seebigs-resolve');
var fromFile = __filename;
resolve.browser('module.js', fromFile);
```