-
Notifications
You must be signed in to change notification settings - Fork 700
Description
Just for recording. It will be helpful once we want to polish current watch mode implementation in the future.
Refs:
Close mechanism in watch mode
| bundler.reset_closed_for_watch_mode(); |
is useless becuase bundler.is_closed never gets changed to true in watch mode. watch mode doesn't call Bundler#close in any circumstance.
The current watch implemntation will hang if we use smaller thread numbers
We now use a workaround to solve it.
Watch mode does not handle errors in options hook and causes promise rejections
rolldown/packages/rolldown/src/api/watch/watcher.ts
Lines 58 to 67 in e1bc3f7
| const bundlerOptions = await Promise.all( | |
| options | |
| .map((option) => | |
| arraify(option.output || {}).map(async (output) => { | |
| const inputOptions = await PluginDriver.callOptionsHook(option, true); | |
| return createBundlerOptions(inputOptions, output, true); | |
| }) | |
| ) | |
| .flat(), | |
| ); |
rolldown/packages/rolldown/src/api/watch/index.ts
Lines 6 to 12 in e1bc3f7
| export const watch = ( | |
| input: WatchOptions | WatchOptions[], | |
| ): RolldownWatcher => { | |
| const emitter = new WatcherEmitter(); | |
| createWatcher(emitter, input); | |
| return emitter; | |
| }; |
The
await is missing for createWatcher() call. (we cannot solve it by adding await because watch() should be sync)
Some watch events want to access RolldownBuild instance
rolldown/crates/rolldown_binding/src/types/binding_watcher_event.rs
Lines 87 to 99 in 02474da
| pub struct BindingBundleEndEventData { | |
| pub output: String, | |
| pub duration: u32, | |
| result: Arc<Mutex<Bundler>>, | |
| } | |
| #[napi] | |
| impl BindingBundleEndEventData { | |
| #[napi(getter)] | |
| pub fn result(&self) -> crate::binding_bundler_impl::BindingBundlerImpl { | |
| crate::binding_bundler_impl::BindingBundlerImpl::new_with_bundler(Arc::clone(&self.result)) | |
| } | |
| } |
Unlike RollupBuild, RolldownBuild will issue an build/bundle for each write/generate, while RollupBuild itself is a reusable build/bundle and could call write/generate multiple times. With this fundamental difference, I think it's hard to support similar functionality that rollup did in the watch mode.
Refs:
- [Bug]: due to the smaller
max_blocking_threadsvalue, the build hangs in watch mode #6393 - perf(cli): advance
createTokioRuntime#6618
To be investigated:
- [Bug]: Can't exit process at watch-cli close test #2584
- [Bug]: Watcher does not handle swapfiles #2634, [Bug]: Watch runs once on save on Linux #6846
- [Bug]:
watchAPI does not work on StackBlitz #2778 - Watch mode bugs in wasm #5051
Watchershould construct the bundler within itself instead of take it from outside #6931- --watch mode does not work #7759
- resolver cache is not cleared