rollup 2.31.0 → 2.33.1

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.31.0
4
- Thu, 15 Oct 2020 17:21:50 GMT - commit 8cdbc617d4d5883c283480df179f516a8527b06d
3
+ Rollup.js v2.33.1
4
+ Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.31.0
4
- Thu, 15 Oct 2020 17:21:50 GMT - commit 8cdbc617d4d5883c283480df179f516a8527b06d
3
+ Rollup.js v2.33.1
4
+ Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
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.31.0";
16
+ var version = "2.33.1";
17
17
 
18
18
  var charToInteger = {};
19
19
  var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -2338,7 +2338,8 @@ class ExternalModule {
2338
2338
  },
2339
2339
  isEntry: false,
2340
2340
  isExternal: true,
2341
- meta
2341
+ meta,
2342
+ syntheticNamedExports: false
2342
2343
  };
2343
2344
  }
2344
2345
  getVariableForExportName(name) {
@@ -4513,7 +4514,7 @@ class NamespaceVariable extends Variable {
4513
4514
  }
4514
4515
  const memberVariables = Object.create(null);
4515
4516
  for (const name of this.context.getExports().concat(this.context.getReexports())) {
4516
- if (name[0] !== '*' && name !== this.module.syntheticNamedExports) {
4517
+ if (name[0] !== '*' && name !== this.module.info.syntheticNamedExports) {
4517
4518
  memberVariables[name] = this.context.traceExport(name);
4518
4519
  }
4519
4520
  }
@@ -9668,7 +9669,6 @@ class Module {
9668
9669
  this.graph = graph;
9669
9670
  this.id = id;
9670
9671
  this.options = options;
9671
- this.syntheticNamedExports = syntheticNamedExports;
9672
9672
  this.ast = null;
9673
9673
  this.chunkFileNames = new Set();
9674
9674
  this.chunkName = null;
@@ -9738,7 +9738,8 @@ class Module {
9738
9738
  },
9739
9739
  isEntry,
9740
9740
  isExternal: false,
9741
- meta
9741
+ meta,
9742
+ syntheticNamedExports
9742
9743
  };
9743
9744
  }
9744
9745
  basename() {
@@ -9836,7 +9837,7 @@ class Module {
9836
9837
  }
9837
9838
  const exportNamesByVariable = new Map();
9838
9839
  for (const exportName of this.getAllExportNames()) {
9839
- if (exportName === this.syntheticNamedExports)
9840
+ if (exportName === this.info.syntheticNamedExports)
9840
9841
  continue;
9841
9842
  let tracedVariable = this.getVariableForExportName(exportName);
9842
9843
  if (tracedVariable instanceof ExportDefaultVariable) {
@@ -9895,14 +9896,17 @@ class Module {
9895
9896
  getSyntheticNamespace() {
9896
9897
  if (this.syntheticNamespace === null) {
9897
9898
  this.syntheticNamespace = undefined;
9898
- this.syntheticNamespace = this.getVariableForExportName(typeof this.syntheticNamedExports === 'string' ? this.syntheticNamedExports : 'default');
9899
+ this.syntheticNamespace = this.getVariableForExportName(typeof this.info.syntheticNamedExports === 'string'
9900
+ ? this.info.syntheticNamedExports
9901
+ : 'default');
9899
9902
  }
9900
9903
  if (!this.syntheticNamespace) {
9901
9904
  return error({
9902
9905
  code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
9903
9906
  id: this.id,
9904
- message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.syntheticNamedExports)}' needs ${typeof this.syntheticNamedExports === 'string' && this.syntheticNamedExports !== 'default'
9905
- ? `an export named "${this.syntheticNamedExports}"`
9907
+ message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.info.syntheticNamedExports)}' needs ${typeof this.info.syntheticNamedExports === 'string' &&
9908
+ this.info.syntheticNamedExports !== 'default'
9909
+ ? `an export named "${this.info.syntheticNamedExports}"`
9906
9910
  : 'a default export'}.`
9907
9911
  });
9908
9912
  }
@@ -9946,7 +9950,7 @@ class Module {
9946
9950
  // we don't want to create shims when we are just
9947
9951
  // probing export * modules for exports
9948
9952
  if (!isExportAllSearch) {
9949
- if (this.syntheticNamedExports) {
9953
+ if (this.info.syntheticNamedExports) {
9950
9954
  let syntheticExport = this.syntheticExports.get(name);
9951
9955
  if (!syntheticExport) {
9952
9956
  const syntheticNamespace = this.getSyntheticNamespace();
@@ -9978,7 +9982,7 @@ class Module {
9978
9982
  markModuleAndImpureDependenciesAsExecuted(this);
9979
9983
  }
9980
9984
  for (const exportName of this.getExports()) {
9981
- if (includeNamespaceMembers || exportName !== this.syntheticNamedExports) {
9985
+ if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
9982
9986
  const variable = this.getVariableForExportName(exportName);
9983
9987
  variable.deoptimizePath(UNKNOWN_PATH);
9984
9988
  if (!variable.included) {
@@ -10104,7 +10108,7 @@ class Module {
10104
10108
  warn: this.warn.bind(this)
10105
10109
  };
10106
10110
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
10107
- this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
10111
+ this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports);
10108
10112
  this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
10109
10113
  this.info.ast = ast;
10110
10114
  timeEnd('analyse ast', 3);
@@ -10123,7 +10127,7 @@ class Module {
10123
10127
  originalSourcemap: this.originalSourcemap,
10124
10128
  resolvedIds: this.resolvedIds,
10125
10129
  sourcemapChain: this.sourcemapChain,
10126
- syntheticNamedExports: this.syntheticNamedExports,
10130
+ syntheticNamedExports: this.info.syntheticNamedExports,
10127
10131
  transformDependencies: this.transformDependencies,
10128
10132
  transformFiles: this.transformFiles
10129
10133
  };
@@ -10152,7 +10156,7 @@ class Module {
10152
10156
  this.info.hasModuleSideEffects = moduleSideEffects;
10153
10157
  }
10154
10158
  if (syntheticNamedExports != null) {
10155
- this.syntheticNamedExports = syntheticNamedExports;
10159
+ this.info.syntheticNamedExports = syntheticNamedExports;
10156
10160
  }
10157
10161
  if (meta != null) {
10158
10162
  this.info.meta = { ...this.info.meta, ...meta };
@@ -10302,7 +10306,7 @@ class Module {
10302
10306
  this.imports.add(externalVariable);
10303
10307
  mergedNamespaces.push(externalVariable);
10304
10308
  }
10305
- else if (module.syntheticNamedExports) {
10309
+ else if (module.info.syntheticNamedExports) {
10306
10310
  const syntheticNamespace = module.getSyntheticNamespace();
10307
10311
  syntheticNamespace.include();
10308
10312
  this.imports.add(syntheticNamespace);
@@ -10922,7 +10926,7 @@ class Chunk$1 {
10922
10926
  if (!chunkModules.has(importer)) {
10923
10927
  this.dynamicEntryModules.push(module);
10924
10928
  // Modules with synthetic exports need an artificial namespace for dynamic imports
10925
- if (module.syntheticNamedExports && !outputOptions.preserveModules) {
10929
+ if (module.info.syntheticNamedExports && !outputOptions.preserveModules) {
10926
10930
  includedNamespaces.add(module);
10927
10931
  this.exports.add(module.namespace);
10928
10932
  }
@@ -11024,24 +11028,28 @@ class Chunk$1 {
11024
11028
  if (requiredFacades.length === 0) {
11025
11029
  requiredFacades.push({});
11026
11030
  }
11027
- if (!this.facadeModule &&
11028
- (this.outputOptions.preserveModules ||
11029
- module.preserveSignature !== 'strict' ||
11030
- this.canModuleBeFacade(module, exposedVariables))) {
11031
- this.facadeModule = module;
11032
- this.facadeChunkByModule.set(module, this);
11033
- if (module.preserveSignature) {
11034
- this.strictFacade = module.preserveSignature === 'strict';
11035
- this.ensureReexportsAreAvailableForModule(module);
11031
+ if (!this.facadeModule) {
11032
+ const needsStrictFacade = module.preserveSignature === 'strict' ||
11033
+ (module.preserveSignature === 'exports-only' &&
11034
+ module.getExportNamesByVariable().size !== 0);
11035
+ if (!needsStrictFacade ||
11036
+ this.outputOptions.preserveModules ||
11037
+ this.canModuleBeFacade(module, exposedVariables)) {
11038
+ this.facadeModule = module;
11039
+ this.facadeChunkByModule.set(module, this);
11040
+ if (module.preserveSignature) {
11041
+ this.strictFacade = needsStrictFacade;
11042
+ this.ensureReexportsAreAvailableForModule(module);
11043
+ }
11044
+ this.assignFacadeName(requiredFacades.shift(), module);
11036
11045
  }
11037
- this.assignFacadeName(requiredFacades.shift(), module);
11038
11046
  }
11039
11047
  for (const facadeName of requiredFacades) {
11040
11048
  facades.push(Chunk$1.generateFacade(this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.modulesById, this.chunkByModule, this.facadeChunkByModule, this.includedNamespaces, module, facadeName));
11041
11049
  }
11042
11050
  }
11043
11051
  for (const module of this.dynamicEntryModules) {
11044
- if (module.syntheticNamedExports)
11052
+ if (module.info.syntheticNamedExports)
11045
11053
  continue;
11046
11054
  if (!this.facadeModule && this.canModuleBeFacade(module, exposedVariables)) {
11047
11055
  this.facadeModule = module;
@@ -18463,6 +18471,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
18463
18471
  getFileName: fileEmitter.getFileName,
18464
18472
  getModuleIds: () => graph.modulesById.keys(),
18465
18473
  getModuleInfo: graph.getModuleInfo,
18474
+ getWatchFiles: () => Object.keys(graph.watchFiles),
18466
18475
  isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
18467
18476
  meta: {
18468
18477
  rollupVersion: version,
@@ -18504,6 +18513,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
18504
18513
  const inputHookNames = {
18505
18514
  buildEnd: 1,
18506
18515
  buildStart: 1,
18516
+ closeWatcher: 1,
18507
18517
  load: 1,
18508
18518
  moduleParsed: 1,
18509
18519
  options: 1,
@@ -18746,10 +18756,13 @@ class Graph {
18746
18756
  });
18747
18757
  if (watcher) {
18748
18758
  this.watchMode = true;
18749
- const handleChange = (id) => this.pluginDriver.hookSeqSync('watchChange', [id]);
18759
+ const handleChange = (...args) => this.pluginDriver.hookSeqSync('watchChange', args);
18760
+ const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []);
18750
18761
  watcher.on('change', handleChange);
18762
+ watcher.on('close', handleClose);
18751
18763
  watcher.once('restart', () => {
18752
18764
  watcher.removeListener('change', handleChange);
18765
+ watcher.removeListener('close', handleClose);
18753
18766
  });
18754
18767
  }
18755
18768
  this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.31.0
4
- Thu, 15 Oct 2020 17:21:50 GMT - commit 8cdbc617d4d5883c283480df179f516a8527b06d
3
+ Rollup.js v2.33.1
4
+ Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -7091,7 +7091,7 @@ class FileWatcher {
7091
7091
  const task = this.task;
7092
7092
  const isLinux = platform() === 'linux';
7093
7093
  const isTransformDependency = transformWatcherId !== null;
7094
- const handleChange = (id) => {
7094
+ const handleChange = (id, event) => {
7095
7095
  const changedId = transformWatcherId || id;
7096
7096
  if (isLinux) {
7097
7097
  // unwatching and watching fixes an issue with chokidar where on certain systems,
@@ -7100,22 +7100,39 @@ class FileWatcher {
7100
7100
  watcher.unwatch(changedId);
7101
7101
  watcher.add(changedId);
7102
7102
  }
7103
- task.invalidate(changedId, isTransformDependency);
7103
+ task.invalidate(changedId, { isTransformDependency, event });
7104
7104
  };
7105
7105
  const watcher = chokidar
7106
7106
  .watch([], this.chokidarOptions)
7107
- .on('add', handleChange)
7108
- .on('change', handleChange)
7109
- .on('unlink', handleChange);
7107
+ .on('add', id => handleChange(id, 'create'))
7108
+ .on('change', id => handleChange(id, 'update'))
7109
+ .on('unlink', id => handleChange(id, 'delete'));
7110
7110
  return watcher;
7111
7111
  }
7112
7112
  }
7113
7113
 
7114
+ const eventsRewrites = {
7115
+ create: {
7116
+ create: 'buggy',
7117
+ delete: null,
7118
+ update: 'create',
7119
+ },
7120
+ delete: {
7121
+ create: 'update',
7122
+ delete: 'buggy',
7123
+ update: 'buggy',
7124
+ },
7125
+ update: {
7126
+ create: 'buggy',
7127
+ delete: 'delete',
7128
+ update: 'update',
7129
+ }
7130
+ };
7114
7131
  class Watcher {
7115
7132
  constructor(configs, emitter) {
7116
7133
  this.buildDelay = 0;
7117
7134
  this.buildTimeout = null;
7118
- this.invalidatedIds = new Set();
7135
+ this.invalidatedIds = new Map();
7119
7136
  this.rerun = false;
7120
7137
  this.emitter = emitter;
7121
7138
  emitter.close = this.close.bind(this);
@@ -7132,14 +7149,25 @@ class Watcher {
7132
7149
  for (const task of this.tasks) {
7133
7150
  task.close();
7134
7151
  }
7152
+ this.emitter.emit('close');
7135
7153
  this.emitter.removeAllListeners();
7136
7154
  }
7137
- emit(event, value) {
7138
- this.emitter.emit(event, value);
7139
- }
7140
- invalidate(id) {
7141
- if (id) {
7142
- this.invalidatedIds.add(id);
7155
+ invalidate(file) {
7156
+ if (file) {
7157
+ const prevEvent = this.invalidatedIds.get(file.id);
7158
+ const event = prevEvent
7159
+ ? eventsRewrites[prevEvent][file.event]
7160
+ : file.event;
7161
+ if (event === 'buggy') {
7162
+ //TODO: throws or warn? Currently just ignore, uses new event
7163
+ this.invalidatedIds.set(file.id, file.event);
7164
+ }
7165
+ else if (event === null) {
7166
+ this.invalidatedIds.delete(file.id);
7167
+ }
7168
+ else {
7169
+ this.invalidatedIds.set(file.id, event);
7170
+ }
7143
7171
  }
7144
7172
  if (this.running) {
7145
7173
  this.rerun = true;
@@ -7149,17 +7177,17 @@ class Watcher {
7149
7177
  clearTimeout(this.buildTimeout);
7150
7178
  this.buildTimeout = setTimeout(() => {
7151
7179
  this.buildTimeout = null;
7152
- for (const id of this.invalidatedIds) {
7153
- this.emit('change', id);
7180
+ for (const [id, event] of this.invalidatedIds.entries()) {
7181
+ this.emitter.emit('change', id, { event });
7154
7182
  }
7155
7183
  this.invalidatedIds.clear();
7156
- this.emit('restart');
7184
+ this.emitter.emit('restart');
7157
7185
  this.run();
7158
7186
  }, this.buildDelay);
7159
7187
  }
7160
7188
  async run() {
7161
7189
  this.running = true;
7162
- this.emit('event', {
7190
+ this.emitter.emit('event', {
7163
7191
  code: 'START'
7164
7192
  });
7165
7193
  try {
@@ -7167,13 +7195,13 @@ class Watcher {
7167
7195
  await task.run();
7168
7196
  }
7169
7197
  this.running = false;
7170
- this.emit('event', {
7198
+ this.emitter.emit('event', {
7171
7199
  code: 'END'
7172
7200
  });
7173
7201
  }
7174
7202
  catch (error) {
7175
7203
  this.running = false;
7176
- this.emit('event', {
7204
+ this.emitter.emit('event', {
7177
7205
  code: 'ERROR',
7178
7206
  error
7179
7207
  });
@@ -7212,9 +7240,9 @@ class Task {
7212
7240
  this.closed = true;
7213
7241
  this.fileWatcher.close();
7214
7242
  }
7215
- invalidate(id, isTransformDependency) {
7243
+ invalidate(id, details) {
7216
7244
  this.invalidated = true;
7217
- if (isTransformDependency) {
7245
+ if (details.isTransformDependency) {
7218
7246
  for (const module of this.cache.modules) {
7219
7247
  if (module.transformDependencies.indexOf(id) === -1)
7220
7248
  continue;
@@ -7222,7 +7250,7 @@ class Task {
7222
7250
  module.originalCode = null;
7223
7251
  }
7224
7252
  }
7225
- this.watcher.invalidate(id);
7253
+ this.watcher.invalidate({ id, event: details.event });
7226
7254
  }
7227
7255
  async run() {
7228
7256
  if (!this.invalidated)
@@ -7233,7 +7261,7 @@ class Task {
7233
7261
  cache: this.cache
7234
7262
  };
7235
7263
  const start = Date.now();
7236
- this.watcher.emit('event', {
7264
+ this.watcher.emitter.emit('event', {
7237
7265
  code: 'BUNDLE_START',
7238
7266
  input: this.options.input,
7239
7267
  output: this.outputFiles
@@ -7245,7 +7273,7 @@ class Task {
7245
7273
  }
7246
7274
  this.updateWatchedFiles(result);
7247
7275
  this.skipWrite || (await Promise.all(this.outputs.map(output => result.write(output))));
7248
- this.watcher.emit('event', {
7276
+ this.watcher.emitter.emit('event', {
7249
7277
  code: 'BUNDLE_END',
7250
7278
  duration: Date.now() - start,
7251
7279
  input: this.options.input,
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.31.0
4
- Thu, 15 Oct 2020 17:21:50 GMT - commit 8cdbc617d4d5883c283480df179f516a8527b06d
3
+ Rollup.js v2.33.1
4
+ Mon, 02 Nov 2020 06:50:50 GMT - commit d861c91c068bc4e64d84db3b84232d3fb7f1d073
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup