Why does bundle include source files and other non-runtime dependent files in the project? #98
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Hey @fourpastmidnight 👋 I think you've found a spot with the documentation that needs more work. Yarn's workspace feature (having multiple local packages), is a really powerful tool for code sharing. It allows you to break up your application, while sharing common code, in the same way as if that code was pushed to npm. Except it can stay local to the monorepo, and can be versioned with everything else. When you run a The In the past with Imagine you have a monorepo with 10 lambdas/nodejs apps/microservices in it, and they all shared a bunch of code. Each package will have a different dependency graph, and wont need everything in the repo. So we can create a separate bundle for each. In contrast, when building and distributing to the web we often collapse everything into a single file. Or more recently, a collection of files.
The initial reason for this was that I typically build and deploy lambdas from CI, and so other release artifacts were not caught up in the final bundles. However, it's something that should be configurable, and at the very least should read the existing The other The intent of
Yep that's precisely the problem
You'd need to copy the
Yep sounds like you might not have copied everything you needed. You need all of
Just on this, it's helpful to control these. Either with
This sounds like a feature to add. I often write a lot of TypeScript code, and for packages that are shared I don't always compile then, instead just pointing I think we would need to add a per package config for folders to remove for the bundle, because it's not easy to know if a script in your output folder wants to reach into
Some of the plugins could be, though perhaps an option to clear them out might be useful. As an example, there's a plugin in this repo to allow you to use But mainly,
The That's not to say how you're doing it is wrong, just it's a different approach. I'd argue that having a different command for each package to build makes moving between packages hard for developers new to the project, and that anything that needs to be in the environment for build, should likely be passed in instead at runtime. The only exception to that would be Though also, You can add a The last part behind the philosophy here, is that you should build one artifact, test it, deploy it to dev, test it there, maybe run integration tests, then deploy it to production. The actual artifact never changes, giving you a higher confidence it will succeed in production. Then, the only things that change per environment are ENV vars, secrets (which should always be passed at runtime), and the state of feature flags. However, that may not be suitable for how your repository is setup. Which doesn't mean how you've setup is wrong, just it's different to what I think |
Beta Was this translation helpful? Give feedback.
-
We recently adding this feature 🚀 in #112 You can now set files to be ignored when bundling. Add a .bundleignore file with the same format as .gitignore next to the package.json you are bundling. Optionally put one next to your root package.json to apply to all bundles. You can pass --ignore-file to specify a different ignore file. Or decide at bundle time what to ignore by passing --exclude along with the file path to ignore. |
Beta Was this translation helpful? Give feedback.
We recently adding this feature 🚀 in #112
You can now set files to be ignored when bundling.
Add a .bundleignore file with the same format as .gitignore next to the package.json you are bundling.
Optionally put one next to your root package.json to apply to all bundles.
You can pass --ignore-file to specify a different ignore file.
Or decide at bundle time what to ignore by passing --exclude along with the file path to ignore.