You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ember-require-module

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-require-module

Easily require a module which will silently fail if it is not found.

0.4.0
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

ember-require-module

Build Status Ember Observer Score npm version

Dynamically require modules

Installation

ember install ember-require-module

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

Compatibility

See the Changelog

  • Ember.js v3.24 or above
  • Ember CLI v3.24 or above
  • Node.js v12 or above

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

ember-addon

FAQs

Package last updated on 27 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts