Export default class not working

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);


As @townmulti said in his original post you don’t need to put brackets around your import when you make a export default. See “Examples” section on MDN.

import AspectRatio from '/imports/utils/AspectRatio.js';

Can you try to rename your named function test with something different that does not match the template’s name test ? Not really sure if I already saw something like this…


There are two issues with your code:

  1. As @townmulti and @borntodev have said, if you use export default, you don’t use {} in the import statement.
  2. You have defined getters with the same names as parameters to the constructor. This will result in recursive calls to the constructor until you’re out of memory.
1 Like

Ups yes Rob. You are right. And thanks again for beeing so helpful!!

1 Like