pahen / node-module-lookup-amd

Resolve aliased dependency paths using a RequireJS config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

module-lookup-amd npm npm

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

var lookup = require('module-lookup-amd');

var realPath = lookup({
  partial: 'someModule',
  filename: 'file/containing/partial',
  config: 'path/to/my/requirejs/config' // optional if not using paths/map aliasing
});
  • partial: the dependency that you want to lookup
  • filename: the path of the file that contains the dependency (i.e., parent module)
  • 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 argument which is the full path to your config file.

Shell usage

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

About

Resolve aliased dependency paths using a RequireJS config


Languages

Language:JavaScript 99.6%Language:CSS 0.4%Language:HTML 0.1%