rollup 2.63.0 → 2.64.0

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.63.0
4
- Tue, 04 Jan 2022 07:30:25 GMT - commit ae674c9edde5efb8ce6d8ef845598a805938178c
3
+ Rollup.js v2.64.0
4
+ Fri, 14 Jan 2022 14:02:32 GMT - commit 82a3e2634a9d51b5040752e4fb2fd264651d504e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -10,6 +10,8 @@
10
10
  */
11
11
  export { version as VERSION, defineConfig, rollup, watch } from './shared/rollup.js';
12
12
  import 'path';
13
+ import 'process';
14
+ import 'perf_hooks';
13
15
  import 'crypto';
14
16
  import 'fs';
15
17
  import 'events';
@@ -1,19 +1,21 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.63.0
4
- Tue, 04 Jan 2022 07:30:25 GMT - commit ae674c9edde5efb8ce6d8ef845598a805938178c
3
+ Rollup.js v2.64.0
4
+ Fri, 14 Jan 2022 14:02:32 GMT - commit 82a3e2634a9d51b5040752e4fb2fd264651d504e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
9
9
  Released under the MIT License.
10
10
  */
11
- import require$$0__default, { relative as relative$1, resolve, extname, basename, win32, posix, isAbsolute as isAbsolute$1, dirname } from 'path';
11
+ import require$$0, { relative as relative$1, resolve, extname, basename, win32, posix, isAbsolute as isAbsolute$1, dirname } from 'path';
12
+ import process$1 from 'process';
13
+ import { performance } from 'perf_hooks';
12
14
  import { createHash as createHash$1 } from 'crypto';
13
15
  import fs, { lstatSync, realpathSync, readdirSync } from 'fs';
14
16
  import { EventEmitter } from 'events';
15
17
 
16
- var version$1 = "2.63.0";
18
+ var version$1 = "2.64.0";
17
19
 
18
20
  var charToInteger = {};
19
21
  var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -1866,7 +1868,7 @@ function getAugmentedNamespace(n) {
1866
1868
 
1867
1869
  var utils$3 = {};
1868
1870
 
1869
- const path$1 = require$$0__default;
1871
+ const path$1 = require$$0;
1870
1872
  const WIN_SLASH = '\\\\/';
1871
1873
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1872
1874
 
@@ -2046,7 +2048,7 @@ var constants$2 = {
2046
2048
 
2047
2049
  (function (exports) {
2048
2050
 
2049
- const path = require$$0__default;
2051
+ const path = require$$0;
2050
2052
  const win32 = process.platform === 'win32';
2051
2053
  const {
2052
2054
  REGEX_BACKSLASH,
@@ -3576,7 +3578,7 @@ parse$1.fastpaths = (input, options) => {
3576
3578
 
3577
3579
  var parse_1 = parse$1;
3578
3580
 
3579
- const path = require$$0__default;
3581
+ const path = require$$0;
3580
3582
  const scan = scan_1;
3581
3583
  const parse = parse_1;
3582
3584
  const utils = utils$3;
@@ -12012,24 +12014,7 @@ function getOriginalLocation(sourcemapChain, location) {
12012
12014
  }
12013
12015
 
12014
12016
  const NOOP = () => { };
12015
- let getStartTime = () => [0, 0];
12016
- let getElapsedTime = () => 0;
12017
- let getMemory = () => 0;
12018
- let timers = {};
12019
- const normalizeHrTime = (time) => time[0] * 1e3 + time[1] / 1e6;
12020
- function setTimeHelpers() {
12021
- if (typeof process !== 'undefined' && typeof process.hrtime === 'function') {
12022
- getStartTime = process.hrtime.bind(process);
12023
- getElapsedTime = previous => normalizeHrTime(process.hrtime(previous));
12024
- }
12025
- else if (typeof performance !== 'undefined' && typeof performance.now === 'function') {
12026
- getStartTime = () => [performance.now(), 0];
12027
- getElapsedTime = previous => performance.now() - previous[0];
12028
- }
12029
- if (typeof process !== 'undefined' && typeof process.memoryUsage === 'function') {
12030
- getMemory = () => process.memoryUsage().heapUsed;
12031
- }
12032
- }
12017
+ let timers = new Map();
12033
12018
  function getPersistedLabel(label, level) {
12034
12019
  switch (level) {
12035
12020
  case 1:
@@ -12044,46 +12029,47 @@ function getPersistedLabel(label, level) {
12044
12029
  }
12045
12030
  function timeStartImpl(label, level = 3) {
12046
12031
  label = getPersistedLabel(label, level);
12047
- if (!timers.hasOwnProperty(label)) {
12048
- timers[label] = {
12032
+ const startMemory = process$1.memoryUsage().heapUsed;
12033
+ const startTime = performance.now();
12034
+ const timer = timers.get(label);
12035
+ if (timer === undefined) {
12036
+ timers.set(label, {
12049
12037
  memory: 0,
12050
- startMemory: undefined,
12051
- startTime: undefined,
12038
+ startMemory,
12039
+ startTime,
12052
12040
  time: 0,
12053
12041
  totalMemory: 0
12054
- };
12042
+ });
12043
+ }
12044
+ else {
12045
+ timer.startMemory = startMemory;
12046
+ timer.startTime = startTime;
12055
12047
  }
12056
- const currentMemory = getMemory();
12057
- timers[label].startTime = getStartTime();
12058
- timers[label].startMemory = currentMemory;
12059
12048
  }
12060
12049
  function timeEndImpl(label, level = 3) {
12061
12050
  label = getPersistedLabel(label, level);
12062
- if (timers.hasOwnProperty(label)) {
12063
- const currentMemory = getMemory();
12064
- timers[label].time += getElapsedTime(timers[label].startTime);
12065
- timers[label].totalMemory = Math.max(timers[label].totalMemory, currentMemory);
12066
- timers[label].memory += currentMemory - timers[label].startMemory;
12051
+ const timer = timers.get(label);
12052
+ if (timer !== undefined) {
12053
+ const currentMemory = process$1.memoryUsage().heapUsed;
12054
+ timer.memory += currentMemory - timer.startMemory;
12055
+ timer.time += performance.now() - timer.startTime;
12056
+ timer.totalMemory = Math.max(timer.totalMemory, currentMemory);
12067
12057
  }
12068
12058
  }
12069
12059
  function getTimings() {
12070
12060
  const newTimings = {};
12071
- for (const [label, { time, memory, totalMemory }] of Object.entries(timers)) {
12061
+ for (const [label, { memory, time, totalMemory }] of timers) {
12072
12062
  newTimings[label] = [time, memory, totalMemory];
12073
12063
  }
12074
12064
  return newTimings;
12075
12065
  }
12076
- let timeStart = NOOP, timeEnd = NOOP;
12077
- const TIMED_PLUGIN_HOOKS = {
12078
- load: true,
12079
- resolveDynamicImport: true,
12080
- resolveId: true,
12081
- transform: true
12082
- };
12066
+ let timeStart = NOOP;
12067
+ let timeEnd = NOOP;
12068
+ const TIMED_PLUGIN_HOOKS = ['load', 'resolveDynamicImport', 'resolveId', 'transform'];
12083
12069
  function getPluginWithTimers(plugin, index) {
12084
12070
  const timedPlugin = {};
12085
- for (const hook of Object.keys(plugin)) {
12086
- if (TIMED_PLUGIN_HOOKS[hook] === true) {
12071
+ for (const hook of TIMED_PLUGIN_HOOKS) {
12072
+ if (hook in plugin) {
12087
12073
  let timerLabel = `plugin ${index}`;
12088
12074
  if (plugin.name) {
12089
12075
  timerLabel += ` (${plugin.name})`;
@@ -12091,11 +12077,11 @@ function getPluginWithTimers(plugin, index) {
12091
12077
  timerLabel += ` - ${hook}`;
12092
12078
  timedPlugin[hook] = function (...args) {
12093
12079
  timeStart(timerLabel, 4);
12094
- let result = plugin[hook].apply(this === timedPlugin ? plugin : this, args);
12080
+ const result = plugin[hook](...args);
12095
12081
  timeEnd(timerLabel, 4);
12096
12082
  if (result && typeof result.then === 'function') {
12097
12083
  timeStart(`${timerLabel} (async)`, 4);
12098
- result = result.then((hookResult) => {
12084
+ return result.then((hookResult) => {
12099
12085
  timeEnd(`${timerLabel} (async)`, 4);
12100
12086
  return hookResult;
12101
12087
  });
@@ -12103,16 +12089,15 @@ function getPluginWithTimers(plugin, index) {
12103
12089
  return result;
12104
12090
  };
12105
12091
  }
12106
- else {
12107
- timedPlugin[hook] = plugin[hook];
12108
- }
12109
12092
  }
12110
- return timedPlugin;
12093
+ return {
12094
+ ...plugin,
12095
+ ...timedPlugin
12096
+ };
12111
12097
  }
12112
12098
  function initialiseTimers(inputOptions) {
12113
12099
  if (inputOptions.perf) {
12114
- timers = {};
12115
- setTimeHelpers();
12100
+ timers = new Map();
12116
12101
  timeStart = timeStartImpl;
12117
12102
  timeEnd = timeEndImpl;
12118
12103
  inputOptions.plugins = inputOptions.plugins.map(getPluginWithTimers);
@@ -12275,7 +12260,7 @@ class Module {
12275
12260
  }
12276
12261
  return module.isIncluded();
12277
12262
  },
12278
- meta,
12263
+ meta: { ...meta },
12279
12264
  syntheticNamedExports
12280
12265
  };
12281
12266
  }
@@ -12296,7 +12281,7 @@ class Module {
12296
12281
  return this.allExportNames;
12297
12282
  }
12298
12283
  const allExportNames = (this.allExportNames = new Set());
12299
- for (const name of Object.keys(this.exports)) {
12284
+ for (const name of this.getExports()) {
12300
12285
  allExportNames.add(name);
12301
12286
  }
12302
12287
  for (const name of Object.keys(this.reexportDescriptions)) {
@@ -12320,12 +12305,11 @@ class Module {
12320
12305
  const relevantDependencies = new Set();
12321
12306
  const necessaryDependencies = new Set();
12322
12307
  const alwaysCheckedDependencies = new Set();
12323
- let dependencyVariables = this.imports.keys();
12308
+ const dependencyVariables = new Set(this.imports);
12324
12309
  if (this.info.isEntry ||
12325
12310
  this.includedDynamicImporters.length > 0 ||
12326
12311
  this.namespace.included ||
12327
12312
  this.implicitlyLoadedAfter.size > 0) {
12328
- dependencyVariables = new Set(dependencyVariables);
12329
12313
  for (const exportName of [...this.getReexports(), ...this.getExports()]) {
12330
12314
  const exportedVariable = this.getVariableForExportName(exportName);
12331
12315
  if (exportedVariable) {
@@ -12798,11 +12782,7 @@ class Module {
12798
12782
  for (const specifier of node.specifiers) {
12799
12783
  const isDefault = specifier.type === ImportDefaultSpecifier$1;
12800
12784
  const isNamespace = specifier.type === ImportNamespaceSpecifier$1;
12801
- const name = isDefault
12802
- ? 'default'
12803
- : isNamespace
12804
- ? '*'
12805
- : specifier.imported.name;
12785
+ const name = isDefault ? 'default' : isNamespace ? '*' : specifier.imported.name;
12806
12786
  this.importDescriptions[specifier.local.name] = {
12807
12787
  module: null,
12808
12788
  name,
@@ -12949,7 +12929,7 @@ class Module {
12949
12929
  variable.include();
12950
12930
  this.graph.needsTreeshakingPass = true;
12951
12931
  const variableModule = variable.module;
12952
- if (variableModule && variableModule instanceof Module) {
12932
+ if (variableModule instanceof Module) {
12953
12933
  if (!variableModule.isExecuted) {
12954
12934
  markModuleAndImpureDependenciesAsExecuted(variableModule);
12955
12935
  }
@@ -14307,6 +14287,7 @@ class Chunk {
14307
14287
  this.implicitlyLoadedBefore = new Set();
14308
14288
  this.imports = new Set();
14309
14289
  this.indentString = undefined;
14290
+ // This may only be updated in the constructor
14310
14291
  this.isEmpty = true;
14311
14292
  this.name = null;
14312
14293
  this.renderedDependencies = null;
@@ -14492,7 +14473,7 @@ class Chunk {
14492
14473
  }), existingNames);
14493
14474
  }
14494
14475
  generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
14495
- const id = this.orderedModules[0].id;
14476
+ const [{ id }] = this.orderedModules;
14496
14477
  const sanitizedId = this.outputOptions.sanitizeFileName(id);
14497
14478
  let path;
14498
14479
  const patternOpt = unsetOptions.has('entryFileNames')
@@ -21589,9 +21570,9 @@ function writeFile(dest, data) {
21589
21570
  }
21590
21571
 
21591
21572
  class Queue {
21592
- constructor(maxParallel = 1) {
21573
+ constructor(maxParallel) {
21593
21574
  this.maxParallel = maxParallel;
21594
- this.queue = new Array();
21575
+ this.queue = [];
21595
21576
  this.workerCount = 0;
21596
21577
  }
21597
21578
  run(task) {
@@ -21922,7 +21903,6 @@ async function transform(source, module, pluginDriver, warn) {
21922
21903
  ast,
21923
21904
  code,
21924
21905
  customTransformCache,
21925
- meta: module.info.meta,
21926
21906
  originalCode,
21927
21907
  originalSourcemap,
21928
21908
  sourcemapChain,
@@ -21942,7 +21922,6 @@ class ModuleLoader {
21942
21922
  this.moduleLoadPromises = new Map();
21943
21923
  this.modulesWithLoadedDependencies = new Set();
21944
21924
  this.nextEntryModuleIndex = 0;
21945
- this.readQueue = new Queue();
21946
21925
  this.resolveId = async (source, importer, customOptions, isEntry, skip = null) => {
21947
21926
  return this.addDefaultsToResolvedId(this.getNormalizedResolvedIdWithoutDefaults(this.options.external(source, importer, false)
21948
21927
  ? false
@@ -21951,7 +21930,7 @@ class ModuleLoader {
21951
21930
  this.hasModuleSideEffects = options.treeshake
21952
21931
  ? options.treeshake.moduleSideEffects
21953
21932
  : () => true;
21954
- this.readQueue.maxParallel = options.maxParallelFileReads;
21933
+ this.readQueue = new Queue(options.maxParallelFileReads);
21955
21934
  }
21956
21935
  async addAdditionalModules(unresolvedModules) {
21957
21936
  const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))));
@@ -22002,8 +21981,9 @@ class ModuleLoader {
22002
21981
  }
22003
21982
  return module;
22004
21983
  }
22005
- preloadModule(resolvedId) {
22006
- return this.fetchModule(this.addDefaultsToResolvedId(resolvedId), undefined, false, true).then(module => module.info);
21984
+ async preloadModule(resolvedId) {
21985
+ const module = await this.fetchModule(this.addDefaultsToResolvedId(resolvedId), undefined, false, true);
21986
+ return module.info;
22007
21987
  }
22008
21988
  addDefaultsToResolvedId(resolvedId) {
22009
21989
  var _a, _b;
@@ -22053,13 +22033,23 @@ class ModuleLoader {
22053
22033
  timeEnd('load modules', 3);
22054
22034
  const sourceDescription = typeof source === 'string'
22055
22035
  ? { code: source }
22056
- : typeof source === 'object' && typeof source.code === 'string'
22036
+ : source != null && typeof source === 'object' && typeof source.code === 'string'
22057
22037
  ? source
22058
22038
  : error(errBadLoader(id));
22059
22039
  const cachedModule = this.graph.cachedModules.get(id);
22060
22040
  if (cachedModule &&
22061
22041
  !cachedModule.customTransformCache &&
22062
- cachedModule.originalCode === sourceDescription.code) {
22042
+ cachedModule.originalCode === sourceDescription.code &&
22043
+ !(await this.pluginDriver.hookFirst('shouldTransformCachedModule', [
22044
+ {
22045
+ ast: cachedModule.ast,
22046
+ code: cachedModule.code,
22047
+ id: cachedModule.id,
22048
+ meta: cachedModule.meta,
22049
+ moduleSideEffects: cachedModule.moduleSideEffects,
22050
+ syntheticNamedExports: cachedModule.syntheticNamedExports
22051
+ }
22052
+ ]))) {
22063
22053
  if (cachedModule.transformFiles) {
22064
22054
  for (const emittedFile of cachedModule.transformFiles)
22065
22055
  this.pluginDriver.emitFile(emittedFile);
@@ -22495,6 +22485,7 @@ const inputHookNames = {
22495
22485
  options: 1,
22496
22486
  resolveDynamicImport: 1,
22497
22487
  resolveId: 1,
22488
+ shouldTransformCachedModule: 1,
22498
22489
  transform: 1,
22499
22490
  watchChange: 1
22500
22491
  };
@@ -1,21 +1,22 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.63.0
4
- Tue, 04 Jan 2022 07:30:25 GMT - commit ae674c9edde5efb8ce6d8ef845598a805938178c
3
+ Rollup.js v2.64.0
4
+ Fri, 14 Jan 2022 14:02:32 GMT - commit 82a3e2634a9d51b5040752e4fb2fd264651d504e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
9
9
  Released under the MIT License.
10
10
  */
11
- import * as require$$0$1 from 'path';
12
- import require$$0__default from 'path';
11
+ import require$$0$1, { resolve } from 'path';
13
12
  import { defaultOnWarn, ensureArray, warnUnknownOptions, objectifyOptionWithPresets, treeshakePresets, objectifyOption, generatedCodePresets, picomatch as picomatch$2, getAugmentedNamespace, fseventsImporter, createFilter, rollupInternal } from './rollup.js';
14
13
  import require$$2$1, { platform } from 'os';
15
14
  import require$$0$2 from 'events';
16
15
  import fs$4 from 'fs';
17
16
  import require$$2 from 'util';
18
17
  import require$$1 from 'stream';
18
+ import 'process';
19
+ import 'perf_hooks';
19
20
  import 'crypto';
20
21
 
21
22
  const commandAliases = {
@@ -177,7 +178,7 @@ var chokidar$1 = {};
177
178
 
178
179
  const fs$3 = fs$4;
179
180
  const { Readable } = require$$1;
180
- const sysPath$3 = require$$0__default;
181
+ const sysPath$3 = require$$0$1;
181
182
  const { promisify: promisify$3 } = require$$2;
182
183
  const picomatch$1 = picomatch$2;
183
184
 
@@ -775,7 +776,7 @@ var isGlob$2 = function isGlob(str, options) {
775
776
  };
776
777
 
777
778
  var isGlob$1 = isGlob$2;
778
- var pathPosixDirname = require$$0__default.posix.dirname;
779
+ var pathPosixDirname = require$$0$1.posix.dirname;
779
780
  var isWin32 = require$$2$1.platform() === 'win32';
780
781
 
781
782
  var slash = '/';
@@ -2498,7 +2499,7 @@ const require$$0 = [
2498
2499
 
2499
2500
  var binaryExtensions$1 = require$$0;
2500
2501
 
2501
- const path = require$$0__default;
2502
+ const path = require$$0$1;
2502
2503
  const binaryExtensions = binaryExtensions$1;
2503
2504
 
2504
2505
  const extensions = new Set(binaryExtensions);
@@ -2509,7 +2510,7 @@ var constants = {};
2509
2510
 
2510
2511
  (function (exports) {
2511
2512
 
2512
- const {sep} = require$$0__default;
2513
+ const {sep} = require$$0$1;
2513
2514
  const {platform} = process;
2514
2515
  const os = require$$2$1;
2515
2516
 
@@ -2575,7 +2576,7 @@ exports.isIBMi = os.type() === 'OS400';
2575
2576
  }(constants));
2576
2577
 
2577
2578
  const fs$2 = fs$4;
2578
- const sysPath$2 = require$$0__default;
2579
+ const sysPath$2 = require$$0$1;
2579
2580
  const { promisify: promisify$2 } = require$$2;
2580
2581
  const isBinaryPath = isBinaryPath$1;
2581
2582
  const {
@@ -3214,7 +3215,7 @@ var fseventsHandler = {exports: {}};
3214
3215
  const require$$3 = /*@__PURE__*/getAugmentedNamespace(fseventsImporter);
3215
3216
 
3216
3217
  const fs$1 = fs$4;
3217
- const sysPath$1 = require$$0__default;
3218
+ const sysPath$1 = require$$0$1;
3218
3219
  const { promisify: promisify$1 } = require$$2;
3219
3220
 
3220
3221
  let fsevents;
@@ -3738,7 +3739,7 @@ fseventsHandler.exports.canUse = canUse;
3738
3739
 
3739
3740
  const { EventEmitter } = require$$0$2;
3740
3741
  const fs = fs$4;
3741
- const sysPath = require$$0__default;
3742
+ const sysPath = require$$0$1;
3742
3743
  const { promisify } = require$$2;
3743
3744
  const readdirp = readdirp_1;
3744
3745
  const anymatch = anymatch$2.exports.default;
@@ -4732,8 +4733,9 @@ class FileWatcher {
4732
4733
  }
4733
4734
  }
4734
4735
  watch(id, isTransformDependency) {
4736
+ var _a;
4735
4737
  if (isTransformDependency) {
4736
- const watcher = this.transformWatchers.get(id) || this.createWatcher(id);
4738
+ const watcher = (_a = this.transformWatchers.get(id)) !== null && _a !== void 0 ? _a : this.createWatcher(id);
4737
4739
  watcher.add(id);
4738
4740
  this.transformWatchers.set(id, watcher);
4739
4741
  }
@@ -4868,7 +4870,7 @@ class Task {
4868
4870
  this.outputs = this.options.output;
4869
4871
  this.outputFiles = this.outputs.map(output => {
4870
4872
  if (output.file || output.dir)
4871
- return require$$0$1.resolve(output.file || output.dir);
4873
+ return resolve(output.file || output.dir);
4872
4874
  return undefined;
4873
4875
  });
4874
4876
  const watchOptions = this.options.watch || {};
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.63.0
4
- Tue, 04 Jan 2022 07:30:25 GMT - commit ae674c9edde5efb8ce6d8ef845598a805938178c
3
+ Rollup.js v2.64.0
4
+ Fri, 14 Jan 2022 14:02:32 GMT - commit 82a3e2634a9d51b5040752e4fb2fd264651d504e
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -18,6 +18,7 @@ require('./shared/rollup.js');
18
18
  require('./shared/mergeOptions.js');
19
19
  require('process');
20
20
  require('tty');
21
+ require('perf_hooks');
21
22
  require('crypto');
22
23
  require('events');
23
24