1.1.1 • Published 6 years ago

@nore/resolve v1.1.1

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

@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 resolved
  • path — the absolute path of the project, to match local modules
  • extension — the extension of the file is being requested
  • parent — 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.


License ISC  ·  GitHub @navaru  ·  Twitter @navaru