UNPKG

24.9 kBJavaScriptView Raw
1/*
2 @license
3 Rollup.js v2.55.1
4 Thu, 29 Jul 2021 15:46:34 GMT - commit 97759be7eacc11c4f7e4fdb9fada077279b363f3
5
6
7 https://github.com/rollup/rollup
8
9 Released under the MIT License.
10*/
11'use strict';
12
13var path = require('path');
14var require$$0 = require('util');
15var index = require('./index.js');
16var rollup = require('./rollup.js');
17var mergeOptions = require('./mergeOptions.js');
18var require$$2 = require('os');
19require('events');
20require('fs');
21require('stream');
22require('crypto');
23
24function _interopNamespaceDefault(e) {
25 var n = Object.create(null);
26 if (e) {
27 Object.keys(e).forEach(function (k) {
28 n[k] = e[k];
29 });
30 }
31 n['default'] = e;
32 return n;
33}
34
35var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
36
37const util = require$$0;
38const braces = index.braces_1;
39const picomatch = index.picomatch;
40const utils = index.utils;
41const isEmptyString = val => val === '' || val === './';
42
43/**
44 * Returns an array of strings that match one or more glob patterns.
45 *
46 * ```js
47 * const mm = require('micromatch');
48 * // mm(list, patterns[, options]);
49 *
50 * console.log(mm(['a.js', 'a.txt'], ['*.js']));
51 * //=> [ 'a.js' ]
52 * ```
53 * @param {String|Array<string>} `list` List of strings to match.
54 * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
55 * @param {Object} `options` See available [options](#options)
56 * @return {Array} Returns an array of matches
57 * @summary false
58 * @api public
59 */
60
61const micromatch = (list, patterns, options) => {
62 patterns = [].concat(patterns);
63 list = [].concat(list);
64
65 let omit = new Set();
66 let keep = new Set();
67 let items = new Set();
68 let negatives = 0;
69
70 let onResult = state => {
71 items.add(state.output);
72 if (options && options.onResult) {
73 options.onResult(state);
74 }
75 };
76
77 for (let i = 0; i < patterns.length; i++) {
78 let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
79 let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
80 if (negated) negatives++;
81
82 for (let item of list) {
83 let matched = isMatch(item, true);
84
85 let match = negated ? !matched.isMatch : matched.isMatch;
86 if (!match) continue;
87
88 if (negated) {
89 omit.add(matched.output);
90 } else {
91 omit.delete(matched.output);
92 keep.add(matched.output);
93 }
94 }
95 }
96
97 let result = negatives === patterns.length ? [...items] : [...keep];
98 let matches = result.filter(item => !omit.has(item));
99
100 if (options && matches.length === 0) {
101 if (options.failglob === true) {
102 throw new Error(`No matches found for "${patterns.join(', ')}"`);
103 }
104
105 if (options.nonull === true || options.nullglob === true) {
106 return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
107 }
108 }
109
110 return matches;
111};
112
113/**
114 * Backwards compatibility
115 */
116
117micromatch.match = micromatch;
118
119/**
120 * Returns a matcher function from the given glob `pattern` and `options`.
121 * The returned function takes a string to match as its only argument and returns
122 * true if the string is a match.
123 *
124 * ```js
125 * const mm = require('micromatch');
126 * // mm.matcher(pattern[, options]);
127 *
128 * const isMatch = mm.matcher('*.!(*a)');
129 * console.log(isMatch('a.a')); //=> false
130 * console.log(isMatch('a.b')); //=> true
131 * ```
132 * @param {String} `pattern` Glob pattern
133 * @param {Object} `options`
134 * @return {Function} Returns a matcher function.
135 * @api public
136 */
137
138micromatch.matcher = (pattern, options) => picomatch(pattern, options);
139
140/**
141 * Returns true if **any** of the given glob `patterns` match the specified `string`.
142 *
143 * ```js
144 * const mm = require('micromatch');
145 * // mm.isMatch(string, patterns[, options]);
146 *
147 * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
148 * console.log(mm.isMatch('a.a', 'b.*')); //=> false
149 * ```
150 * @param {String} `str` The string to test.
151 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
152 * @param {Object} `[options]` See available [options](#options).
153 * @return {Boolean} Returns true if any patterns match `str`
154 * @api public
155 */
156
157micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
158
159/**
160 * Backwards compatibility
161 */
162
163micromatch.any = micromatch.isMatch;
164
165/**
166 * Returns a list of strings that _**do not match any**_ of the given `patterns`.
167 *
168 * ```js
169 * const mm = require('micromatch');
170 * // mm.not(list, patterns[, options]);
171 *
172 * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
173 * //=> ['b.b', 'c.c']
174 * ```
175 * @param {Array} `list` Array of strings to match.
176 * @param {String|Array} `patterns` One or more glob pattern to use for matching.
177 * @param {Object} `options` See available [options](#options) for changing how matches are performed
178 * @return {Array} Returns an array of strings that **do not match** the given patterns.
179 * @api public
180 */
181
182micromatch.not = (list, patterns, options = {}) => {
183 patterns = [].concat(patterns).map(String);
184 let result = new Set();
185 let items = [];
186
187 let onResult = state => {
188 if (options.onResult) options.onResult(state);
189 items.push(state.output);
190 };
191
192 let matches = micromatch(list, patterns, { ...options, onResult });
193
194 for (let item of items) {
195 if (!matches.includes(item)) {
196 result.add(item);
197 }
198 }
199 return [...result];
200};
201
202/**
203 * Returns true if the given `string` contains the given pattern. Similar
204 * to [.isMatch](#isMatch) but the pattern can match any part of the string.
205 *
206 * ```js
207 * var mm = require('micromatch');
208 * // mm.contains(string, pattern[, options]);
209 *
210 * console.log(mm.contains('aa/bb/cc', '*b'));
211 * //=> true
212 * console.log(mm.contains('aa/bb/cc', '*d'));
213 * //=> false
214 * ```
215 * @param {String} `str` The string to match.
216 * @param {String|Array} `patterns` Glob pattern to use for matching.
217 * @param {Object} `options` See available [options](#options) for changing how matches are performed
218 * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
219 * @api public
220 */
221
222micromatch.contains = (str, pattern, options) => {
223 if (typeof str !== 'string') {
224 throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
225 }
226
227 if (Array.isArray(pattern)) {
228 return pattern.some(p => micromatch.contains(str, p, options));
229 }
230
231 if (typeof pattern === 'string') {
232 if (isEmptyString(str) || isEmptyString(pattern)) {
233 return false;
234 }
235
236 if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
237 return true;
238 }
239 }
240
241 return micromatch.isMatch(str, pattern, { ...options, contains: true });
242};
243
244/**
245 * Filter the keys of the given object with the given `glob` pattern
246 * and `options`. Does not attempt to match nested keys. If you need this feature,
247 * use [glob-object][] instead.
248 *
249 * ```js
250 * const mm = require('micromatch');
251 * // mm.matchKeys(object, patterns[, options]);
252 *
253 * const obj = { aa: 'a', ab: 'b', ac: 'c' };
254 * console.log(mm.matchKeys(obj, '*b'));
255 * //=> { ab: 'b' }
256 * ```
257 * @param {Object} `object` The object with keys to filter.
258 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
259 * @param {Object} `options` See available [options](#options) for changing how matches are performed
260 * @return {Object} Returns an object with only keys that match the given patterns.
261 * @api public
262 */
263
264micromatch.matchKeys = (obj, patterns, options) => {
265 if (!utils.isObject(obj)) {
266 throw new TypeError('Expected the first argument to be an object');
267 }
268 let keys = micromatch(Object.keys(obj), patterns, options);
269 let res = {};
270 for (let key of keys) res[key] = obj[key];
271 return res;
272};
273
274/**
275 * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
276 *
277 * ```js
278 * const mm = require('micromatch');
279 * // mm.some(list, patterns[, options]);
280 *
281 * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
282 * // true
283 * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
284 * // false
285 * ```
286 * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
287 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
288 * @param {Object} `options` See available [options](#options) for changing how matches are performed
289 * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
290 * @api public
291 */
292
293micromatch.some = (list, patterns, options) => {
294 let items = [].concat(list);
295
296 for (let pattern of [].concat(patterns)) {
297 let isMatch = picomatch(String(pattern), options);
298 if (items.some(item => isMatch(item))) {
299 return true;
300 }
301 }
302 return false;
303};
304
305/**
306 * Returns true if every string in the given `list` matches
307 * any of the given glob `patterns`.
308 *
309 * ```js
310 * const mm = require('micromatch');
311 * // mm.every(list, patterns[, options]);
312 *
313 * console.log(mm.every('foo.js', ['foo.js']));
314 * // true
315 * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
316 * // true
317 * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
318 * // false
319 * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
320 * // false
321 * ```
322 * @param {String|Array} `list` The string or array of strings to test.
323 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
324 * @param {Object} `options` See available [options](#options) for changing how matches are performed
325 * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
326 * @api public
327 */
328
329micromatch.every = (list, patterns, options) => {
330 let items = [].concat(list);
331
332 for (let pattern of [].concat(patterns)) {
333 let isMatch = picomatch(String(pattern), options);
334 if (!items.every(item => isMatch(item))) {
335 return false;
336 }
337 }
338 return true;
339};
340
341/**
342 * Returns true if **all** of the given `patterns` match
343 * the specified string.
344 *
345 * ```js
346 * const mm = require('micromatch');
347 * // mm.all(string, patterns[, options]);
348 *
349 * console.log(mm.all('foo.js', ['foo.js']));
350 * // true
351 *
352 * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
353 * // false
354 *
355 * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
356 * // true
357 *
358 * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
359 * // true
360 * ```
361 * @param {String|Array} `str` The string to test.
362 * @param {String|Array} `patterns` One or more glob patterns to use for matching.
363 * @param {Object} `options` See available [options](#options) for changing how matches are performed
364 * @return {Boolean} Returns true if any patterns match `str`
365 * @api public
366 */
367
368micromatch.all = (str, patterns, options) => {
369 if (typeof str !== 'string') {
370 throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
371 }
372
373 return [].concat(patterns).every(p => picomatch(p, options)(str));
374};
375
376/**
377 * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
378 *
379 * ```js
380 * const mm = require('micromatch');
381 * // mm.capture(pattern, string[, options]);
382 *
383 * console.log(mm.capture('test/*.js', 'test/foo.js'));
384 * //=> ['foo']
385 * console.log(mm.capture('test/*.js', 'foo/bar.css'));
386 * //=> null
387 * ```
388 * @param {String} `glob` Glob pattern to use for matching.
389 * @param {String} `input` String to match
390 * @param {Object} `options` See available [options](#options) for changing how matches are performed
391 * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
392 * @api public
393 */
394
395micromatch.capture = (glob, input, options) => {
396 let posix = utils.isWindows(options);
397 let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
398 let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
399
400 if (match) {
401 return match.slice(1).map(v => v === void 0 ? '' : v);
402 }
403};
404
405/**
406 * Create a regular expression from the given glob `pattern`.
407 *
408 * ```js
409 * const mm = require('micromatch');
410 * // mm.makeRe(pattern[, options]);
411 *
412 * console.log(mm.makeRe('*.js'));
413 * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
414 * ```
415 * @param {String} `pattern` A glob pattern to convert to regex.
416 * @param {Object} `options`
417 * @return {RegExp} Returns a regex created from the given pattern.
418 * @api public
419 */
420
421micromatch.makeRe = (...args) => picomatch.makeRe(...args);
422
423/**
424 * Scan a glob pattern to separate the pattern into segments. Used
425 * by the [split](#split) method.
426 *
427 * ```js
428 * const mm = require('micromatch');
429 * const state = mm.scan(pattern[, options]);
430 * ```
431 * @param {String} `pattern`
432 * @param {Object} `options`
433 * @return {Object} Returns an object with
434 * @api public
435 */
436
437micromatch.scan = (...args) => picomatch.scan(...args);
438
439/**
440 * Parse a glob pattern to create the source string for a regular
441 * expression.
442 *
443 * ```js
444 * const mm = require('micromatch');
445 * const state = mm(pattern[, options]);
446 * ```
447 * @param {String} `glob`
448 * @param {Object} `options`
449 * @return {Object} Returns an object with useful properties and output to be used as regex source string.
450 * @api public
451 */
452
453micromatch.parse = (patterns, options) => {
454 let res = [];
455 for (let pattern of [].concat(patterns || [])) {
456 for (let str of braces(String(pattern), options)) {
457 res.push(picomatch.parse(str, options));
458 }
459 }
460 return res;
461};
462
463/**
464 * Process the given brace `pattern`.
465 *
466 * ```js
467 * const { braces } = require('micromatch');
468 * console.log(braces('foo/{a,b,c}/bar'));
469 * //=> [ 'foo/(a|b|c)/bar' ]
470 *
471 * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
472 * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
473 * ```
474 * @param {String} `pattern` String with brace pattern to process.
475 * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
476 * @return {Array}
477 * @api public
478 */
479
480micromatch.braces = (pattern, options) => {
481 if (typeof pattern !== 'string') throw new TypeError('Expected a string');
482 if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
483 return [pattern];
484 }
485 return braces(pattern, options);
486};
487
488/**
489 * Expand braces
490 */
491
492micromatch.braceExpand = (pattern, options) => {
493 if (typeof pattern !== 'string') throw new TypeError('Expected a string');
494 return micromatch.braces(pattern, { ...options, expand: true });
495};
496
497/**
498 * Expose micromatch
499 */
500
501var micromatch_1 = micromatch;
502
503var mm = micromatch_1;
504
505function ensureArray(thing) {
506 if (Array.isArray(thing))
507 return thing;
508 if (thing == undefined)
509 return [];
510 return [thing];
511}
512
513function getMatcherString(id, resolutionBase) {
514 if (resolutionBase === false) {
515 return id;
516 }
517 return path.resolve(...(typeof resolutionBase === 'string' ? [resolutionBase, id] : [id]));
518}
519const createFilter = function createFilter(include, exclude, options) {
520 const resolutionBase = options && options.resolve;
521 const getMatcher = (id) => {
522 return id instanceof RegExp
523 ? id
524 : {
525 test: mm.matcher(getMatcherString(id, resolutionBase)
526 .split(path.sep)
527 .join('/'), { dot: true })
528 };
529 };
530 const includeMatchers = ensureArray(include).map(getMatcher);
531 const excludeMatchers = ensureArray(exclude).map(getMatcher);
532 return function (id) {
533 if (typeof id !== 'string')
534 return false;
535 if (/\0/.test(id))
536 return false;
537 id = id.split(path.sep).join('/');
538 for (let i = 0; i < excludeMatchers.length; ++i) {
539 const matcher = excludeMatchers[i];
540 if (matcher.test(id))
541 return false;
542 }
543 for (let i = 0; i < includeMatchers.length; ++i) {
544 const matcher = includeMatchers[i];
545 if (matcher.test(id))
546 return true;
547 }
548 return !includeMatchers.length;
549 };
550};
551
552class FileWatcher {
553 constructor(task, chokidarOptions) {
554 this.transformWatchers = new Map();
555 this.chokidarOptions = chokidarOptions;
556 this.task = task;
557 this.watcher = this.createWatcher(null);
558 }
559 close() {
560 this.watcher.close();
561 for (const watcher of this.transformWatchers.values()) {
562 watcher.close();
563 }
564 }
565 unwatch(id) {
566 this.watcher.unwatch(id);
567 const transformWatcher = this.transformWatchers.get(id);
568 if (transformWatcher) {
569 this.transformWatchers.delete(id);
570 transformWatcher.close();
571 }
572 }
573 watch(id, isTransformDependency) {
574 if (isTransformDependency) {
575 const watcher = this.transformWatchers.get(id) || this.createWatcher(id);
576 watcher.add(id);
577 this.transformWatchers.set(id, watcher);
578 }
579 else {
580 this.watcher.add(id);
581 }
582 }
583 createWatcher(transformWatcherId) {
584 const task = this.task;
585 const isLinux = require$$2.platform() === 'linux';
586 const isTransformDependency = transformWatcherId !== null;
587 const handleChange = (id, event) => {
588 const changedId = transformWatcherId || id;
589 if (isLinux) {
590 // unwatching and watching fixes an issue with chokidar where on certain systems,
591 // a file that was unlinked and immediately recreated would create a change event
592 // but then no longer any further events
593 watcher.unwatch(changedId);
594 watcher.add(changedId);
595 }
596 task.invalidate(changedId, { event, isTransformDependency });
597 };
598 const watcher = index.chokidar
599 .watch([], this.chokidarOptions)
600 .on('add', id => handleChange(id, 'create'))
601 .on('change', id => handleChange(id, 'update'))
602 .on('unlink', id => handleChange(id, 'delete'));
603 return watcher;
604 }
605}
606
607const eventsRewrites = {
608 create: {
609 create: 'buggy',
610 delete: null,
611 update: 'create'
612 },
613 delete: {
614 create: 'update',
615 delete: 'buggy',
616 update: 'buggy'
617 },
618 update: {
619 create: 'buggy',
620 delete: 'delete',
621 update: 'update'
622 }
623};
624class Watcher {
625 constructor(configs, emitter) {
626 this.buildDelay = 0;
627 this.buildTimeout = null;
628 this.invalidatedIds = new Map();
629 this.rerun = false;
630 this.emitter = emitter;
631 emitter.close = this.close.bind(this);
632 this.tasks = configs.map(config => new Task(this, config));
633 this.buildDelay = configs.reduce((buildDelay, { watch }) => watch && typeof watch.buildDelay === 'number'
634 ? Math.max(buildDelay, watch.buildDelay)
635 : buildDelay, this.buildDelay);
636 this.running = true;
637 process.nextTick(() => this.run());
638 }
639 close() {
640 if (this.buildTimeout)
641 clearTimeout(this.buildTimeout);
642 for (const task of this.tasks) {
643 task.close();
644 }
645 this.emitter.emit('close');
646 this.emitter.removeAllListeners();
647 }
648 invalidate(file) {
649 if (file) {
650 const prevEvent = this.invalidatedIds.get(file.id);
651 const event = prevEvent ? eventsRewrites[prevEvent][file.event] : file.event;
652 if (event === 'buggy') {
653 //TODO: throws or warn? Currently just ignore, uses new event
654 this.invalidatedIds.set(file.id, file.event);
655 }
656 else if (event === null) {
657 this.invalidatedIds.delete(file.id);
658 }
659 else {
660 this.invalidatedIds.set(file.id, event);
661 }
662 }
663 if (this.running) {
664 this.rerun = true;
665 return;
666 }
667 if (this.buildTimeout)
668 clearTimeout(this.buildTimeout);
669 this.buildTimeout = setTimeout(() => {
670 this.buildTimeout = null;
671 for (const [id, event] of this.invalidatedIds.entries()) {
672 this.emitter.emit('change', id, { event });
673 }
674 this.invalidatedIds.clear();
675 this.emitter.emit('restart');
676 this.run();
677 }, this.buildDelay);
678 }
679 async run() {
680 this.running = true;
681 this.emitter.emit('event', {
682 code: 'START'
683 });
684 for (const task of this.tasks) {
685 await task.run();
686 }
687 this.running = false;
688 this.emitter.emit('event', {
689 code: 'END'
690 });
691 if (this.rerun) {
692 this.rerun = false;
693 this.invalidate();
694 }
695 }
696}
697class Task {
698 constructor(watcher, config) {
699 this.cache = { modules: [] };
700 this.watchFiles = [];
701 this.invalidated = true;
702 this.watcher = watcher;
703 this.closed = false;
704 this.watched = new Set();
705 this.skipWrite = Boolean(config.watch && config.watch.skipWrite);
706 this.options = mergeOptions.mergeOptions(config);
707 this.outputs = this.options.output;
708 this.outputFiles = this.outputs.map(output => {
709 if (output.file || output.dir)
710 return path__namespace.resolve(output.file || output.dir);
711 return undefined;
712 });
713 const watchOptions = this.options.watch || {};
714 this.filter = createFilter(watchOptions.include, watchOptions.exclude);
715 this.fileWatcher = new FileWatcher(this, {
716 ...watchOptions.chokidar,
717 disableGlobbing: true,
718 ignoreInitial: true
719 });
720 }
721 close() {
722 this.closed = true;
723 this.fileWatcher.close();
724 }
725 invalidate(id, details) {
726 this.invalidated = true;
727 if (details.isTransformDependency) {
728 for (const module of this.cache.modules) {
729 if (module.transformDependencies.indexOf(id) === -1)
730 continue;
731 // effective invalidation
732 module.originalCode = null;
733 }
734 }
735 this.watcher.invalidate({ event: details.event, id });
736 }
737 async run() {
738 if (!this.invalidated)
739 return;
740 this.invalidated = false;
741 const options = {
742 ...this.options,
743 cache: this.cache
744 };
745 const start = Date.now();
746 this.watcher.emitter.emit('event', {
747 code: 'BUNDLE_START',
748 input: this.options.input,
749 output: this.outputFiles
750 });
751 let result = null;
752 try {
753 result = await rollup.rollupInternal(options, this.watcher.emitter);
754 if (this.closed) {
755 return;
756 }
757 this.updateWatchedFiles(result);
758 this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
759 this.watcher.emitter.emit('event', {
760 code: 'BUNDLE_END',
761 duration: Date.now() - start,
762 input: this.options.input,
763 output: this.outputFiles,
764 result
765 });
766 }
767 catch (error) {
768 if (!this.closed) {
769 if (Array.isArray(error.watchFiles)) {
770 for (const id of error.watchFiles) {
771 this.watchFile(id);
772 }
773 }
774 if (error.id) {
775 this.cache.modules = this.cache.modules.filter(module => module.id !== error.id);
776 }
777 }
778 this.watcher.emitter.emit('event', {
779 code: 'ERROR',
780 error,
781 result
782 });
783 }
784 }
785 updateWatchedFiles(result) {
786 const previouslyWatched = this.watched;
787 this.watched = new Set();
788 this.watchFiles = result.watchFiles;
789 this.cache = result.cache;
790 for (const id of this.watchFiles) {
791 this.watchFile(id);
792 }
793 for (const module of this.cache.modules) {
794 for (const depId of module.transformDependencies) {
795 this.watchFile(depId, true);
796 }
797 }
798 for (const id of previouslyWatched) {
799 if (!this.watched.has(id)) {
800 this.fileWatcher.unwatch(id);
801 }
802 }
803 }
804 watchFile(id, isTransformDependency = false) {
805 if (!this.filter(id))
806 return;
807 this.watched.add(id);
808 if (this.outputFiles.some(file => file === id)) {
809 throw new Error('Cannot import the generated bundle');
810 }
811 // this is necessary to ensure that any 'renamed' files
812 // continue to be watched following an error
813 this.fileWatcher.watch(id, isTransformDependency);
814 }
815}
816
817exports.Task = Task;
818exports.Watcher = Watcher;
819//# sourceMappingURL=watch.js.map