I’m not sure how many people know that with Meteor apps, packages put in your devDependencies are never put into your server-side bundle, but will be put in your client-side bundle.
With larger projects, this can lead to much smaller build times, as your server-bundle will be much smaller.
In our team, we haven’t always added packages properly, and so now I’m trying to clean this up and move lots of client-only dependencies into devDependencies.
Does someone know of a quick way to find these packages that could safely be moved into devDependencies because the server-bundle never imports them anywhere? That would speed up this process, and could maybe even help out a lot of other Meteor projects!
@znewsham I can’t find the source for this, but this is how meteor was optimized in the past. When the client bundle needed a package from devDependencies, instead of crashing at build-time, they decided to include the package in the production bundle for simplicity. You can easily verify this with a starter meteor app.
@superfail Have you tried this yourself? How would you use recast with a meteor code-base (and handling the server/client split)?
@afrokick Very interesting, though not trivial to do right!
I’m looking at the client bundle of an app with dev dependencies - and I can’t see any reference to those dependencies, in dev or prod -can you provide a concrete example? Most dev dependencies make no sense in the client bundle. I can’t think of a situation where the client should ever require a package from devDependencies
As far as I know, this is how most bundlers work - if a file is imported, the content of the file is included in the bundle regardless of if it is from a dev dependency or not. The server is different because Meteor copies the whole node_modules folder, excluding dev dependencies, instead of bundling the specific files imported.
This is the only use case I know of. It feels weird, but in some cases it can drastically speed up deploying apps. I’ve done it in the past for a few projects, with several different bundlers.