Registry / devops / rollup-plugin-watch-globs

rollup-plugin-watch-globs

JSON →
library2.0.1jsnpmunverified

A Rollup plugin that extends the watch mode to monitor arbitrary file globs (e.g., static assets, stylesheets, HTML) not in the module graph. Currently v2.0.1, maintained by Caleb Evans. Key differentiator: unlike relying on Rollup's default watch (which only tracks JS/TS files in the dependency graph), this plugin explicitly adds glob patterns to trigger rebuilds, complementing tools like rollup-plugin-copy. Released under MIT License, requires rollup >=2.0.0 as a peer dependency. A lightweight, focused solution with no runtime dependencies beyond rollup.

npm install rollup-plugin-watch-globs
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-WATC
R
rollup-plugin-watch-globs
devopsjavascriptv2.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

watchGlobs
✓ import watchGlobs from 'rollup-plugin-watch-globs'
✗ const watchGlobs = require('rollup-plugin-watch-globs')
Default ESM export. CommonJS require() works only if package supports dual CJS/ESM; check your Rollup config's format.
watchGlobs
✓ const watchGlobs = require('rollup-plugin-watch-globs').default
✗ const watchGlobs = require('rollup-plugin-watch-globs')
In CommonJS, you must use .default because the package exports an ESM default.
rollup.config.js
✓ plugins: [watchGlobs([ 'public/**/*.*', 'src/styles/*.scss' ])]
✗ plugins: [watchGlobs({ patterns: [...] })]
The function accepts an array of glob strings, not an options object.

Shows how to import and configure watchGlobs with two glob patterns to watch static assets and stylesheets.

// rollup.config.js import watchGlobs from 'rollup-plugin-watch-globs'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ watchGlobs([ 'public/**/*.*', 'src/styles/*.scss' ]) ] };
Debug
Known issues
gotchaGlob patterns must be provided as an array of strings, not an object or single string.
fix
Ensure the argument is an array: watchGlobs(['**/*.css'])
affects: >=1.0.0
gotchaThis plugin only adds file watching; it does not handle actual copying or processing of watched files (use e.g., rollup-plugin-copy).
fix
Combine with appropriate plugins for actions on change.
affects: >=1.0.0
breakingv2.x changed the default export to be a callable function; previously it might have been a factory or object.
fix
Use import watchGlobs from 'rollup-plugin-watch-globs' and call it directly.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: watchGlobs is not a function
Incorrect import style (CommonJS without .default or wrong ESM import).
fix
Use: import watchGlobs from 'rollup-plugin-watch-globs' (ESM) or const watchGlobs = require('rollup-plugin-watch-globs').default (CJS).
Error: The 'watchGlobs' plugin hook 'watchChange' threw an error: Unexpected glob pattern
Passed a string instead of an array of strings.
fix
Wrap glob pattern in an array: watchGlobs(['public/**/*.*'])
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
rolluprequiredpeer dependency >=2.0.0
Agent activity
4 hits · last 30 days
node
4
Resources