We split code along three lines:
First, we defer loading the bulk of the application until after login. The login page loads the bits it needs along with all the router files. The router files use dynamic imports for anything their endpoints need. Given a successful login, the app imports code supporting the homepage and feed. Deeper elements get loaded as users drill deeper into the app.
This approach defers loading app-level code but the packages still are all loaded with the login page. Excepting the below, we have yet to find a way to defer loading of packages. While there might be 1-2 that that login does not need, it’s low priority for us because those that it does are the overwhelming majority of the codebase that lives in packages.
Second, we have enduser and admin/console sides to our application. The who, what and how for these is quite different. Importantly, the admin console is not part of our Cordova app so we don’t want all that code in there. Thus we split the code by building separate servers that apply different packages too. They of course point to the same Mongo and file store. Users can hop between the servers thanks to Meteor documentation.
@rjdavid is of course very right. All of your code – in our case all enduser code – is shipped with the Cordova app and served by a device-resident localhost. Hot code push (HCP) is refreshing that code, that served by the localhost, so it is pushing everything including anything referenced by dynamic import (hence why dynamic imports can’t use variables). While this is a large download, it certainly beats the alternatives
Finally, we support white-labeling. As this is just reskinning the app, we don’t build separate servers for it. We use subdomain to identify a white-labeled request and then SSR to inject the CSS. White-labeling takes a little more though – in particular, you need different localhost port numbers and Meteor’s SSR does not support HCP. The latter requires using SSR client-side, i.e. not in the localhost but rather applying the client-side call the package makes available.
Wow – aren’t I chatty this morning? Regardless, I hope that helps.