Hey guys, nice work with 1.3, it’s a lot of little things that are going to make the overall developer experience a lot smoother. I’m reading through the guide now and had a couple of questions about this section, namely:
###1. Relative import paths
I found relative paths in the examples that have more than one ‘finding the parent level’, i.e.
../../ hard to follow. In past experience with React projects I’ve also found these tedious to maintain and at certain times difficult to reason about.
I can see a benefit in using relative paths because I’m assuming in future we will be able to move everything from
imports/ into the project’s base directory (as one example). At that point we’d have to update a lot of individual files though if we’re using absolute paths, which would be a pain for version control.
I have used Broccoli in the past, which allows you to set a root directory for
import statements in the brocfile (basically a project
settings.js). So I’m wondering whether a similar option would be possible for Meteor: for now set the base import folder to
/imports. Then from your
routes.js you could just
import '/ui/template/pages/xyz.html', and when the hypothetical Meteor 1.4 comes out and forces everyone to switch to the new imports pattern (making
/imports redundant), we could just kill the that directory and change the import root in one line of code.
###2. Clarity about what to import
I found this sentence in particular unclear:
imports/startup/client/routes.js configures all of the routes and then imports all other code that is required on the client, forming the main entry point for the rest of the client application
My intuition tells me that importing “all other code that is required on the client” is not actually what you’re suggesting. In any case I had to read the section three times to figure out what you really mean. I’m still not sure why importing anything close to ‘all’ code in the router would be advantageous, and what really needs to be imported.
My understanding is that after the (eagerly loaded) startup, the router – for all intents and purposes – forms the ‘root node’ of the app, from which other files are, at least in principle, lazily loaded. So it makes sense for the router to know about other layouts and pages that are directly accessible via routes. Is that the extent for files that should be imported here, or have I missed something?