javascriptecmascript-6ember.jsember-cliember-classic

Ember CLI import ES6 file to ember-cli-builds.js


So the ember-cli-builds.js file clearly states

// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

I'm importing regular javascript files this way

app.import('vendor/global.js');

but what is the proper way to "specify an object with the list of modules as keys along with the exports of each module as it's value"?


Solution

  • At the "AMD Javascript modules" heading of the guides, it is described like that:

    Provide the asset path as the first argument, and the list of modules and exports as the second.

    app.import('bower_components/ic-ajax/dist/named-amd/main.js', {
      exports: {
        'ic-ajax': [
          'default',
          'defineFixture',
          'lookupFixture',
          'raw',
          'request'
        ]
      }
    });
    

    You can now import them in your app. (e.g. import { raw as icAjaxRaw } from 'ic-ajax';)

    Reference From Guide