Open
Description
Describe the feature
An API for asset bundling to hook into the watch/hotswap feature to create an incremental build of the asset.
Use Case
Asset bundling can be expensive. While some providers (e.g. Docker) already use an internal cache to build increments, not all do and it is the responsibility of the provider to store state.
A concrete would be bundling a lambda function with esbuild. This could use esbuild's native watch feature to update assets instead of always doing a full build. Or it could rely on CDKs file watcher, but trigger a rebuild when one of its files changed.
Proposed Solution
Maybe two variations
// Uses a custom file watcher implementation and does an incremental update
// will callback to the CDK watch context when an update has occurred
interface WatchingAsset {
startWatching(context) {
// watch files & update when needed
// then inform the CDK watch context
context.updated(/* data */);
}
// Has a well known method that can register interests with the global CDK watcher
interface IncrementalAsset {
gatherInterest(context) {
watchProvider.registerInterest('handler/**/*.ts');
}
// this is called when ever a rebuild is needed
rebuild(changeDetails) {
// do the incremental rebuild here
}
}
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
n/a
Environment details (OS name and version, etc.)
n/a