Trying to understand Meteor 1.3 ES6 modules

So I’m in the process of upgrading my app to 1.3. So from the documentation it looks like Meteor now uses ES2015 modules.

So as I understand it (and correct me please if I’m wrong), with ES2015 modules, in order to use something from another file you must import it and in order to make it available for importing, you must export it.

However, I’ve just done the upgrade, and to my surprise, nothing breaks in my project - everything works perfectly. Shouldn’t everything that was referencing a function or object from another file break unless I import it? As it stands, it seems that every function and object in every file is globally available to every other file just like it was before Meteor 1.3.

In order to use the ES2015 import feature, you will need to put your files in a directory named imports/, If you don’t, they will be available globally and that’s why your code still works.

ah ok i guess they didn’t want to break everyone’s apps (like I expected mine to break).

Although looking at this thread (Meteor 1.3 imports directory?), i have a feeling the /imports folder might be a temporary thing. Wouldn’t have minded a flag or something that just makes everything implicitly in an imports folder.

@waiholiu check out video #15 for an overview an #16 for a practical implementation of imports, moving a project from the global load structure to an imports structure

It is a free-form discussion format, so it may feel unstructured (and long), but there is a lot of information in there where we touch a fairly large amount of gotchas and nuances.

1 Like