Registry / devops / rollup-plugin-watch

rollup-plugin-watch

JSON →
library1.0.5jsnpmunverified

A Rollup plugin to specify additional directories and files for Rollup to watch during dev mode, complementing Rollup's built-in watch mechanism. Version 1.0.5 (stable) requires Node >=16 and peer dependency rollup ^2.x.x || ^3.x.x || ^4.x.x. It ships TypeScript definitions. Key differentiator: allows watching external assets not imported in code, preventing unnecessary dev server restarts. Low maintenance, minimal API surface (dir, include, exclude).

npm install rollup-plugin-watch
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WATC
R
rollup-plugin-watch
devopsjavascriptv1.0.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (watch function)
import watch from 'rollup-plugin-watch'
import { watch } from 'rollup-plugin-watch'
Package uses default export; named export does not exist
CommonJS require
const watch = require('rollup-plugin-watch')
const { watch } = require('rollup-plugin-watch')
CJS works with default export
TypeScript type import
import type { RollupWatchOptions } from 'rollup-plugin-watch'
import { RollupWatchOptions } from 'rollup-plugin-watch'
Types are exported but not as runtime values; use type-only import

Shows basic usage: watch a directory with include/exclude patterns for non-imported assets.

import watch from 'rollup-plugin-watch'; export default { input: 'index.js', output: { file: 'dist/index.js', format: 'esm' }, plugins: [ watch({ dir: 'public', include: ['**/*.html', '**/*.css'], exclude: ['node_modules/**'] }) ] };
Debug
Known issues
gotchaThe `dir` option does not recursively watch subdirectories by default; you must use `include` with glob patterns for deeper watches.
fix
Set include: ['**/*'] to watch all files recursively within the directory.
affects: >=1.0.0
deprecatedOptions `include` and `exclude` were originally strings; array support added later. Using a string still works but is deprecated in favor of arrays.
fix
Use arrays: include: ['file1', 'file2'] instead of include: 'file1'.
affects: >=1.0.0
gotchaThis plugin only notifies Rollup to watch files; it does not trigger builds on file changes outside Rollup's watch mode.
fix
Ensure Rollup is running in watch mode (e.g., rollup -w) for the plugin to have any effect.
affects: >=1.0.0
gotchaThe plugin has no effect on builds (non-watch mode); it is solely for development with Rollup's watcher.
fix
Only use in development configurations; do not expect it to work in build-only scripts.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-watch'
Package not installed or wrong import path.
fix
Run npm install rollup-plugin-watch --save-dev and ensure the import uses default import.
TypeError: watch is not a function
Using named import { watch } instead of default import.
fix
Change import to: import watch from 'rollup-plugin-watch'.
The watch option 'dir' must be a string
Passing a non-string value (e.g., array or object) to dir.
fix
Set dir to a single directory path as a string: dir: 'public'.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required for plugin to work
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-watch — npm install rollup-plugin-watch · libregistry