Package Exports
- import-modules
- import-modules/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (import-modules) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
import-modules
Import all modules in a directory
This package is intentionally simple. Not interested in more features.
Install
$ npm install import-modules
Usage
.
└── directory
├── foo-bar.js
└── baz-faz.js
const importModules = require('import-modules');
const modules = importModules('directory');
console.log(modules);
//=> {fooBar: [Function], bazFaz: [Function]}
API
importModules(directory?, options?)
directory
Type: string
Default: __dirname
Directory to import modules from. Unless you've set the fileExtensions
option, that means any .js
, .json
, .node
files, in that order. Does not recurse. Ignores the caller file and files starting with .
or _
.
options
Type: object
camelize
Type: boolean
Default: true
Convert dash-style names (foo-bar
) and snake-style names (foo_bar
) to camel-case (fooBar
).
fileExtensions
Type: string[]
Default: ['.js', '.json', '.node']
File extensions to look for. Order matters.
Related
- import-from - Import a module from a given path
- import-cwd - Import a module from the current working directory
- import-lazy - Import a module lazily