I am creating a React-Meteor app, and have created a Session variable to make certain data available globally. To do this, from the root folder of the app, I ran meteor add session.
The docs show for each method an import statement:
Session.methodName(parameters)
import { Session } from 'meteor/session'
In my project, I have commented out every single import { Session } statement, and it still works. Is this because I am only using .get() and .set(), or is the import statement in fact not needed?
This is for backwards compatibility. In early times, Meteor worked with magic globals that were available everywhere. They still work, but you should better import them to make things clearer.
IIRC, this worked everywhere. You could even define your own “global” variables by assigning them without putting var, let or const in front of them, like this:
myGlobal = true;
Once you put an explicit variable declarator in front, however,
var myVariable = true;
the scope was limited to the file the variable was defined in.
In packages, you additionally have to export the package-wide globals via a statement in package.js, to make them global for the entire application.