module-lookup-amd

Resolve aliased dependency paths using a RequireJS config

MIT 41 个版本
安装
npm install module-lookup-amd
yarn add module-lookup-amd
pnpm add module-lookup-amd
bun add module-lookup-amd
README

module-lookup-amd

CI npm version npm downloads

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' jump to dependency feature that lets you click on a module name and open the relevant file.

npm install module-lookup-amd

Usage

ESM

import lookup from '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
  configPath: 'path/to/config/directory', // optional
  fileSystem: {} // optional
});

CommonJS

const { default: lookup } = require('module-lookup-amd');
  • 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 configPath or directory argument which is assumed to be the location where your config would have been.
  • configPath: path to the config file (or its directory) used to determine the module resolution directory; inferred automatically when config is a string path
  • 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

lookup-amd -c path/to/my/config.js -f path/to/file/containing/dependency -d path/containing/all/files my/dependency/name

License

MIT

版本列表
10.0.1 2026-05-26
10.0.0 2026-05-19
9.1.3 2026-04-27
9.1.2 2026-04-19
9.1.1 2026-02-23
9.1.0 2026-02-09
9.0.5 2025-06-16
9.0.4 2025-02-02
9.0.3 2025-02-01
9.0.2 2024-07-26
9.0.1 2024-04-10
9.0.0 2024-04-10
8.0.5 2023-05-13
8.0.4 2023-05-10
8.0.3 2023-05-04
8.0.2 2023-05-04
8.0.1 2023-04-25
8.0.0 2023-04-25
7.0.1 2020-12-21
7.0.0 2020-11-29
6.2.0 2019-03-19
6.1.0 2018-12-16
6.0.0 2018-12-14
5.0.2 2018-12-12
5.0.1 2018-02-19
5.0.0 2018-01-07
4.0.5 2017-09-30
4.0.4 2017-04-29
4.0.3 2016-07-15
4.0.2 2016-06-14
4.0.1 2016-06-04
4.0.0 2016-06-02
3.0.0 2016-05-11
2.0.5 2015-10-01
2.0.4 2015-07-09
2.0.3 2015-07-04
2.0.2 2015-07-04
2.0.1 2015-06-27
2.0.0 2015-06-26
1.0.0 2014-10-06
0.0.0 2014-10-06