@nore/resolve
v1.1.1
Published
ES modules file resolve
Downloads
2
Readme
@nore/resolve
Resolve a module request
, returning the absolute path of the file.
Installation
$ npm install @nore/resolve
Use:
import resolve from '@nore/resolve'
const file = resolve({
request: 'components/button',
path: '/path/to/project',
extension: '.css',
parent: '/path/to/project/source/app/index.js',
})
Options:
request
— the module request that should be resolvedpath
— the absolute path of the project, to match local modulesextension
— the extension of the file is being requestedparent
— the absolute path to the file from which the request was made (optional)
request
formats:
- absolute paths:
/some/path/to/file.extension
/path/to/folder
- relative paths:
./path/to/file.extension
./path/to/folder
../folder/file.extension
../path/to/folder
- local modules, relative to project
path
:path/to/file.extension
path/to/folder
- modules, loaded from the
node_modules
folder:jquery
For example if a request is /path/to/name
and a file and folder exists with the same name, the file name.ext
has priority.