🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

ember-rollup

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-rollup

Use rollup to add runtime dependencies to an ember-cli addon.

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
3
Created
Source

ember-rollup npm version Build Status

Use rollup to add runtime dependencies to an ember-cli addon.

Installation

npm i --save ember-rollup

What is this thing?

ember-rollup is not an addon, but rather a function that takes just two arguments:

  • An array of string module names. These modules must be present in dependencies in package.json.
  • The original object to be exported in index.js

Simply wrap the exports of your app/addon index.js with the function, and suddenly, ES6/2015 dependencies in your ember app! ember-rollup even handles babel for you. Modules are namespaced based on the addon name.

ember-rollup looks for a jsnext:main or module in package.json of imported modules. If not provided, it will fallback to main and assume a normal CommonJS module. If main is not provided, it will assume index.js.

Example

//my-addon/index.js
const emberRollup = require('ember-rollup');
const runtimeDependencies = ['my-module', 'rsvp'];

module.exports = emberRollup(runtimeDependencies, {
  name: 'my-addon',
  ...
});
//my-addon/app/my-thing.js
import myModule from 'my-addon/my-module';
import RSVP from 'my-addon/rsvp';

Custom Rollup Entry

Some packages don't specify jsnext:main or module in their package.json even though a module exists. You can manually point rollup to the module entry point file path using rollupEntry.

//my-addon/index.js
const emberRollup = require('ember-rollup');
const runtimeDependencies = [{
  name: '@reactivex/rxjs',
  namespaced: false,
  rollupEntry: 'dist/esm5_for_rollup/index.js'
}];

module.exports = emberRollup(runtimeDependencies, {
  name: 'my-addon',
  ...
});
//my-addon/app/my-thing.js
import { Observable } from 'rxjs';

Turning off addon namespacing

By default, module names are namespaced based on the addon. The reason being, an app might use two different addons that require two different versions of the same module. If you would rather force the app to only include one version of any given module, you can turn off namespacing.

//my-addon/index.js
const emberRollup = require('ember-rollup');
const runtimeDependencies = [{
  name: 'my-module',
  namespaced: false
}, 'rsvp'];

module.exports = emberRollup(runtimeDependencies, {
  name: 'my-addon',
  ...
});
//my-addon/app/my-thing.js
import myModule from 'my-module';
import RSVP from 'my-addon/rsvp';

Keywords

ember

FAQs

Package last updated on 06 Nov 2020

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