@ms-cloudpack/bundler
This library provides Cloudpack's implementation of an abstraction on bundling a package, assuming that the package is conformant.
Rather than directly depending on Webpack, rollup, or esbuild with large amounts of custom configuration, having an abstraction around bundling provides constraints around having common inputs/outputs.
This enforces the code follow consistent constraints, while also ensuring the output can be consumed in the browser or in node depending on supported environments.
Abstraction also allows us to use the right tool for the job. The right tool depends on priorities and capabilities. For dev builds we want the fastest tool, while for production we want optimal output.
Details
The Cloudpack bundler abstraction is simple and constrained on purpose:
- Consume a standard package (app or library) with a minimum set of requirements.
- Emits standard ESM bundle.
- Leverages package.json and convention as much as possible:
There are three output modes:
- library mode - produces a bundle of source which externalizes dependencies and is directly consumable by the target (browser or node), which can resolve the dependencies through an import map in the browser or through module resolution in node. The source is unminified.
- production mode - produces a bundle of minified source which includes dependencies and is also similarly consumed.
- development mode - like production mode, but not minified.