How to import an amd module in ember-cli?

前端 未结 3 1483
攒了一身酷
攒了一身酷 2021-02-13 02:13

I am building an EmberJS application with the great help of ember-cli, which is great, but I have an error and I cannot find what I am doing wrong.

Here is

3条回答
  •  醉话见心
    2021-02-13 02:30

    In recent versions of ember (I am using 2.11) it is possible to load AMD in UMD wrappers using

    app.import('bower_components/js-md5/js/md5.js', {using: [{ 
       transformation: 'amd', as: 'js-md5' 
    }]});
    

    And in your code

    import md5 from 'js-md5';
    

    In your case of underscore it should look like:

    app.import('vendor/underscore/underscore.js', {using: [{ 
       transformation: 'amd', as: 'underscore' 
    }]});
    

提交回复
热议问题