https://github.com/dependents/node-module-lookup-amd
Resolve aliased dependency paths using a RequireJS config
https://github.com/dependents/node-module-lookup-amd
requirejs
Last synced: about 1 year ago
JSON representation
Resolve aliased dependency paths using a RequireJS config
- Host: GitHub
- URL: https://github.com/dependents/node-module-lookup-amd
- Owner: dependents
- License: mit
- Created: 2014-10-06T21:48:28.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2025-02-02T08:01:26.000Z (over 1 year ago)
- Last Synced: 2025-03-29T17:07:33.056Z (about 1 year ago)
- Topics: requirejs
- Language: JavaScript
- Homepage:
- Size: 592 KB
- Stars: 6
- Watchers: 3
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# module-lookup-amd
[](https://github.com/dependents/node-module-lookup-amd/actions/workflows/ci.yml?query=branch%3Amain)
[](https://www.npmjs.com/package/module-lookup-amd)
[](https://www.npmjs.com/package/module-lookup-amd)
> Resolve AMD dependency paths to an absolute path on the filesystem
This module takes in a partial and *synchronously* gives back its absolute path on the filesystem.
I built this for [Dependents'](https://sublime.wbond.net/packages/Dependents) [jump to dependency](https://github.com/dependents/Dependents#jump-to-a-dependency) feature that lets you click on a module name
and open the relevant file.
```sh
npm install module-lookup-amd
```
## Usage
```js
const lookup = require('module-lookup-amd');
const realPath = lookup({
partial: 'someModule',
filename: 'file/containing/partial',
directory: 'path/to/all/js/files', // optional
config: 'path/to/my/requirejs/config', // optional
fileSystem: {} // optional
});
```
* `partial`: the dependency that you want to lookup
* `filename`: the path of the file that contains the dependency (i.e., parent module)
* `directory`: Used to resolve files if you're not using a requirejs config
* `config`: the path to your RequireJS configuration file
* As an optimization, you can provide a pre-parsed config object (the contents of the RequireJS config in object form)
as `config`. You are then required to provide a `directory` argument which is assumed to be the location where your config would have been.
* `fileSystem`: An alternative `fs` implementation to use for filesystem interactions. Defaults to Node.js's `fs` implementation if not supplied.
## CLI
Assumes a global `-g` installation
```sh
lookup-amd -c path/to/my/config.js -f path/to/file/containing/dependency -d path/containing/all/files my/dependency/name
```
## License
[MIT](LICENSE)