SeDav
SeDav

Reputation: 781

No files eagerly loaded in meteor application other than main.js

After having created a simple meteor application with the newest meteor 1.8 client:

meteor create testapp

and then adding a file under the path server/test.js, I would expect the file main.js and test.js beeing eagerly loaded server side. Nevertheless only main.js is loaded server side.

In the meteor documentation about file structure main.js is reported to be the main entry point, but not to be the only file eagerly imported if present.

Upvotes: 2

Views: 165

Answers (1)

SeDav
SeDav

Reputation: 781

The reason for this behavior is a section in the package.js, that is beeing created by meteor create

{
  ...,
  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  }
}

in the changelog to 1.8 they mention this behavior.

When specified, these entry points override Meteor's default module loading semantics, rendering imports directories unnecessary. If mainModule is left unspecified for either client or server, the default rules will apply for that architecture, as before. To disable eager loading of modules on a given architecture, simply provide a mainModule value of false.

So the solution is to remove the mainModule section from the package.json.

Upvotes: 3

Related Questions