mardi 20 octobre 2015

Cannot import ES6 NPM module directly in to Ember CLI

I'm trying to use d3-arrays in a project. The module itself includes both original ES6 modules and a UMD build. I would expect to be able to add this directly as a dependency to my ember-cli project and have it available, but that is not the case.

I've seen suggestions that are over a year old saying to use ember-browserify, and others suggesting making a shim, but AFAIK this would really only be ideal if it were a bower dependency, and bower seems to be on the way out.

For the sake of correctness, how can I just import this module as though it were part of my project and use it as import {mean} from 'd3-arrays without needing to convert it to another package format first?

I've tried making a shim which just exports the imported UMD code:

// index.js
var d3ArraysExports = require('d3-arrays');
d3ArraysExports.name = 'd3-arrays-shim';
module.exports = d3ArraysExports;

Ember finds this module just fine, but it never gets added to the require entries list.

If there is some design decision in Ember CLI as to why this doesn't work, please point me to it.




Aucun commentaire:

Enregistrer un commentaire