Meteor 1.3 : How to EXPORT and IMPORT ES2015 modules from a meteor package to the app using that package

Ok, so I am using Meteor 1.3.
I want to use ES2015 modules to import and export modules rather than Meteor’s internal export structure.
Reason :

  • I want to test the package files without running meteor. For which I need the files to export an object.

Problem :
I am able to use ES6 modules and test the files.
But that breaks the Meteor export structure i.e. I dont put var before a variable and it’s exported to all other files and then I just use api.export . But if I want it to test in CommonJS, I have to use var. So how do I export?

Please help. I am not used to write help questions on forums, so please ask me I you need more information.
Thanx in advance!

Did you add the ecmascript package to your package.js? And do you use api.mainModule instead of api.export there?

You can find more information about the modules support in the 1.3 modules README.

1 Like

Thanx @martijnwalraven. I knew I had to use api.mainModule but didn’t know how it worked. Now it seems stupid.
Thanx anyway. You guys are doing great job with Meteor. :heart_eyes: