Variable: watch()
ts
const watch: (input) => RolldownWatcherDefined in: node_modules/.pnpm/rolldown@1.0.0-rc.1/node_modules/rolldown/dist/shared/define-config-DO4TBkJV.d.mts:1292
Experimental
The API compatible with Rollup's watch function.
This function will rebuild the bundle when it detects that the individual modules have changed on disk.
Note that when using this function, it is your responsibility to call event.result.close() in response to the BUNDLE_END event to avoid resource leaks.
Parameters
input
The watch options object or the list of them.
Returns
A watcher object.
Example
js
import { watch } from 'rolldown'
const watcher = watch({
/* ... */
})
watcher.on('event', (event) => {
if (event.code === 'BUNDLE_END') {
console.log(event.duration)
event.result.close()
}
})
// Stop watching
watcher.close()