Understanding old files and Meteor 1.3

I notice that the demo of Meteor 1.3 has
import { Meteor } from ‘meteor/meteor’;
at the top of
server/main.js

I upgraded my 1.2 app to Meteor 1.3, changing no code manually.

It runs fine, but it doesn’t have any explicit code in it to import Meteor in either my client or server files.

Is the import { Meteor } command unnecessary? Is it being included automatically in some cases?

Meteor 1.3 is backwards compatible so will run as expected without import statements, but moving towards import/export is the recommended path forward and in the future the eager loading of js files may be removed in favor of lazy loading.

thank you. I understand that. But how is it that the old files still work? Does it automatically do an import {Meteor} on all ‘eagerly loaded’ js files, or only on some of them?

-All files in folder ‘/imports’ are not automatically imported, so you have to use the import statement

-All other files ( so not in a subfolder of /imports ) are automatically loaded by Meteor.

More info in The Guide

I must be missing something.

I understand that my other files, not in /imports are automatically loaded. But does the compiler automatically include ‘meteor/meteor’ into those automatically loaded files? And if so, then what else does it automatically include in those files?

Yes, it is automatically importing anything that is exported by a meteor package… any npm packages will still require an import to use.

1 Like

It’s not adding any import statements, it’s just that your code gets all put into one file where global variables are now in all of your file’s scopes and can then be used throughout your app.

You can see the compiled app.js in:

client: '.meteor/local/build/programs/web.browser/app/app.js'
server: '.meteor/local/build/programs/server/app/app.js'

I agree it is not clear from the new Meteor 1.3 Guide what the default bundling and load order is for apps built without using import and that all Meteor objects are still accessible as globals. I’m writing an update to the Guide to make this more clear. See Application Structure

1 Like

Thanks. This clarifies whats happening better now. This will make it easier for me to determine if and when I need to import explicitly. Thanks for everyones input.