Skip to content

Watch mode issue collection #6482

@hyf0

Description

@hyf0

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

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(),
);

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

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:

To be investigated:

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions