Google News
logo
Meteor.js - Interview Questions
Lazy loading modules from a package in Meteor.
Packages can also specify a lazy main module:
Package.onUse(function (api) {
  api.mainModule("client.js", "client", { lazy: true });
});
This means the client.js module will not be evaluated during app startup unless/until another module imports it, and will not even be included in the client bundle if no importing code is found.
 
To import a method named exportedPackageMethod, simply :
import { exportedPackageMethod } from "meteor/<package name>";
Note : Packages with lazy main modules cannot use api.export to export global symbols to other packages/apps. Also, prior to Meteor 1.4.4.2 it is neccessary to explicitly name the file containing the module: import "meteor/<package name>/client.js".
Advertisement