rollup 2.66.1 → 2.67.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/rollup.d.ts CHANGED
@@ -156,13 +156,14 @@ export type EmitChunk = (id: string, options?: { name?: string }) => string;
156
156
 
157
157
  export type EmitFile = (emittedFile: EmittedFile) => string;
158
158
 
159
- interface ModuleInfo {
159
+ interface ModuleInfo extends ModuleOptions {
160
160
  ast: AcornNode | null;
161
161
  code: string | null;
162
162
  dynamicImporters: readonly string[];
163
163
  dynamicallyImportedIdResolutions: readonly ResolvedId[];
164
164
  dynamicallyImportedIds: readonly string[];
165
165
  hasDefaultExport: boolean | null;
166
+ /** @deprecated Use `moduleSideEffects` instead */
166
167
  hasModuleSideEffects: boolean | 'no-treeshake';
167
168
  id: string;
168
169
  implicitlyLoadedAfterOneOf: readonly string[];
@@ -173,8 +174,6 @@ interface ModuleInfo {
173
174
  isEntry: boolean;
174
175
  isExternal: boolean;
175
176
  isIncluded: boolean | null;
176
- meta: CustomPluginOptions;
177
- syntheticNamedExports: boolean | string;
178
177
  }
179
178
 
180
179
  export type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
package/dist/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.66.1
4
- Tue, 25 Jan 2022 07:58:28 GMT - commit f523f0098d3e98f87abef54f48f39d06a7cc7eec
3
+ Rollup.js v2.67.0
4
+ Wed, 02 Feb 2022 06:19:08 GMT - commit 61d772ba59be605e53e72613ae51cee4b72aee64
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.66.1
4
- Tue, 25 Jan 2022 07:58:28 GMT - commit f523f0098d3e98f87abef54f48f39d06a7cc7eec
3
+ Rollup.js v2.67.0
4
+ Wed, 02 Feb 2022 06:19:08 GMT - commit 61d772ba59be605e53e72613ae51cee4b72aee64
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -10,9 +10,9 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- const require$$0$2 = require('events');
14
- const fs$4 = require('fs');
15
- const require$$0$1 = require('path');
13
+ const require$$0$3 = require('events');
14
+ const require$$0$1 = require('fs');
15
+ const require$$0$2 = require('path');
16
16
  const require$$2 = require('util');
17
17
  const require$$1 = require('stream');
18
18
  const rollup = require('./rollup.js');
@@ -20,9 +20,9 @@ const require$$2$1 = require('os');
20
20
 
21
21
  var chokidar$1 = {};
22
22
 
23
- const fs$3 = fs$4;
23
+ const fs$3 = require$$0$1;
24
24
  const { Readable } = require$$1;
25
- const sysPath$3 = require$$0$1;
25
+ const sysPath$3 = require$$0$2;
26
26
  const { promisify: promisify$3 } = require$$2;
27
27
  const picomatch$1 = rollup.picomatch;
28
28
 
@@ -620,7 +620,7 @@ var isGlob$2 = function isGlob(str, options) {
620
620
  };
621
621
 
622
622
  var isGlob$1 = isGlob$2;
623
- var pathPosixDirname = require$$0$1.posix.dirname;
623
+ var pathPosixDirname = require$$0$2.posix.dirname;
624
624
  var isWin32 = require$$2$1.platform() === 'win32';
625
625
 
626
626
  var slash = '/';
@@ -2343,7 +2343,7 @@ const require$$0 = [
2343
2343
 
2344
2344
  var binaryExtensions$1 = require$$0;
2345
2345
 
2346
- const path = require$$0$1;
2346
+ const path = require$$0$2;
2347
2347
  const binaryExtensions = binaryExtensions$1;
2348
2348
 
2349
2349
  const extensions = new Set(binaryExtensions);
@@ -2354,7 +2354,7 @@ var constants = {};
2354
2354
 
2355
2355
  (function (exports) {
2356
2356
 
2357
- const {sep} = require$$0$1;
2357
+ const {sep} = require$$0$2;
2358
2358
  const {platform} = process;
2359
2359
  const os = require$$2$1;
2360
2360
 
@@ -2419,8 +2419,8 @@ exports.isLinux = platform === 'linux';
2419
2419
  exports.isIBMi = os.type() === 'OS400';
2420
2420
  }(constants));
2421
2421
 
2422
- const fs$2 = fs$4;
2423
- const sysPath$2 = require$$0$1;
2422
+ const fs$2 = require$$0$1;
2423
+ const sysPath$2 = require$$0$2;
2424
2424
  const { promisify: promisify$2 } = require$$2;
2425
2425
  const isBinaryPath = isBinaryPath$1;
2426
2426
  const {
@@ -3066,8 +3066,8 @@ var fseventsHandler = {exports: {}};
3066
3066
 
3067
3067
  const require$$3 = /*@__PURE__*/rollup.getAugmentedNamespace(rollup.fseventsImporter);
3068
3068
 
3069
- const fs$1 = fs$4;
3070
- const sysPath$1 = require$$0$1;
3069
+ const fs$1 = require$$0$1;
3070
+ const sysPath$1 = require$$0$2;
3071
3071
  const { promisify: promisify$1 } = require$$2;
3072
3072
 
3073
3073
  let fsevents;
@@ -3589,9 +3589,9 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
3589
3589
  fseventsHandler.exports = FsEventsHandler$1;
3590
3590
  fseventsHandler.exports.canUse = canUse;
3591
3591
 
3592
- const { EventEmitter } = require$$0$2;
3593
- const fs = fs$4;
3594
- const sysPath = require$$0$1;
3592
+ const { EventEmitter } = require$$0$3;
3593
+ const fs = require$$0$1;
3594
+ const sysPath = require$$0$2;
3595
3595
  const { promisify } = require$$2;
3596
3596
  const readdirp = readdirp_1;
3597
3597
  const anymatch = anymatch$2.exports.default;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.66.1
4
- Tue, 25 Jan 2022 07:58:28 GMT - commit f523f0098d3e98f87abef54f48f39d06a7cc7eec
3
+ Rollup.js v2.67.0
4
+ Wed, 02 Feb 2022 06:19:08 GMT - commit 61d772ba59be605e53e72613ae51cee4b72aee64
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -10,7 +10,7 @@
10
10
  */
11
11
  'use strict';
12
12
 
13
- const fs = require('fs');
13
+ const require$$0$1 = require('fs');
14
14
  const require$$0 = require('path');
15
15
  const url = require('url');
16
16
  const process$1 = require('process');
@@ -610,7 +610,7 @@ async function getDefaultFromTranspiledConfigFile(fileName, commandOptions) {
610
610
  return loadConfigFromBundledFile(fileName, code);
611
611
  }
612
612
  async function loadConfigFromBundledFile(fileName, bundledCode) {
613
- const resolvedFileName = fs.realpathSync(fileName);
613
+ const resolvedFileName = await require$$0$1.promises.realpath(fileName);
614
614
  const extension = require$$0.extname(resolvedFileName);
615
615
  const defaultLoader = require.extensions[extension];
616
616
  require.extensions[extension] = (module, requiredFileName) => {
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.66.1
4
- Tue, 25 Jan 2022 07:58:28 GMT - commit f523f0098d3e98f87abef54f48f39d06a7cc7eec
3
+ Rollup.js v2.67.0
4
+ Wed, 02 Feb 2022 06:19:08 GMT - commit 61d772ba59be605e53e72613ae51cee4b72aee64
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v2.66.1
4
- Tue, 25 Jan 2022 07:58:28 GMT - commit f523f0098d3e98f87abef54f48f39d06a7cc7eec
3
+ Rollup.js v2.67.0
4
+ Wed, 02 Feb 2022 06:19:08 GMT - commit 61d772ba59be605e53e72613ae51cee4b72aee64
5
5
 
6
6
 
7
7
  https://github.com/rollup/rollup
@@ -14,8 +14,8 @@ const require$$0 = require('path');
14
14
  const process$1 = require('process');
15
15
  const perf_hooks = require('perf_hooks');
16
16
  const crypto = require('crypto');
17
- const fs = require('fs');
18
- const require$$0$1 = require('events');
17
+ const require$$0$1 = require('fs');
18
+ const require$$0$2 = require('events');
19
19
 
20
20
  function _interopNamespaceDefault(e) {
21
21
  const n = Object.create(null);
@@ -28,7 +28,7 @@ function _interopNamespaceDefault(e) {
28
28
  return n;
29
29
  }
30
30
 
31
- var version$1 = "2.66.1";
31
+ var version$1 = "2.67.0";
32
32
 
33
33
  function ensureArray$1(items) {
34
34
  if (Array.isArray(items)) {
@@ -2322,7 +2322,7 @@ function makeLegal(str) {
2322
2322
  }
2323
2323
 
2324
2324
  class ExternalModule {
2325
- constructor(options, id, hasModuleSideEffects, meta, renormalizeRenderPath) {
2325
+ constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath) {
2326
2326
  this.options = options;
2327
2327
  this.id = id;
2328
2328
  this.renormalizeRenderPath = renormalizeRenderPath;
@@ -2341,7 +2341,7 @@ class ExternalModule {
2341
2341
  this.variableName = '';
2342
2342
  this.suggestedVariableName = makeLegal(id.split(/[\\/]/).pop());
2343
2343
  const { importers, dynamicImporters } = this;
2344
- this.info = {
2344
+ const info = (this.info = {
2345
2345
  ast: null,
2346
2346
  code: null,
2347
2347
  dynamicallyImportedIdResolutions: EMPTY_ARRAY,
@@ -2350,7 +2350,10 @@ class ExternalModule {
2350
2350
  return dynamicImporters.sort();
2351
2351
  },
2352
2352
  hasDefaultExport: null,
2353
- hasModuleSideEffects,
2353
+ get hasModuleSideEffects() {
2354
+ warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', false, options);
2355
+ return info.moduleSideEffects;
2356
+ },
2354
2357
  id,
2355
2358
  implicitlyLoadedAfterOneOf: EMPTY_ARRAY,
2356
2359
  implicitlyLoadedBefore: EMPTY_ARRAY,
@@ -2363,8 +2366,14 @@ class ExternalModule {
2363
2366
  isExternal: true,
2364
2367
  isIncluded: null,
2365
2368
  meta,
2369
+ moduleSideEffects,
2366
2370
  syntheticNamedExports: false
2367
- };
2371
+ });
2372
+ // Hide the deprecated key so that it only warns when accessed explicitly
2373
+ Object.defineProperty(this.info, 'hasModuleSideEffects', {
2374
+ ...Object.getOwnPropertyDescriptor(this.info, 'hasModuleSideEffects'),
2375
+ enumerable: false
2376
+ });
2368
2377
  }
2369
2378
  getVariableForExportName(name) {
2370
2379
  let declaration = this.declarations[name];
@@ -4906,15 +4915,6 @@ exports.SOURCEMAPPING_URL += 'ppingURL';
4906
4915
  const whiteSpaceNoNewline = '[ \\f\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]';
4907
4916
  const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${exports.SOURCEMAPPING_URL}=.+`);
4908
4917
 
4909
- // patch up acorn-walk until class-fields are officially supported
4910
- base$1.PropertyDefinition = function (node, st, c) {
4911
- if (node.computed) {
4912
- c(node.key, st, 'Expression');
4913
- }
4914
- if (node.value) {
4915
- c(node.value, st, 'Expression');
4916
- }
4917
- };
4918
4918
  const ANNOTATION_KEY = '_rollupAnnotations';
4919
4919
  const INVALID_COMMENT_KEY = '_rollupRemoved';
4920
4920
  function handlePureAnnotationsOfNode(node, state, type = node.type) {
@@ -8643,6 +8643,8 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
8643
8643
  flat: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
8644
8644
  flatMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
8645
8645
  forEach: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8646
+ groupBy: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8647
+ groupByToMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
8646
8648
  includes: METHOD_RETURNS_BOOLEAN,
8647
8649
  indexOf: METHOD_RETURNS_NUMBER,
8648
8650
  join: METHOD_RETURNS_STRING,
@@ -12253,7 +12255,7 @@ function markModuleAndImpureDependenciesAsExecuted(baseModule) {
12253
12255
  for (const dependency of [...module.dependencies, ...module.implicitlyLoadedBefore]) {
12254
12256
  if (!(dependency instanceof ExternalModule) &&
12255
12257
  !dependency.isExecuted &&
12256
- (dependency.info.hasModuleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
12258
+ (dependency.info.moduleSideEffects || module.implicitlyLoadedBefore.has(dependency)) &&
12257
12259
  !visitedModules.has(dependency.id)) {
12258
12260
  dependency.isExecuted = true;
12259
12261
  visitedModules.add(dependency.id);
@@ -12311,7 +12313,7 @@ function getAndExtendSideEffectModules(variable, module) {
12311
12313
  return sideEffectModules;
12312
12314
  }
12313
12315
  class Module {
12314
- constructor(graph, id, options, isEntry, hasModuleSideEffects, syntheticNamedExports, meta) {
12316
+ constructor(graph, id, options, isEntry, moduleSideEffects, syntheticNamedExports, meta) {
12315
12317
  this.graph = graph;
12316
12318
  this.id = id;
12317
12319
  this.options = options;
@@ -12358,17 +12360,18 @@ class Module {
12358
12360
  this.preserveSignature = this.options.preserveEntrySignatures;
12359
12361
  // eslint-disable-next-line @typescript-eslint/no-this-alias
12360
12362
  const module = this;
12363
+ const { dynamicImports, dynamicImporters, reexportDescriptions, implicitlyLoadedAfter, implicitlyLoadedBefore, sources, importers } = this;
12361
12364
  this.info = {
12362
12365
  ast: null,
12363
12366
  code: null,
12364
12367
  get dynamicallyImportedIdResolutions() {
12365
- return module.dynamicImports
12368
+ return dynamicImports
12366
12369
  .map(({ argument }) => typeof argument === 'string' && module.resolvedIds[argument])
12367
12370
  .filter(Boolean);
12368
12371
  },
12369
12372
  get dynamicallyImportedIds() {
12370
12373
  const dynamicallyImportedIds = [];
12371
- for (const { id } of module.dynamicImports) {
12374
+ for (const { id } of dynamicImports) {
12372
12375
  if (id) {
12373
12376
  dynamicallyImportedIds.push(id);
12374
12377
  }
@@ -12376,43 +12379,52 @@ class Module {
12376
12379
  return dynamicallyImportedIds;
12377
12380
  },
12378
12381
  get dynamicImporters() {
12379
- return module.dynamicImporters.sort();
12382
+ return dynamicImporters.sort();
12380
12383
  },
12381
12384
  get hasDefaultExport() {
12382
12385
  // This information is only valid after parsing
12383
12386
  if (!module.ast) {
12384
12387
  return null;
12385
12388
  }
12386
- return 'default' in module.exports || 'default' in module.reexportDescriptions;
12389
+ return 'default' in module.exports || 'default' in reexportDescriptions;
12390
+ },
12391
+ get hasModuleSideEffects() {
12392
+ warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', false, options);
12393
+ return module.info.moduleSideEffects;
12387
12394
  },
12388
- hasModuleSideEffects,
12389
12395
  id,
12390
12396
  get implicitlyLoadedAfterOneOf() {
12391
- return Array.from(module.implicitlyLoadedAfter, getId).sort();
12397
+ return Array.from(implicitlyLoadedAfter, getId).sort();
12392
12398
  },
12393
12399
  get implicitlyLoadedBefore() {
12394
- return Array.from(module.implicitlyLoadedBefore, getId).sort();
12400
+ return Array.from(implicitlyLoadedBefore, getId).sort();
12395
12401
  },
12396
12402
  get importedIdResolutions() {
12397
- return Array.from(module.sources, source => module.resolvedIds[source]).filter(Boolean);
12403
+ return Array.from(sources, source => module.resolvedIds[source]).filter(Boolean);
12398
12404
  },
12399
12405
  get importedIds() {
12400
- return Array.from(module.sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
12406
+ return Array.from(sources, source => { var _a; return (_a = module.resolvedIds[source]) === null || _a === void 0 ? void 0 : _a.id; }).filter(Boolean);
12401
12407
  },
12402
12408
  get importers() {
12403
- return module.importers.sort();
12409
+ return importers.sort();
12404
12410
  },
12405
12411
  isEntry,
12406
12412
  isExternal: false,
12407
12413
  get isIncluded() {
12408
- if (module.graph.phase !== BuildPhase.GENERATE) {
12414
+ if (graph.phase !== BuildPhase.GENERATE) {
12409
12415
  return null;
12410
12416
  }
12411
12417
  return module.isIncluded();
12412
12418
  },
12413
12419
  meta: { ...meta },
12420
+ moduleSideEffects,
12414
12421
  syntheticNamedExports
12415
12422
  };
12423
+ // Hide the deprecated key so that it only warns when accessed explicitly
12424
+ Object.defineProperty(this.info, 'hasModuleSideEffects', {
12425
+ ...Object.getOwnPropertyDescriptor(this.info, 'hasModuleSideEffects'),
12426
+ enumerable: false
12427
+ });
12416
12428
  }
12417
12429
  basename() {
12418
12430
  const base = require$$0.basename(this.id);
@@ -12487,7 +12499,7 @@ class Module {
12487
12499
  }
12488
12500
  necessaryDependencies.add(variable.module);
12489
12501
  }
12490
- if (!this.options.treeshake || this.info.hasModuleSideEffects === 'no-treeshake') {
12502
+ if (!this.options.treeshake || this.info.moduleSideEffects === 'no-treeshake') {
12491
12503
  for (const dependency of this.dependencies) {
12492
12504
  relevantDependencies.add(dependency);
12493
12505
  }
@@ -12637,7 +12649,7 @@ class Module {
12637
12649
  return [null];
12638
12650
  }
12639
12651
  hasEffects() {
12640
- return (this.info.hasModuleSideEffects === 'no-treeshake' ||
12652
+ return (this.info.moduleSideEffects === 'no-treeshake' ||
12641
12653
  (this.ast.included && this.ast.hasEffects(createHasEffectsContext())));
12642
12654
  }
12643
12655
  include() {
@@ -12769,7 +12781,7 @@ class Module {
12769
12781
  dependencies: Array.from(this.dependencies, getId),
12770
12782
  id: this.id,
12771
12783
  meta: this.info.meta,
12772
- moduleSideEffects: this.info.hasModuleSideEffects,
12784
+ moduleSideEffects: this.info.moduleSideEffects,
12773
12785
  originalCode: this.originalCode,
12774
12786
  originalSourcemap: this.originalSourcemap,
12775
12787
  resolvedIds: this.resolvedIds,
@@ -12821,7 +12833,7 @@ class Module {
12821
12833
  }
12822
12834
  updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
12823
12835
  if (moduleSideEffects != null) {
12824
- this.info.hasModuleSideEffects = moduleSideEffects;
12836
+ this.info.moduleSideEffects = moduleSideEffects;
12825
12837
  }
12826
12838
  if (syntheticNamedExports != null) {
12827
12839
  this.info.syntheticNamedExports = syntheticNamedExports;
@@ -12975,7 +12987,7 @@ class Module {
12975
12987
  relevantDependencies.add(dependency);
12976
12988
  continue;
12977
12989
  }
12978
- if (!(dependency.info.hasModuleSideEffects || alwaysCheckedDependencies.has(dependency))) {
12990
+ if (!(dependency.info.moduleSideEffects || alwaysCheckedDependencies.has(dependency))) {
12979
12991
  continue;
12980
12992
  }
12981
12993
  if (dependency instanceof ExternalModule || dependency.hasEffects()) {
@@ -14026,10 +14038,8 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
14026
14038
  const moduleSources = modules
14027
14039
  .filter(module => !module.excludeFromSourcemap)
14028
14040
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
14029
- // DecodedSourceMap (from magic-string) uses a number[] instead of the more
14030
- // correct SourceMapSegment tuples. Cast it here to gain type safety.
14031
- let source = new Link(map, moduleSources);
14032
- source = bundleSourcemapChain.reduce(linkMap, source);
14041
+ const link = new Link(map, moduleSources);
14042
+ const source = bundleSourcemapChain.reduce(linkMap, link);
14033
14043
  let { sources, sourcesContent, names, mappings } = source.traceMappings();
14034
14044
  if (file) {
14035
14045
  const directory = require$$0.dirname(file);
@@ -14320,13 +14330,7 @@ function decodedSourcemap(map) {
14320
14330
  version: 3
14321
14331
  };
14322
14332
  }
14323
- let mappings;
14324
- if (typeof map.mappings === 'string') {
14325
- mappings = decode(map.mappings);
14326
- }
14327
- else {
14328
- mappings = map.mappings;
14329
- }
14333
+ const mappings = typeof map.mappings === 'string' ? decode(map.mappings) : map.mappings;
14330
14334
  return { ...map, mappings };
14331
14335
  }
14332
14336
 
@@ -14472,7 +14476,7 @@ class Chunk {
14472
14476
  chunk.dependencies.add(dependency instanceof Module ? chunkByModule.get(dependency) : dependency);
14473
14477
  }
14474
14478
  if (!chunk.dependencies.has(chunkByModule.get(facadedModule)) &&
14475
- facadedModule.info.hasModuleSideEffects &&
14479
+ facadedModule.info.moduleSideEffects &&
14476
14480
  facadedModule.hasEffects()) {
14477
14481
  chunk.dependencies.add(chunkByModule.get(facadedModule));
14478
14482
  }
@@ -14609,15 +14613,15 @@ class Chunk {
14609
14613
  }
14610
14614
  generateIdPreserveModules(preserveModulesRelativeDir, options, existingNames, unsetOptions) {
14611
14615
  const [{ id }] = this.orderedModules;
14612
- const sanitizedId = this.outputOptions.sanitizeFileName(id);
14616
+ const sanitizedId = this.outputOptions.sanitizeFileName(id.split(QUERY_HASH_REGEX, 1)[0]);
14613
14617
  let path;
14614
14618
  const patternOpt = unsetOptions.has('entryFileNames')
14615
14619
  ? '[name][assetExtname].js'
14616
14620
  : options.entryFileNames;
14617
14621
  const pattern = typeof patternOpt === 'function' ? patternOpt(this.getChunkInfo()) : patternOpt;
14618
- if (isAbsolute(id)) {
14622
+ if (isAbsolute(sanitizedId)) {
14619
14623
  const currentDir = require$$0.dirname(sanitizedId);
14620
- const extension = require$$0.extname(id);
14624
+ const extension = require$$0.extname(sanitizedId);
14621
14625
  const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
14622
14626
  assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
14623
14627
  ext: () => extension.substr(1),
@@ -15409,6 +15413,7 @@ class Chunk {
15409
15413
  function getChunkNameFromModule(module) {
15410
15414
  return module.chunkName || getAliasName(module.id);
15411
15415
  }
15416
+ const QUERY_HASH_REGEX = /[?#]/;
15412
15417
 
15413
15418
  function generateAssetFileName(name, source, outputOptions, bundle) {
15414
15419
  const emittedName = outputOptions.sanitizeFileName(name || 'asset');
@@ -21717,25 +21722,6 @@ Parser.acorn = {
21717
21722
  nonASCIIwhitespace: nonASCIIwhitespace
21718
21723
  };
21719
21724
 
21720
- const readFile = (file) => new Promise((fulfil, reject) => fs.readFile(file, 'utf-8', (err, contents) => (err ? reject(err) : fulfil(contents))));
21721
- function mkdirpath(path) {
21722
- const dir = require$$0.dirname(path);
21723
- fs.mkdirSync(dir, { recursive: true });
21724
- }
21725
- function writeFile(dest, data) {
21726
- return new Promise((fulfil, reject) => {
21727
- mkdirpath(dest);
21728
- fs.writeFile(dest, data, err => {
21729
- if (err) {
21730
- reject(err);
21731
- }
21732
- else {
21733
- fulfil();
21734
- }
21735
- });
21736
- });
21737
- }
21738
-
21739
21725
  class Queue {
21740
21726
  constructor(maxParallel) {
21741
21727
  this.maxParallel = maxParallel;
@@ -21802,25 +21788,19 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
21802
21788
  return addJsExtensionIfNecessary(importer ? require$$0.resolve(require$$0.dirname(importer), source) : require$$0.resolve(source), preserveSymlinks);
21803
21789
  }
21804
21790
  function addJsExtensionIfNecessary(file, preserveSymlinks) {
21805
- let found = findFile(file, preserveSymlinks);
21806
- if (found)
21807
- return found;
21808
- found = findFile(file + '.mjs', preserveSymlinks);
21809
- if (found)
21810
- return found;
21811
- found = findFile(file + '.js', preserveSymlinks);
21812
- return found;
21791
+ var _a, _b;
21792
+ return ((_b = (_a = findFile(file, preserveSymlinks)) !== null && _a !== void 0 ? _a : findFile(file + '.mjs', preserveSymlinks)) !== null && _b !== void 0 ? _b : findFile(file + '.js', preserveSymlinks));
21813
21793
  }
21814
21794
  function findFile(file, preserveSymlinks) {
21815
21795
  try {
21816
- const stats = fs.lstatSync(file);
21796
+ const stats = require$$0$1.lstatSync(file);
21817
21797
  if (!preserveSymlinks && stats.isSymbolicLink())
21818
- return findFile(fs.realpathSync(file), preserveSymlinks);
21798
+ return findFile(require$$0$1.realpathSync(file), preserveSymlinks);
21819
21799
  if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
21820
21800
  // check case
21821
21801
  const name = require$$0.basename(file);
21822
- const files = fs.readdirSync(require$$0.dirname(file));
21823
- if (files.indexOf(name) !== -1)
21802
+ const files = require$$0$1.readdirSync(require$$0.dirname(file));
21803
+ if (files.includes(name))
21824
21804
  return file;
21825
21805
  }
21826
21806
  }
@@ -22173,7 +22153,7 @@ class ModuleLoader {
22173
22153
  timeStart('load modules', 3);
22174
22154
  let source;
22175
22155
  try {
22176
- source = await this.readQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await readFile(id)); });
22156
+ source = await this.readQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await require$$0$1.promises.readFile(id, 'utf8')); });
22177
22157
  }
22178
22158
  catch (err) {
22179
22159
  timeEnd('load modules', 3);
@@ -22314,7 +22294,7 @@ class ModuleLoader {
22314
22294
  module.dependencies.add(dependency);
22315
22295
  dependency.importers.push(module.id);
22316
22296
  }
22317
- if (!this.options.treeshake || module.info.hasModuleSideEffects === 'no-treeshake') {
22297
+ if (!this.options.treeshake || module.info.moduleSideEffects === 'no-treeshake') {
22318
22298
  for (const dependency of module.dependencies) {
22319
22299
  if (dependency instanceof Module) {
22320
22300
  dependency.importedFromNotTreeshaken = true;
@@ -22422,10 +22402,8 @@ class ModuleLoader {
22422
22402
  syntheticNamedExports: false
22423
22403
  };
22424
22404
  }
22425
- else {
22426
- if (resolvedId.external && resolvedId.syntheticNamedExports) {
22427
- this.options.onwarn(errExternalSyntheticExports(source, importer));
22428
- }
22405
+ else if (resolvedId.external && resolvedId.syntheticNamedExports) {
22406
+ this.options.onwarn(errExternalSyntheticExports(source, importer));
22429
22407
  }
22430
22408
  return resolvedId;
22431
22409
  }
@@ -22675,7 +22653,6 @@ class PluginDriver {
22675
22653
  constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
22676
22654
  this.graph = graph;
22677
22655
  this.options = options;
22678
- this.pluginContexts = new Map();
22679
22656
  warnDeprecatedHooks(userPlugins, options);
22680
22657
  this.pluginCache = pluginCache;
22681
22658
  this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
@@ -22685,9 +22662,10 @@ class PluginDriver {
22685
22662
  this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
22686
22663
  this.plugins = userPlugins.concat(basePluginDriver ? basePluginDriver.plugins : []);
22687
22664
  const existingPluginNames = new Set();
22688
- for (const plugin of this.plugins) {
22689
- this.pluginContexts.set(plugin, getPluginContext(plugin, pluginCache, graph, options, this.fileEmitter, existingPluginNames));
22690
- }
22665
+ this.pluginContexts = new Map(this.plugins.map(plugin => [
22666
+ plugin,
22667
+ getPluginContext(plugin, pluginCache, graph, options, this.fileEmitter, existingPluginNames)
22668
+ ]));
22691
22669
  if (basePluginDriver) {
22692
22670
  for (const plugin of userPlugins) {
22693
22671
  for (const hook of inputHooks) {
@@ -23020,7 +22998,7 @@ class Graph {
23020
22998
  this.needsTreeshakingPass = false;
23021
22999
  for (const module of this.modules) {
23022
23000
  if (module.isExecuted) {
23023
- if (module.info.hasModuleSideEffects === 'no-treeshake') {
23001
+ if (module.info.moduleSideEffects === 'no-treeshake') {
23024
23002
  module.includeAllInBundle();
23025
23003
  }
23026
23004
  else {
@@ -23270,13 +23248,14 @@ const getHasModuleSideEffects = (moduleSideEffectsOption, pureExternalModules) =
23270
23248
 
23271
23249
  // https://datatracker.ietf.org/doc/html/rfc2396
23272
23250
  // eslint-disable-next-line no-control-regex
23273
- const INVALID_CHAR_RE = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
23251
+ const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g;
23252
+ const DRIVE_LETTER_REGEX = /^[a-z]:/i;
23274
23253
  function sanitizeFileName(name) {
23275
- const match = /^[a-z]:/i.exec(name);
23254
+ const match = DRIVE_LETTER_REGEX.exec(name);
23276
23255
  const driveLetter = match ? match[0] : '';
23277
23256
  // A `:` is only allowed as part of a windows drive letter (ex: C:\foo)
23278
23257
  // Otherwise, avoid them because they can refer to NTFS alternate data streams.
23279
- return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_RE, '_');
23258
+ return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_REGEX, '_');
23280
23259
  }
23281
23260
 
23282
23261
  function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
@@ -23497,7 +23476,14 @@ const getIndent = (config, compact) => {
23497
23476
  const configIndent = config.indent;
23498
23477
  return configIndent === false ? '' : configIndent !== null && configIndent !== void 0 ? configIndent : true;
23499
23478
  };
23500
- const ALLOWED_INTEROP_TYPES = new Set(['auto', 'esModule', 'default', 'defaultOnly', true, false]);
23479
+ const ALLOWED_INTEROP_TYPES = new Set([
23480
+ 'auto',
23481
+ 'esModule',
23482
+ 'default',
23483
+ 'defaultOnly',
23484
+ true,
23485
+ false
23486
+ ]);
23501
23487
  const getInterop = (config, inputOptions) => {
23502
23488
  const configInterop = config.interop;
23503
23489
  const validatedInteropTypes = new Set();
@@ -23682,8 +23668,10 @@ function getSortingFileType(file) {
23682
23668
  }
23683
23669
  return SortingFileType.SECONDARY_CHUNK;
23684
23670
  }
23685
- function writeOutputFile(outputFile, outputOptions) {
23671
+ async function writeOutputFile(outputFile, outputOptions) {
23686
23672
  const fileName = require$$0.resolve(outputOptions.dir || require$$0.dirname(outputOptions.file), outputFile.fileName);
23673
+ // 'recursive: true' does not throw if the folder structure, or parts of it, already exist
23674
+ await require$$0$1.promises.mkdir(require$$0.dirname(fileName), { recursive: true });
23687
23675
  let writeSourceMapPromise;
23688
23676
  let source;
23689
23677
  if (outputFile.type === 'asset') {
@@ -23698,14 +23686,14 @@ function writeOutputFile(outputFile, outputOptions) {
23698
23686
  }
23699
23687
  else {
23700
23688
  url = `${require$$0.basename(outputFile.fileName)}.map`;
23701
- writeSourceMapPromise = writeFile(`${fileName}.map`, outputFile.map.toString());
23689
+ writeSourceMapPromise = require$$0$1.promises.writeFile(`${fileName}.map`, outputFile.map.toString());
23702
23690
  }
23703
23691
  if (outputOptions.sourcemap !== 'hidden') {
23704
23692
  source += `//# ${exports.SOURCEMAPPING_URL}=${url}\n`;
23705
23693
  }
23706
23694
  }
23707
23695
  }
23708
- return Promise.all([writeFile(fileName, source), writeSourceMapPromise]);
23696
+ return Promise.all([require$$0$1.promises.writeFile(fileName, source), writeSourceMapPromise]);
23709
23697
  }
23710
23698
  /**
23711
23699
  * Auxiliary function for defining rollup configuration
@@ -23716,7 +23704,7 @@ function defineConfig(options) {
23716
23704
  return options;
23717
23705
  }
23718
23706
 
23719
- class WatchEmitter extends require$$0$1.EventEmitter {
23707
+ class WatchEmitter extends require$$0$2.EventEmitter {
23720
23708
  constructor() {
23721
23709
  super();
23722
23710
  // Allows more than 10 bundles to be watched without