rollup 2.7.5 → 2.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.7.5
4
- Wed, 29 Apr 2020 19:48:24 GMT - commit a2b48832de11ad38eacfeacad08ba4dfceecfe96
3
+ Rollup.js v2.7.6
4
+ Thu, 30 Apr 2020 18:55:10 GMT - commit 468010ba801b1e59573b6aa7319461a449aa43df
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.7.5
4
- Wed, 29 Apr 2020 19:48:24 GMT - commit a2b48832de11ad38eacfeacad08ba4dfceecfe96
3
+ Rollup.js v2.7.6
4
+ Thu, 30 Apr 2020 18:55:10 GMT - commit 468010ba801b1e59573b6aa7319461a449aa43df
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -13,7 +13,7 @@ import { createHash as createHash$1 } from 'crypto';
13
13
  import { writeFile as writeFile$1, readdirSync, mkdirSync, readFile as readFile$1, lstatSync, realpathSync } from 'fs';
14
14
  import { EventEmitter } from 'events';
15
15
 
16
- var version = "2.7.5";
16
+ var version = "2.7.6";
17
17
 
18
18
  // Reserved word lists for various dialects of the language
19
19
 
@@ -14832,7 +14832,9 @@ class Module {
14832
14832
  else if (variable instanceof ExportDefaultVariable) {
14833
14833
  variable = variable.getOriginalVariable();
14834
14834
  }
14835
- relevantDependencies.add(variable.module);
14835
+ if (variable.module) {
14836
+ relevantDependencies.add(variable.module);
14837
+ }
14836
14838
  }
14837
14839
  if (this.isEntryPoint || this.dynamicallyImportedBy.length > 0 || this.graph.preserveModules) {
14838
14840
  for (const exportName of [...this.getReexports(), ...this.getExports()]) {
@@ -14843,7 +14845,9 @@ class Module {
14843
14845
  else if (variable instanceof ExportDefaultVariable) {
14844
14846
  variable = variable.getOriginalVariable();
14845
14847
  }
14846
- relevantDependencies.add(variable.module);
14848
+ if (variable.module) {
14849
+ relevantDependencies.add(variable.module);
14850
+ }
14847
14851
  }
14848
14852
  }
14849
14853
  if (this.graph.treeshakingOptions) {
@@ -16517,7 +16521,7 @@ class Chunk$1 {
16517
16521
  else if (variable instanceof ExportDefaultVariable) {
16518
16522
  variable = variable.getOriginalVariable();
16519
16523
  }
16520
- if (variable.module.chunk !== this) {
16524
+ if (variable.module && variable.module.chunk !== this) {
16521
16525
  this.imports.add(variable);
16522
16526
  if (!(variable instanceof NamespaceVariable && this.graph.preserveModules) &&
16523
16527
  variable.module instanceof Module) {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.7.5
4
- Wed, 29 Apr 2020 19:48:24 GMT - commit a2b48832de11ad38eacfeacad08ba4dfceecfe96
3
+ Rollup.js v2.7.6
4
+ Thu, 30 Apr 2020 18:55:10 GMT - commit 468010ba801b1e59573b6aa7319461a449aa43df
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -3993,6 +3993,7 @@ const { promisify } = util;
3993
3993
  const readdir = promisify(fs.readdir);
3994
3994
  const stat = promisify(fs.stat);
3995
3995
  const lstat = promisify(fs.lstat);
3996
+ const realpath = promisify(fs.realpath);
3996
3997
 
3997
3998
  /**
3998
3999
  * @typedef {Object} EntryInfo
@@ -4090,11 +4091,7 @@ class ReaddirpStream extends Readable {
4090
4091
  this._rdOptions = { encoding: 'utf8', withFileTypes: this._isDirent };
4091
4092
 
4092
4093
  // Launch stream with one parent, the root dir.
4093
- try {
4094
- this.parents = [this._exploreDir(root, 1)];
4095
- } catch (error) {
4096
- this.destroy(error);
4097
- }
4094
+ this.parents = [this._exploreDir(root, 1)];
4098
4095
  this.reading = false;
4099
4096
  this.parent = undefined;
4100
4097
  }
@@ -4110,7 +4107,10 @@ class ReaddirpStream extends Readable {
4110
4107
  if (files.length > 0) {
4111
4108
  const slice = files.splice(0, batch).map(dirent => this._formatEntry(dirent, path));
4112
4109
  for (const entry of await Promise.all(slice)) {
4113
- if (this._isDirAndMatchesFilter(entry)) {
4110
+ if (this.destroyed) return;
4111
+
4112
+ const entryType = await this._getEntryType(entry);
4113
+ if (entryType === 'directory' && this._directoryFilter(entry)) {
4114
4114
  if (depth <= this._maxDepth) {
4115
4115
  this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
4116
4116
  }
@@ -4119,7 +4119,7 @@ class ReaddirpStream extends Readable {
4119
4119
  this.push(entry);
4120
4120
  batch--;
4121
4121
  }
4122
- } else if (this._isFileAndMatchesFilter(entry)) {
4122
+ } else if ((entryType === 'file' || this._includeAsFile(entry)) && this._fileFilter(entry)) {
4123
4123
  if (this._wantsFile) {
4124
4124
  this.push(entry);
4125
4125
  batch--;
@@ -4133,6 +4133,7 @@ class ReaddirpStream extends Readable {
4133
4133
  break;
4134
4134
  }
4135
4135
  this.parent = await parent;
4136
+ if (this.destroyed) return;
4136
4137
  }
4137
4138
  }
4138
4139
  } catch (error) {
@@ -4153,10 +4154,11 @@ class ReaddirpStream extends Readable {
4153
4154
  }
4154
4155
 
4155
4156
  async _formatEntry(dirent, path$1) {
4156
- const basename = this._isDirent ? dirent.name : dirent;
4157
- const fullPath = path.resolve(path.join(path$1, basename));
4158
- const entry = {path: path.relative(this._root, fullPath), fullPath, basename};
4157
+ let entry;
4159
4158
  try {
4159
+ const basename = this._isDirent ? dirent.name : dirent;
4160
+ const fullPath = path.resolve(path.join(path$1, basename));
4161
+ entry = {path: path.relative(this._root, fullPath), fullPath, basename};
4160
4162
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
4161
4163
  } catch (err) {
4162
4164
  this._onError(err);
@@ -4168,24 +4170,43 @@ class ReaddirpStream extends Readable {
4168
4170
  if (isNormalFlowError(err) && !this.destroyed) {
4169
4171
  this.emit('warn', err);
4170
4172
  } else {
4171
- throw err;
4173
+ this.destroy(err);
4172
4174
  }
4173
4175
  }
4174
4176
 
4175
- _isDirAndMatchesFilter(entry) {
4177
+ async _getEntryType(entry) {
4176
4178
  // entry may be undefined, because a warning or an error were emitted
4177
4179
  // and the statsProp is undefined
4178
4180
  const stats = entry && entry[this._statsProp];
4179
- return stats && stats.isDirectory() && this._directoryFilter(entry);
4181
+ if (!stats) {
4182
+ return;
4183
+ }
4184
+ if (stats.isFile()) {
4185
+ return 'file';
4186
+ }
4187
+ if (stats.isDirectory()) {
4188
+ return 'directory';
4189
+ }
4190
+ if (stats && stats.isSymbolicLink()) {
4191
+ try {
4192
+ const entryRealPath = await realpath(entry.fullPath);
4193
+ const entryRealPathStats = await lstat(entryRealPath);
4194
+ if (entryRealPathStats.isFile()) {
4195
+ return 'file';
4196
+ }
4197
+ if (entryRealPathStats.isDirectory()) {
4198
+ return 'directory';
4199
+ }
4200
+ } catch (error) {
4201
+ this._onError(error);
4202
+ }
4203
+ }
4180
4204
  }
4181
4205
 
4182
- _isFileAndMatchesFilter(entry) {
4206
+ _includeAsFile(entry) {
4183
4207
  const stats = entry && entry[this._statsProp];
4184
- const isFileType = stats && (
4185
- (this._wantsEverything && !stats.isDirectory()) ||
4186
- (stats.isFile() || stats.isSymbolicLink())
4187
- );
4188
- return isFileType && this._fileFilter(entry);
4208
+
4209
+ return stats && this._wantsEverything && !stats.isDirectory();
4189
4210
  }
4190
4211
  }
4191
4212
 
@@ -4779,6 +4800,7 @@ exports.FSEVENT_DELETED = 'deleted';
4779
4800
  exports.FSEVENT_MOVED = 'moved';
4780
4801
  exports.FSEVENT_CLONED = 'cloned';
4781
4802
  exports.FSEVENT_UNKNOWN = 'unknown';
4803
+ exports.FSEVENT_TYPE_FILE = 'file';
4782
4804
  exports.FSEVENT_TYPE_DIRECTORY = 'directory';
4783
4805
  exports.FSEVENT_TYPE_SYMLINK = 'symlink';
4784
4806
 
@@ -5477,6 +5499,7 @@ const {
5477
5499
  FSEVENT_MOVED,
5478
5500
  // FSEVENT_CLONED,
5479
5501
  FSEVENT_UNKNOWN,
5502
+ FSEVENT_TYPE_FILE,
5480
5503
  FSEVENT_TYPE_DIRECTORY,
5481
5504
  FSEVENT_TYPE_SYMLINK,
5482
5505
 
@@ -5487,15 +5510,12 @@ const {
5487
5510
  EMPTY_FN: EMPTY_FN$1,
5488
5511
  IDENTITY_FN
5489
5512
  } = constants$2;
5490
- const FS_MODE_READ = 'r';
5491
5513
 
5492
5514
  const Depth = (value) => isNaN(value) ? {} : {depth: value};
5493
5515
 
5494
5516
  const stat$2 = promisify$2(fs.stat);
5495
- const open$1 = promisify$2(fs.open);
5496
- const close$1 = promisify$2(fs.close);
5497
5517
  const lstat$2 = promisify$2(fs.lstat);
5498
- const realpath = promisify$2(fs.realpath);
5518
+ const realpath$1 = promisify$2(fs.realpath);
5499
5519
 
5500
5520
  const statMethods$1 = { stat: stat$2, lstat: lstat$2 };
5501
5521
 
@@ -5642,6 +5662,14 @@ const calcDepth = (path$1, root) => {
5642
5662
  return i;
5643
5663
  };
5644
5664
 
5665
+ // returns boolean indicating whether the fsevents' event info has the same type
5666
+ // as the one returned by fs.stat
5667
+ const sameTypes = (info, stats) => (
5668
+ info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() ||
5669
+ info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() ||
5670
+ info.type === FSEVENT_TYPE_FILE && stats.isFile()
5671
+ );
5672
+
5645
5673
  /**
5646
5674
  * @mixin
5647
5675
  */
@@ -5672,13 +5700,16 @@ addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5672
5700
  this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts);
5673
5701
  }
5674
5702
 
5675
- async checkFd(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5703
+ async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
5676
5704
  try {
5677
- const fd = await open$1(path, FS_MODE_READ);
5705
+ const stats = await stat$2(path);
5678
5706
  if (this.fsw.closed) return;
5679
- await close$1(fd);
5680
5707
  if (this.fsw.closed) return;
5681
- this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5708
+ if (sameTypes(info, stats)) {
5709
+ this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
5710
+ } else {
5711
+ this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
5712
+ }
5682
5713
  } catch (error) {
5683
5714
  if (error.code === 'EACCES') {
5684
5715
  this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
@@ -5692,9 +5723,10 @@ handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opt
5692
5723
  if (this.fsw.closed || this.checkIgnored(path)) return;
5693
5724
 
5694
5725
  if (event === EV_UNLINK) {
5726
+ const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY;
5695
5727
  // suppress unlink events on never before seen files
5696
- if (info.type === FSEVENT_TYPE_DIRECTORY || watchedDir.has(item)) {
5697
- this.fsw._remove(parent, item);
5728
+ if (isDirectory || watchedDir.has(item)) {
5729
+ this.fsw._remove(parent, item, isDirectory);
5698
5730
  }
5699
5731
  } else {
5700
5732
  if (event === EV_ADD$1) {
@@ -5759,13 +5791,13 @@ _watchWithFsEvents(watchPath, realPath, transform, globFilter) {
5759
5791
  } catch (error) {}
5760
5792
  if (this.fsw.closed) return;
5761
5793
  if (this.checkIgnored(path$1, stats)) return;
5762
- if (stats) {
5794
+ if (sameTypes(info, stats)) {
5763
5795
  this.addOrChange(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5764
5796
  } else {
5765
5797
  this.handleEvent(EV_UNLINK, path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5766
5798
  }
5767
5799
  } else {
5768
- this.checkFd(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5800
+ this.checkExists(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5769
5801
  }
5770
5802
  } else {
5771
5803
  switch (info.event) {
@@ -5774,7 +5806,7 @@ _watchWithFsEvents(watchPath, realPath, transform, globFilter) {
5774
5806
  return this.addOrChange(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5775
5807
  case FSEVENT_DELETED:
5776
5808
  case FSEVENT_MOVED:
5777
- return this.checkFd(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5809
+ return this.checkExists(path$1, fullPath, realPath, parent, watchedDir, item, info, opts);
5778
5810
  }
5779
5811
  }
5780
5812
  };
@@ -5807,7 +5839,7 @@ async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
5807
5839
  this.fsw._incrReadyCount();
5808
5840
 
5809
5841
  try {
5810
- const linkTarget = await realpath(linkPath);
5842
+ const linkTarget = await realpath$1(linkPath);
5811
5843
  if (this.fsw.closed) return;
5812
5844
  if (this.fsw._isIgnored(linkTarget)) {
5813
5845
  return this.fsw._emitReady();
@@ -5943,7 +5975,7 @@ async _addToFsEvents(path$1, transform, forceAdd, priorDepth) {
5943
5975
  } else {
5944
5976
  let realPath;
5945
5977
  try {
5946
- realPath = await realpath(wh.watchPath);
5978
+ realPath = await realpath$1(wh.watchPath);
5947
5979
  } catch (e) {}
5948
5980
  this.initWatch(realPath, path$1, wh, processPath);
5949
5981
  }
@@ -6108,12 +6140,13 @@ class DirEntry {
6108
6140
  const {items} = this;
6109
6141
  if (!items) return;
6110
6142
  items.delete(item);
6143
+ if (items.size > 0) return;
6111
6144
 
6112
- if (!items.size) {
6113
- const dir = this.path;
6114
- try {
6115
- await readdir$1(dir);
6116
- } catch (err) {
6145
+ const dir = this.path;
6146
+ try {
6147
+ await readdir$1(dir);
6148
+ } catch (err) {
6149
+ if (this._removeWatcher) {
6117
6150
  this._removeWatcher(path.dirname(dir), path.basename(dir));
6118
6151
  }
6119
6152
  }
@@ -6439,7 +6472,7 @@ unwatch(paths_) {
6439
6472
  * @returns {Promise<void>}.
6440
6473
  */
6441
6474
  close() {
6442
- if (this.closed) return this;
6475
+ if (this.closed) return this._closePromise;
6443
6476
  this.closed = true;
6444
6477
 
6445
6478
  // Memory management.
@@ -6457,7 +6490,9 @@ close() {
6457
6490
  ['closers', 'watched', 'streams', 'symlinkPaths', 'throttled'].forEach(key => {
6458
6491
  this[`_${key}`].clear();
6459
6492
  });
6460
- return closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve();
6493
+
6494
+ this._closePromise = closers.length ? Promise.all(closers).then(() => undefined) : Promise.resolve();
6495
+ return this._closePromise;
6461
6496
  }
6462
6497
 
6463
6498
  /**
@@ -6558,16 +6593,15 @@ async _emit(event, path$1, val1, val2, val3) {
6558
6593
  (event === EV_ADD$2 || event === EV_ADD_DIR$2 || event === EV_CHANGE$2)
6559
6594
  ) {
6560
6595
  const fullPath = opts.cwd ? path.join(opts.cwd, path$1) : path$1;
6596
+ let stats;
6561
6597
  try {
6562
- const stats = await stat$3(fullPath);
6563
- // Suppress event when fs_stat fails, to avoid sending undefined 'stat'
6564
- if (!stats) return;
6565
- args.push(stats);
6566
- this.emitWithAll(event, args);
6598
+ stats = await stat$3(fullPath);
6567
6599
  } catch (err) {}
6568
- } else {
6569
- this.emitWithAll(event, args);
6600
+ // Suppress event when fs_stat fails, to avoid sending undefined 'stat'
6601
+ if (!stats || this.closed) return;
6602
+ args.push(stats);
6570
6603
  }
6604
+ this.emitWithAll(event, args);
6571
6605
 
6572
6606
  return this;
6573
6607
  }
@@ -6776,13 +6810,15 @@ _hasReadPermissions(stats) {
6776
6810
  * @param {String} item base path of item/directory
6777
6811
  * @returns {void}
6778
6812
  */
6779
- _remove(directory, item) {
6813
+ _remove(directory, item, isDirectory) {
6780
6814
  // if what is being deleted is a directory, get that directory's paths
6781
6815
  // for recursive deleting and cleaning of watched object
6782
6816
  // if it is not a directory, nestedDirectoryChildren will be empty array
6783
6817
  const path$1 = path.join(directory, item);
6784
6818
  const fullPath = path.resolve(path$1);
6785
- const isDirectory = this._watched.has(path$1) || this._watched.has(fullPath);
6819
+ isDirectory = isDirectory != null
6820
+ ? isDirectory
6821
+ : this._watched.has(path$1) || this._watched.has(fullPath);
6786
6822
 
6787
6823
  // prevent duplicate handling in case of arriving here nearly simultaneously
6788
6824
  // via multiple paths (such as _handleFile and _handleDir)
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.7.5
4
- Wed, 29 Apr 2020 19:48:24 GMT - commit a2b48832de11ad38eacfeacad08ba4dfceecfe96
3
+ Rollup.js v2.7.6
4
+ Thu, 30 Apr 2020 18:55:10 GMT - commit 468010ba801b1e59573b6aa7319461a449aa43df
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup