lundi 11 mars 2019

import node js module in ember js framework

I am trying to import a simple node js module into Ember js. I followed the quick start at https://guides.emberjs.com/v3.8.0/getting-started/quick-start/ and got the People List working.

Then I added the simple upper-case module using npm install upper-case and added it to ember-cli-build.js as mentioned in https://guides.emberjs.com/release/addons-and-dependencies/managing-dependencies/.

After that, I opened scientists.js and added import to upper-case as follows:

import Route from '@ember/routing/route';
//import uc from 'upper-case';

export default Route.extend({
  model() {
    var arr = new Array();
    arr[0] = 'Marie Curie'; // uc('Marie Curie');
    arr[1] = 'Mae Jemison';
    arr[2] = 'Albert Hofmann';
    return arr;
  }
});

If I remove the comments, it shows me a blank screen. If I use 'Marie Curie'.toUpperCase() it works, but I want to be able to import such node modules. How can I achieve this?

I have already tried exception while importing module in ember js and ember-auto-import, but they don't seem to work for me. The above method I tried seems to be simple and would be nice if it can work this way.

PS: I could make upper-case work in other JS frameworks such as React and Vue, so the module itself doesn't have any issues.




Aucun commentaire:

Enregistrer un commentaire