Hi I read the meteor guide (1.6) for exporting and importing classes. But the following does not work, like the meteor guide suggests.
Yes, I am using meteor 1.6 and the ecmascript package is in my package list. I am thankful for any help!
file: imports/utils/AspectRatio.js
export default class AspectRatio {
constructor(ratio, height, width, max_width, max_height) {
this.ratio = ratio;
this.height = height;
this.width = width;
this.max_width = max_width;
this.max_height = max_height;
}
get width() {
if (this.width > this.max_width) {
this.ratio = this.max_width / this.width;
this.height = this.height * this.ratio;
this.width = this.width * this.ratio;
}
return this.width;
}
get height() {
if (this.height > this.max_height) {
this.ratio = this.max_height / this.height;
this.width = this.width * this.ratio;
this.height = this.height * this.ratio;
}
return this.height;
}
}
But trying to import it leads to an error depending on how I import It with {} or without it.
1.) error: AspectRatio not a constructor
2.) Token not supported and the max stack size exceeded
file: imports/components/test.js
import { AspectRatio } from '/imports/utils/AspectRatio.js';
Template.test.onCreated(function test() {
const ar = new AspectRatio(0, 480, 200, 100, 80);
console.log(ar.width);
console.log(ar.height);
});