Skip to content

Archdiocese-of-New-Orleans/ember-require-module

 
 

Repository files navigation

ember-require-module

Build Status npm version

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');

About

Dynamically require modules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.4%
  • HTML 16.2%
  • Handlebars 0.4%