Meteor has always imported all the html files present in the folder automatically. I now see a strange behaviour where I have to manually import each file for the templates to be seen.
Is this a new feature?
Meteor has always imported all the html files present in the folder automatically. I now see a strange behaviour where I have to manually import each file for the templates to be seen.
Is this a new feature?
Apart from the handling of the imports
folder, the eager loading still applies.
Whatâs your folder structure and packages?
Even on a new project.
If I create a new project (meteor create test), and add an html file in the client folder, it is not âseenâ.
I can even duplicate a template (âhomeâ for instance), in a different html file without error message (which is not normal).
But if I add "import â./test.htmlâ; " to main.js, then it works as expected. I never had to do that before.
Read the fifth bullet point on https://github.com/meteor/meteor/blob/devel/History.md#v17-2018-05-28 ( Applications may now specify client and server entry point modules in a newly-supported "meteor"
section of package.json
)
If I write the following in package.json, then no template is loaded at all.
"client": false,
I donât get this feature
From this blog post: https://blog.meteor.com/meteor-1-7-and-the-evergreen-dream-a8c1270b0901
This
meteor.mainModuleconfiguration allows you to override Meteorâs default rules for eagerly loading modules. Whereas previously you would have to put modules in an
imports/directory in order to prevent them from being eagerly evaluated, when you use
meteor.mainModuleto specify entry points, all other modules besides the entry points will be loaded lazily. In other words, you no longer need an
imports/directory, and Meteorâs module loading behavior will work more like non-Meteor Node projects.
So I have deleted this part of package.json to restore the old behaviour:
,
"meteor": {
"mainModule": {
"client": false,
"server": false
},
"testModule": "tests/main.js"
}
You will need to actually delete the "meteor"
key and everything in it, rather than setting to false
I think I get why html files need to be imported (with Blaze):
The new lazy loading system still eagerly loads non-js assets, but Blaze compiles your .html
files into .html.js
files, flagging them as lazy-loaded, and requiring you to import them.
css/less/sass/styl
files are still eagerly loaded, and I believe that if you use the static-html
package instead of Blaze, it will also be eagerly loaded (note: I have not tested this assumption)
Yes, deleting the Meteor key fixes it.