Package Exports
- ember-require-module
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 (ember-require-module) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ember-require-module
Dynamically require modules
Installation
ember install ember-require-module
Helpful Links
Looking for help?
If it is a bug please open an issue on GitHub.
Usage
import requireModule from 'ember-require-module';
const moment = requireModule('moment');
// requireModule will return undefined if moment is not found
assert('MomentJS is required!', moment);
// Dynamically require modules when needed
function runTask(taskName, ...params) {
let task = requireModule(`my-addon/tasks/${taskName}`);
assert(`The task ${taskName} does not exist.`, task);
return task.run(...params);
}
// import a named export from a module
const THING = requireModule('path-to-module', 'THING');