This is an experiment in writing a plugin for Rollup that dynamically
calculates inputs to the compiler based on the contents of the src
directory.
Currently, it seems that Rollup does not correctly watch for new files added to a
directory that is used in this.addWatchFile
. This was reported in #3704.
The rollup.config.js
in this repo has 2 plugins:
watchInputs
demonstrates the problemwatchInputsWorkaround
demonstrates a workaround using a custom watcher and a temp file
To reproduce the problem:
- Run the build in watch mode using
npm run watch
(orrollup -c -w
). You'll see the build output in thebuild
directory. - Now remove the
build
directory and add a new file to thesrc
directory. You should not see another build.
To fix this, swap the watchFiles
plugin for the watchFilesWorkaround
plugin
in rollup.config.js
. Re-run the test and you should see rebuilds when new
files are added to the src
directory.