Rollup Cannot call "addWatchFile" after the build has finished.
with manualChunks and build --watch
#13342
Closed
7 tasks done
Labels
Describe the bug
I am attempting to use Vite's filesystem watch functionality to dynamically rebuild the code I am working on in real time. In this case I prefer to use
build --watch
overdev
as it allows me to test my software specifically in the context of its backend, which is not written for Node.I specify manual chunks to Rollup, and expect that other downstream build tools handle it gracefully. Vite seems to modify the provided Rollup config before passing it onward, specifically inserting its own plugins before and after user-specified ones. In this case, the offending plugin appears to be
vite:ensure-watch
.In most cases,
vite:ensure-watch
is a no-op, which is why I assume this went unnoticed for so long. It acts only on proxy paths (path/to/dep.js?proxy
), such as CommonJS dependencies processed by@rollup/plugin-commonjs
. In those cases, it attempts to explicitly calladdWatchFile
on the base path.In my repro, I prescribe a simple CommonJS dependency that is resolved by Rollup. In my actual application, this is React, which is also loaded as a CommonJS module. Specifically, it gets tripped up trying to load
node_modules/react/index.js?commonjs-entry
whilereact
is in its own chunk.From what I can tell, this doesn't do anything in the best of cases? I would disable the plugin and move on if I could, but there doesn't appear to be any option. Commenting out the body of the plugin and making it a true no-op doesn't affect filesystem watch functionality. Is this a holdover from a fix for an upstream bug? I believe simply removing the plugin would be an adequate fix, although I would love to hear from the team about
vite:ensure-watch
's purpose.Reproduction
https://stackblitz.com/edit/vitejs-vite-np1h8f
Steps to reproduce
npm i
npx vite build --watch
System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: