I am new to meteor and was starting to use packages for features kind of development for a new web application.
I wanted to create a core of the web app and then modules as separate packages. I was wondering if I could divide the core into sub packages nested under a top level core package like this.
But so far after searching all over the place I get the impression that we can create only top level packages like this
Is this a meteor restriction or am I missing something.
It will be nice to be able to divide a package into sub-packages
Unfortunately packages can only be top-level directories in the
But in Meteor 1.3 (the next release, currently in beta), you can have the nested structure you want using the new ECMAScript 2015 module standard!
Here’s a work-in-progress of the new Meteor Guide article about app structure:
thanks @sashko. The good thing is I upgraded to meteor 1.3 beta yesterday so hopefully I can start using this new structure immediately.
@sashko does meteor 1.3 load the html files under imports folder? your guide mentioned that we could organize the templates ( i am using blaze) under the import/ui directory. But when I startup, the app cannot find my main layout template which i put under imports/ui/layouts/main_layout.
If I load the html using import … it seems to work.
It will be a bummer if we have to load all html ourselves. Is it now like packages were the all html is loaded automatically ( i read that somewhere?
In both Meteor packages and ES2015 modules, HTML is no longer loaded automatically.
Ok, do you suggest then how to load all template at application startup, since the code breaks if the template are not loaded…
I’d suggest loading the templates where you actually use them. So for every template, you should make a JS file which imports the templates used there. You can see this in our new example app: https://github.com/meteor/todos/blob/7ea33b23c3bde8d5115c21eb714c0c3aa939e6f1/imports/ui/components/lists-show.js#L4
thanks. I will.
There is a defect in meteor where by specifying a imports directory inside a package, you cannot load templates inside the package.js by using api.addFiles(’/imports/ui/template.html’). The template is not loaded. If you move the template to a directory outside imports, then it works fine.