rollup 2.32.1 → 2.33.3

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.32.1
4
- Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
3
+ Rollup.js v2.33.3
4
+ Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.32.1
4
- Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
3
+ Rollup.js v2.33.3
4
+ Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
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.32.1";
16
+ var version = "2.33.3";
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
  }
@@ -4892,6 +4893,16 @@ function getInteropBlock(dependencies, varOrConst, interop, externalLiveBindings
4892
4893
  return `${getHelpersBlock(neededInteropHelpers, accessedGlobals, _, n, s, t, externalLiveBindings, freeze, namespaceToStringTag)}${interopStatements.length > 0 ? `${interopStatements.join(n)}${n}${n}` : ''}`;
4893
4894
  }
4894
4895
 
4896
+ // AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
4897
+ // The assumption is that this makes sense for all relative ids:
4898
+ // https://requirejs.org/docs/api.html#jsfiles
4899
+ function removeExtensionFromRelativeAmdId(id) {
4900
+ if (id[0] === '.' && id.endsWith('.js')) {
4901
+ return id.slice(0, -3);
4902
+ }
4903
+ return id;
4904
+ }
4905
+
4895
4906
  const builtins$1 = {
4896
4907
  assert: true,
4897
4908
  buffer: true,
@@ -4932,15 +4943,6 @@ function warnOnBuiltins(warn, dependencies) {
4932
4943
  });
4933
4944
  }
4934
4945
 
4935
- // AMD resolution will only respect the AMD baseUrl if the .js extension is omitted.
4936
- // The assumption is that this makes sense for all relative ids:
4937
- // https://requirejs.org/docs/api.html#jsfiles
4938
- function removeExtensionFromRelativeAmdId(id) {
4939
- if (id[0] === '.' && id.endsWith('.js')) {
4940
- return id.slice(0, -3);
4941
- }
4942
- return id;
4943
- }
4944
4946
  function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, indentString: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, varOrConst, warn }, { amd: { define: amdDefine, id: amdId }, compact, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
4945
4947
  warnOnBuiltins(warn, dependencies);
4946
4948
  const deps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
@@ -5756,7 +5758,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
5756
5758
  });
5757
5759
  }
5758
5760
  warnOnBuiltins(warn, dependencies);
5759
- const amdDeps = dependencies.map(m => `'${m.id}'`);
5761
+ const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.id)}'`);
5760
5762
  const cjsDeps = dependencies.map(m => `require('${m.id}')`);
5761
5763
  const trimmedImports = trimEmptyImports(dependencies);
5762
5764
  const globalDeps = trimmedImports.map(module => globalProp(module.globalName, globalVar));
@@ -8733,6 +8735,7 @@ class TryStatement extends NodeBase {
8733
8735
  constructor() {
8734
8736
  super(...arguments);
8735
8737
  this.directlyIncluded = false;
8738
+ this.includedLabelsAfterBlock = null;
8736
8739
  }
8737
8740
  hasEffects(context) {
8738
8741
  return ((this.context.options.treeshake.tryCatchDeoptimization
@@ -8748,8 +8751,16 @@ class TryStatement extends NodeBase {
8748
8751
  this.included = true;
8749
8752
  this.directlyIncluded = true;
8750
8753
  this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
8754
+ if (context.includedLabels.size > 0) {
8755
+ this.includedLabelsAfterBlock = [...context.includedLabels];
8756
+ }
8751
8757
  context.brokenFlow = brokenFlow;
8752
8758
  }
8759
+ else if (this.includedLabelsAfterBlock) {
8760
+ for (const label of this.includedLabelsAfterBlock) {
8761
+ context.includedLabels.add(label);
8762
+ }
8763
+ }
8753
8764
  if (this.handler !== null) {
8754
8765
  this.handler.include(context, includeChildrenRecursively);
8755
8766
  context.brokenFlow = brokenFlow;
@@ -9668,7 +9679,6 @@ class Module {
9668
9679
  this.graph = graph;
9669
9680
  this.id = id;
9670
9681
  this.options = options;
9671
- this.syntheticNamedExports = syntheticNamedExports;
9672
9682
  this.ast = null;
9673
9683
  this.chunkFileNames = new Set();
9674
9684
  this.chunkName = null;
@@ -9738,7 +9748,8 @@ class Module {
9738
9748
  },
9739
9749
  isEntry,
9740
9750
  isExternal: false,
9741
- meta
9751
+ meta,
9752
+ syntheticNamedExports
9742
9753
  };
9743
9754
  }
9744
9755
  basename() {
@@ -9836,7 +9847,7 @@ class Module {
9836
9847
  }
9837
9848
  const exportNamesByVariable = new Map();
9838
9849
  for (const exportName of this.getAllExportNames()) {
9839
- if (exportName === this.syntheticNamedExports)
9850
+ if (exportName === this.info.syntheticNamedExports)
9840
9851
  continue;
9841
9852
  let tracedVariable = this.getVariableForExportName(exportName);
9842
9853
  if (tracedVariable instanceof ExportDefaultVariable) {
@@ -9895,14 +9906,17 @@ class Module {
9895
9906
  getSyntheticNamespace() {
9896
9907
  if (this.syntheticNamespace === null) {
9897
9908
  this.syntheticNamespace = undefined;
9898
- this.syntheticNamespace = this.getVariableForExportName(typeof this.syntheticNamedExports === 'string' ? this.syntheticNamedExports : 'default');
9909
+ this.syntheticNamespace = this.getVariableForExportName(typeof this.info.syntheticNamedExports === 'string'
9910
+ ? this.info.syntheticNamedExports
9911
+ : 'default');
9899
9912
  }
9900
9913
  if (!this.syntheticNamespace) {
9901
9914
  return error({
9902
9915
  code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
9903
9916
  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}"`
9917
+ message: `Module "${relativeId(this.id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(this.info.syntheticNamedExports)}' needs ${typeof this.info.syntheticNamedExports === 'string' &&
9918
+ this.info.syntheticNamedExports !== 'default'
9919
+ ? `an export named "${this.info.syntheticNamedExports}"`
9906
9920
  : 'a default export'}.`
9907
9921
  });
9908
9922
  }
@@ -9946,7 +9960,7 @@ class Module {
9946
9960
  // we don't want to create shims when we are just
9947
9961
  // probing export * modules for exports
9948
9962
  if (!isExportAllSearch) {
9949
- if (this.syntheticNamedExports) {
9963
+ if (this.info.syntheticNamedExports) {
9950
9964
  let syntheticExport = this.syntheticExports.get(name);
9951
9965
  if (!syntheticExport) {
9952
9966
  const syntheticNamespace = this.getSyntheticNamespace();
@@ -9978,7 +9992,7 @@ class Module {
9978
9992
  markModuleAndImpureDependenciesAsExecuted(this);
9979
9993
  }
9980
9994
  for (const exportName of this.getExports()) {
9981
- if (includeNamespaceMembers || exportName !== this.syntheticNamedExports) {
9995
+ if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
9982
9996
  const variable = this.getVariableForExportName(exportName);
9983
9997
  variable.deoptimizePath(UNKNOWN_PATH);
9984
9998
  if (!variable.included) {
@@ -10104,7 +10118,7 @@ class Module {
10104
10118
  warn: this.warn.bind(this)
10105
10119
  };
10106
10120
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
10107
- this.namespace = new NamespaceVariable(this.astContext, this.syntheticNamedExports);
10121
+ this.namespace = new NamespaceVariable(this.astContext, this.info.syntheticNamedExports);
10108
10122
  this.ast = new Program$1(ast, { type: 'Module', context: this.astContext }, this.scope);
10109
10123
  this.info.ast = ast;
10110
10124
  timeEnd('analyse ast', 3);
@@ -10123,7 +10137,7 @@ class Module {
10123
10137
  originalSourcemap: this.originalSourcemap,
10124
10138
  resolvedIds: this.resolvedIds,
10125
10139
  sourcemapChain: this.sourcemapChain,
10126
- syntheticNamedExports: this.syntheticNamedExports,
10140
+ syntheticNamedExports: this.info.syntheticNamedExports,
10127
10141
  transformDependencies: this.transformDependencies,
10128
10142
  transformFiles: this.transformFiles
10129
10143
  };
@@ -10152,7 +10166,7 @@ class Module {
10152
10166
  this.info.hasModuleSideEffects = moduleSideEffects;
10153
10167
  }
10154
10168
  if (syntheticNamedExports != null) {
10155
- this.syntheticNamedExports = syntheticNamedExports;
10169
+ this.info.syntheticNamedExports = syntheticNamedExports;
10156
10170
  }
10157
10171
  if (meta != null) {
10158
10172
  this.info.meta = { ...this.info.meta, ...meta };
@@ -10302,7 +10316,7 @@ class Module {
10302
10316
  this.imports.add(externalVariable);
10303
10317
  mergedNamespaces.push(externalVariable);
10304
10318
  }
10305
- else if (module.syntheticNamedExports) {
10319
+ else if (module.info.syntheticNamedExports) {
10306
10320
  const syntheticNamespace = module.getSyntheticNamespace();
10307
10321
  syntheticNamespace.include();
10308
10322
  this.imports.add(syntheticNamespace);
@@ -10922,7 +10936,7 @@ class Chunk$1 {
10922
10936
  if (!chunkModules.has(importer)) {
10923
10937
  this.dynamicEntryModules.push(module);
10924
10938
  // Modules with synthetic exports need an artificial namespace for dynamic imports
10925
- if (module.syntheticNamedExports && !outputOptions.preserveModules) {
10939
+ if (module.info.syntheticNamedExports && !outputOptions.preserveModules) {
10926
10940
  includedNamespaces.add(module);
10927
10941
  this.exports.add(module.namespace);
10928
10942
  }
@@ -11045,7 +11059,7 @@ class Chunk$1 {
11045
11059
  }
11046
11060
  }
11047
11061
  for (const module of this.dynamicEntryModules) {
11048
- if (module.syntheticNamedExports)
11062
+ if (module.info.syntheticNamedExports)
11049
11063
  continue;
11050
11064
  if (!this.facadeModule && this.canModuleBeFacade(module, exposedVariables)) {
11051
11065
  this.facadeModule = module;
@@ -18467,6 +18481,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
18467
18481
  getFileName: fileEmitter.getFileName,
18468
18482
  getModuleIds: () => graph.modulesById.keys(),
18469
18483
  getModuleInfo: graph.getModuleInfo,
18484
+ getWatchFiles: () => Object.keys(graph.watchFiles),
18470
18485
  isExternal: getDeprecatedContextHandler((id, parentId, isResolved = false) => options.external(id, parentId, isResolved), 'isExternal', 'resolve', plugin.name, true, options),
18471
18486
  meta: {
18472
18487
  rollupVersion: version,
@@ -18508,6 +18523,7 @@ function getPluginContexts(pluginCache, graph, options, fileEmitter) {
18508
18523
  const inputHookNames = {
18509
18524
  buildEnd: 1,
18510
18525
  buildStart: 1,
18526
+ closeWatcher: 1,
18511
18527
  load: 1,
18512
18528
  moduleParsed: 1,
18513
18529
  options: 1,
@@ -18750,10 +18766,13 @@ class Graph {
18750
18766
  });
18751
18767
  if (watcher) {
18752
18768
  this.watchMode = true;
18753
- const handleChange = (id) => this.pluginDriver.hookSeqSync('watchChange', [id]);
18769
+ const handleChange = (...args) => this.pluginDriver.hookSeqSync('watchChange', args);
18770
+ const handleClose = () => this.pluginDriver.hookSeqSync('closeWatcher', []);
18754
18771
  watcher.on('change', handleChange);
18772
+ watcher.on('close', handleClose);
18755
18773
  watcher.once('restart', () => {
18756
18774
  watcher.removeListener('change', handleChange);
18775
+ watcher.removeListener('close', handleClose);
18757
18776
  });
18758
18777
  }
18759
18778
  this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.32.1
4
- Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
3
+ Rollup.js v2.33.3
4
+ Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
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.32.1
4
- Wed, 21 Oct 2020 07:32:18 GMT - commit 51e727c99bfc67a6bc46087c63950cec2a7fe12f
3
+ Rollup.js v2.33.3
4
+ Wed, 18 Nov 2020 05:54:45 GMT - commit 07868398277174501db6703d0bcdfc6b89d6fa6e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup