I want to use a JavaScript module (ES2015) in my Ember.js project, but it does not work.
I wrote a simple sample ES6 JavaScript file,
myES6lib.js
export default function square(b) {
return b * b;
};
Following the MANAGEMENT DEPENDENCES, I ran
ember generate vendor-shim myES6lib
and added a line in ember-cli-build.js
app.import("vendor/shims/myES6lib.js");
then I called the square function in an Ember Controller
import MyES6lib from "myES6lib";
...
console.log("Square(5) = " + MyES6lib.square(5));
but I got an error message as follows:
Uncaught TypeError: _myES6lib.default.square is not a function
Any hints are appreciated, thanks in advance.
Note: I tried to transform myES6lib to ES5 code by Babel, but the result was same.
Aucun commentaire:
Enregistrer un commentaire