bundle more stuff

This commit is contained in:
Rich Harris
2018-08-19 16:15:04 -04:00
parent dba83641e4
commit e0d533f2ea
9 changed files with 35 additions and 36 deletions

View File

@@ -454,19 +454,23 @@ class DevServer {
function noop() {}
function watch_files(pattern: string, events: string[], callback: () => void) {
const chokidar = require('chokidar');
let watcher;
const watcher = chokidar.watch(pattern, {
persistent: true,
ignoreInitial: true,
disableGlobbing: true
});
import('chokidar').then(({ default: chokidar }) => {
if (closed) return;
events.forEach(event => {
watcher.on(event, callback);
watcher = chokidar.watch(pattern, {
persistent: true,
ignoreInitial: true,
disableGlobbing: true
});
events.forEach(event => {
watcher.on(event, callback);
});
});
return {
close: () => watcher.close()
close: () => watcher && watcher.close()
};
}