function ensureWatchedFile(watcher, file, root) {
	if (
		file &&
		// only need to watch if out of root
		!file.startsWith(root + '/') &&
		// some rollup plugins use null bytes for private resolved Ids
		!file.includes('\0') &&
		fs.existsSync(file)
	) {
		// resolve file to normalized system path
		watcher.add(path.resolve(file));
	}
}
taken from vite utils
@param {import('vite').FSWatcher} watcher
@param {string | null} file
@param {string} root
@returns {void}