rollup 3.0.0-1 → 3.0.0-4

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.0.0-1
4
- Fri, 08 Jul 2022 11:35:32 GMT - commit 48ce34db70ebc2b4c1be38e6b8b02881be90b9f1
3
+ Rollup.js v3.0.0-3
4
+ Mon, 15 Aug 2022 04:43:13 GMT - commit 84a4a595851ef71494b6f2ab558968bfbc148bdb
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -9,12 +9,13 @@
9
9
  */
10
10
  'use strict';
11
11
 
12
+ const node_path = require('node:path');
12
13
  const require$$0 = require('path');
13
- const process$1 = require('process');
14
- const perf_hooks = require('perf_hooks');
15
- const crypto = require('crypto');
16
- const require$$0$1 = require('fs');
17
- const require$$0$2 = require('events');
14
+ const process$1 = require('node:process');
15
+ const node_perf_hooks = require('node:perf_hooks');
16
+ const node_crypto = require('node:crypto');
17
+ const node_fs = require('node:fs');
18
+ const node_events = require('node:events');
18
19
 
19
20
  function _interopNamespaceDefault(e) {
20
21
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
@@ -27,7 +28,7 @@ function _interopNamespaceDefault(e) {
27
28
  return n;
28
29
  }
29
30
 
30
- var version$1 = "3.0.0-1";
31
+ var version$1 = "3.0.0-3";
31
32
 
32
33
  function ensureArray$1(items) {
33
34
  if (Array.isArray(items)) {
@@ -162,13 +163,13 @@ function normalize(path) {
162
163
  }
163
164
 
164
165
  function getAliasName(id) {
165
- const base = require$$0.basename(id);
166
- return base.substring(0, base.length - require$$0.extname(id).length);
166
+ const base = node_path.basename(id);
167
+ return base.substring(0, base.length - node_path.extname(id).length);
167
168
  }
168
169
  function relativeId(id) {
169
170
  if (!isAbsolute(id))
170
171
  return id;
171
- return relative(require$$0.resolve(), id);
172
+ return relative(node_path.resolve(), id);
172
173
  }
173
174
  function isPathFragment(name) {
174
175
  // starting with "/", "./", "../", "C:/"
@@ -176,17 +177,17 @@ function isPathFragment(name) {
176
177
  }
177
178
  const UPPER_DIR_REGEX = /^(\.\.\/)*\.\.$/;
178
179
  function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName) {
179
- let relativePath = normalize(relative(require$$0.dirname(importerId), targetPath));
180
+ let relativePath = normalize(relative(node_path.dirname(importerId), targetPath));
180
181
  if (stripJsExtension && relativePath.endsWith('.js')) {
181
182
  relativePath = relativePath.slice(0, -3);
182
183
  }
183
184
  if (ensureFileName) {
184
185
  if (relativePath === '')
185
- return '../' + require$$0.basename(targetPath);
186
+ return '../' + node_path.basename(targetPath);
186
187
  if (UPPER_DIR_REGEX.test(relativePath)) {
187
188
  return relativePath
188
189
  .split('/')
189
- .concat(['..', require$$0.basename(targetPath)])
190
+ .concat(['..', node_path.basename(targetPath)])
190
191
  .join('/');
191
192
  }
192
193
  }
@@ -194,8 +195,10 @@ function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName)
194
195
  }
195
196
 
196
197
  function error(base) {
197
- if (!(base instanceof Error))
198
+ if (!(base instanceof Error)) {
198
199
  base = Object.assign(new Error(base.message), base);
200
+ Object.defineProperty(base, 'name', { value: 'RollupError' });
201
+ }
199
202
  throw base;
200
203
  }
201
204
  function augmentCodeLocation(props, pos, source, id) {
@@ -213,335 +216,545 @@ function augmentCodeLocation(props, pos, source, id) {
213
216
  props.frame = getCodeFrame(source, line, column);
214
217
  }
215
218
  }
216
- var Errors;
217
- (function (Errors) {
218
- Errors["ADDON_ERROR"] = "ADDON_ERROR";
219
- Errors["ALREADY_CLOSED"] = "ALREADY_CLOSED";
220
- Errors["ASSET_NOT_FINALISED"] = "ASSET_NOT_FINALISED";
221
- Errors["ASSET_NOT_FOUND"] = "ASSET_NOT_FOUND";
222
- Errors["ASSET_SOURCE_ALREADY_SET"] = "ASSET_SOURCE_ALREADY_SET";
223
- Errors["ASSET_SOURCE_MISSING"] = "ASSET_SOURCE_MISSING";
224
- Errors["BAD_LOADER"] = "BAD_LOADER";
225
- Errors["CANNOT_EMIT_FROM_OPTIONS_HOOK"] = "CANNOT_EMIT_FROM_OPTIONS_HOOK";
226
- Errors["CHUNK_NOT_GENERATED"] = "CHUNK_NOT_GENERATED";
227
- Errors["CHUNK_INVALID"] = "CHUNK_INVALID";
228
- Errors["CIRCULAR_REEXPORT"] = "CIRCULAR_REEXPORT";
229
- Errors["CYCLIC_CROSS_CHUNK_REEXPORT"] = "CYCLIC_CROSS_CHUNK_REEXPORT";
230
- Errors["DEPRECATED_FEATURE"] = "DEPRECATED_FEATURE";
231
- Errors["EXTERNAL_SYNTHETIC_EXPORTS"] = "EXTERNAL_SYNTHETIC_EXPORTS";
232
- Errors["FILE_NAME_CONFLICT"] = "FILE_NAME_CONFLICT";
233
- Errors["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
234
- Errors["INPUT_HOOK_IN_OUTPUT_PLUGIN"] = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
235
- Errors["INVALID_CHUNK"] = "INVALID_CHUNK";
236
- Errors["INVALID_EXPORT_OPTION"] = "INVALID_EXPORT_OPTION";
237
- Errors["INVALID_EXTERNAL_ID"] = "INVALID_EXTERNAL_ID";
238
- Errors["INVALID_OPTION"] = "INVALID_OPTION";
239
- Errors["INVALID_PLUGIN_HOOK"] = "INVALID_PLUGIN_HOOK";
240
- Errors["INVALID_ROLLUP_PHASE"] = "INVALID_ROLLUP_PHASE";
241
- Errors["INVALID_TLA_FORMAT"] = "INVALID_TLA_FORMAT";
242
- Errors["MISSING_EXPORT"] = "MISSING_EXPORT";
243
- Errors["MISSING_IMPLICIT_DEPENDANT"] = "MISSING_IMPLICIT_DEPENDANT";
244
- Errors["MIXED_EXPORTS"] = "MIXED_EXPORTS";
245
- Errors["NAMESPACE_CONFLICT"] = "NAMESPACE_CONFLICT";
246
- Errors["AMBIGUOUS_EXTERNAL_NAMESPACES"] = "AMBIGUOUS_EXTERNAL_NAMESPACES";
247
- Errors["NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE"] = "NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE";
248
- Errors["PLUGIN_ERROR"] = "PLUGIN_ERROR";
249
- Errors["PREFER_NAMED_EXPORTS"] = "PREFER_NAMED_EXPORTS";
250
- Errors["SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT"] = "SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT";
251
- Errors["UNEXPECTED_NAMED_IMPORT"] = "UNEXPECTED_NAMED_IMPORT";
252
- Errors["UNRESOLVED_ENTRY"] = "UNRESOLVED_ENTRY";
253
- Errors["UNRESOLVED_IMPORT"] = "UNRESOLVED_IMPORT";
254
- Errors["VALIDATION_ERROR"] = "VALIDATION_ERROR";
255
- })(Errors || (Errors = {}));
219
+ // Error codes should be sorted alphabetically while errors should be sorted by
220
+ // error code below
221
+ const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', PREFER_NAMED_EXPORTS = 'PREFER_NAMED_EXPORTS', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', TRANSPILED_ESM_CONFIG = 'TRANSPILED_ESM_CONFIG', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
256
222
  function errAddonNotGenerated(message, hook, plugin) {
257
223
  return {
258
- code: Errors.ADDON_ERROR,
259
- message: `Could not retrieve ${hook}. Check configuration of plugin ${plugin}.
224
+ code: ADDON_ERROR,
225
+ message: `Could not retrieve "${hook}". Check configuration of plugin "${plugin}".
260
226
  \tError Message: ${message}`
261
227
  };
262
228
  }
229
+ function errAlreadyClosed() {
230
+ return {
231
+ code: ALREADY_CLOSED,
232
+ message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
233
+ };
234
+ }
235
+ function errAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
236
+ return {
237
+ binding,
238
+ code: AMBIGUOUS_EXTERNAL_NAMESPACES,
239
+ ids: sources,
240
+ message: `Ambiguous external namespace resolution: "${relativeId(reexportingModule)}" re-exports "${binding}" from one of the external modules ${printQuotedStringList(sources.map(module => relativeId(module)))}, guessing "${relativeId(usedModule)}".`,
241
+ reexporter: reexportingModule
242
+ };
243
+ }
244
+ function errAnonymousPluginCache() {
245
+ return {
246
+ code: ANONYMOUS_PLUGIN_CACHE,
247
+ message: 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.'
248
+ };
249
+ }
263
250
  function errAssetNotFinalisedForFileName(name) {
264
251
  return {
265
- code: Errors.ASSET_NOT_FINALISED,
252
+ code: ASSET_NOT_FINALISED,
266
253
  message: `Plugin error - Unable to get file name for asset "${name}". Ensure that the source is set and that generate is called first. If you reference assets via import.meta.ROLLUP_FILE_URL_<referenceId>, you need to either have set their source after "renderStart" or need to provide an explicit "fileName" when emitting them.`
267
254
  };
268
255
  }
256
+ function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
257
+ return {
258
+ code: ASSET_NOT_FOUND,
259
+ message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
260
+ };
261
+ }
262
+ function errAssetSourceAlreadySet(name) {
263
+ return {
264
+ code: ASSET_SOURCE_ALREADY_SET,
265
+ message: `Unable to set the source for asset "${name}", source already set.`
266
+ };
267
+ }
268
+ function errNoAssetSourceSet(assetName) {
269
+ return {
270
+ code: ASSET_SOURCE_MISSING,
271
+ message: `Plugin error creating asset "${assetName}" - no asset source set.`
272
+ };
273
+ }
274
+ function errBadLoader(id) {
275
+ return {
276
+ code: BAD_LOADER,
277
+ message: `Error loading "${relativeId(id)}": plugin load hook should return a string, a { code, map } object, or nothing/null.`
278
+ };
279
+ }
280
+ function errCannotCallNamespace(name) {
281
+ return {
282
+ code: CANNOT_CALL_NAMESPACE,
283
+ message: `Cannot call a namespace ("${name}").`
284
+ };
285
+ }
269
286
  function errCannotEmitFromOptionsHook() {
270
287
  return {
271
- code: Errors.CANNOT_EMIT_FROM_OPTIONS_HOOK,
288
+ code: CANNOT_EMIT_FROM_OPTIONS_HOOK,
272
289
  message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
273
290
  };
274
291
  }
275
292
  function errChunkNotGeneratedForFileName(name) {
276
293
  return {
277
- code: Errors.CHUNK_NOT_GENERATED,
294
+ code: CHUNK_NOT_GENERATED,
278
295
  message: `Plugin error - Unable to get file name for emitted chunk "${name}". You can only get file names once chunks have been generated after the "renderStart" hook.`
279
296
  };
280
297
  }
281
298
  function errChunkInvalid({ fileName, code }, exception) {
282
299
  const errorProps = {
283
- code: Errors.CHUNK_INVALID,
300
+ code: CHUNK_INVALID,
284
301
  message: `Chunk "${fileName}" is not valid JavaScript: ${exception.message}.`
285
302
  };
286
303
  augmentCodeLocation(errorProps, exception.loc, code, fileName);
287
304
  return errorProps;
288
305
  }
289
- function errCircularReexport(exportName, importedModule) {
306
+ function errCircularDependency(cyclePath) {
307
+ return {
308
+ code: CIRCULAR_DEPENDENCY,
309
+ ids: cyclePath,
310
+ message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
311
+ };
312
+ }
313
+ function errCircularReexport(exportName, exporter) {
290
314
  return {
291
- code: Errors.CIRCULAR_REEXPORT,
292
- id: importedModule,
293
- message: `"${exportName}" cannot be exported from ${relativeId(importedModule)} as it is a reexport that references itself.`
315
+ code: CIRCULAR_REEXPORT,
316
+ exporter,
317
+ message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
294
318
  };
295
319
  }
296
320
  function errCyclicCrossChunkReexport(exportName, exporter, reexporter, importer) {
297
321
  return {
298
- code: Errors.CYCLIC_CROSS_CHUNK_REEXPORT,
322
+ code: CYCLIC_CROSS_CHUNK_REEXPORT,
299
323
  exporter,
300
- importer,
301
- message: `Export "${exportName}" of module ${relativeId(exporter)} was reexported through module ${relativeId(reexporter)} while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in ${relativeId(importer)} to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
324
+ id: importer,
325
+ message: `Export "${exportName}" of module "${relativeId(exporter)}" was reexported through module "${relativeId(reexporter)}" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "${relativeId(importer)}" to point directly to the exporting module or do not use "preserveModules" to ensure these modules end up in the same chunk.`,
302
326
  reexporter
303
327
  };
304
328
  }
305
- function errAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
329
+ function errDeprecation(deprecation) {
306
330
  return {
307
- code: Errors.ASSET_NOT_FOUND,
308
- message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
331
+ code: DEPRECATED_FEATURE,
332
+ ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
309
333
  };
310
334
  }
311
- function errAssetSourceAlreadySet(name) {
335
+ function errDuplicateImportOptions() {
312
336
  return {
313
- code: Errors.ASSET_SOURCE_ALREADY_SET,
314
- message: `Unable to set the source for asset "${name}", source already set.`
337
+ code: DUPLICATE_IMPORT_OPTIONS,
338
+ message: 'Either use --input, or pass input path as argument'
315
339
  };
316
340
  }
317
- function errNoAssetSourceSet(assetName) {
341
+ function errDuplicatePluginName(plugin) {
318
342
  return {
319
- code: Errors.ASSET_SOURCE_MISSING,
320
- message: `Plugin error creating asset "${assetName}" - no asset source set.`
343
+ code: DUPLICATE_PLUGIN_NAME,
344
+ message: `The plugin name ${plugin} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).`
321
345
  };
322
346
  }
323
- function errBadLoader(id) {
347
+ function errEmptyChunk(chunkName) {
324
348
  return {
325
- code: Errors.BAD_LOADER,
326
- message: `Error loading ${relativeId(id)}: plugin load hook should return a string, a { code, map } object, or nothing/null`
349
+ code: EMPTY_BUNDLE,
350
+ message: `Generated an empty chunk: "${chunkName}".`,
351
+ names: [chunkName]
327
352
  };
328
353
  }
329
- function errDeprecation(deprecation) {
354
+ function errEval(id) {
330
355
  return {
331
- code: Errors.DEPRECATED_FEATURE,
332
- ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
356
+ code: EVAL,
357
+ id,
358
+ message: `Use of eval in "${relativeId(id)}" is strongly discouraged as it poses security risks and may cause issues with minification.`,
359
+ url: 'https://rollupjs.org/guide/en/#avoiding-eval'
333
360
  };
334
361
  }
335
- function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
362
+ function errExternalSyntheticExports(id, importer) {
336
363
  return {
337
- code: Errors.FILE_NOT_FOUND,
338
- message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
364
+ code: EXTERNAL_SYNTHETIC_EXPORTS,
365
+ exporter: id,
366
+ message: `External "${id}" cannot have "syntheticNamedExports" enabled (imported by "${relativeId(importer)}").`
367
+ };
368
+ }
369
+ function errFailAfterWarnings() {
370
+ return {
371
+ code: FAIL_AFTER_WARNINGS,
372
+ message: 'Warnings occurred and --failAfterWarnings flag present.'
339
373
  };
340
374
  }
341
375
  function errFileNameConflict(fileName) {
342
376
  return {
343
- code: Errors.FILE_NAME_CONFLICT,
377
+ code: FILE_NAME_CONFLICT,
344
378
  message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
345
379
  };
346
380
  }
381
+ function errFileReferenceIdNotFoundForFilename(assetReferenceId) {
382
+ return {
383
+ code: FILE_NOT_FOUND,
384
+ message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
385
+ };
386
+ }
387
+ function errIllegalIdentifierAsName(name) {
388
+ return {
389
+ code: ILLEGAL_IDENTIFIER_AS_NAME,
390
+ message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`,
391
+ url: 'https://rollupjs.org/guide/en/#outputextend'
392
+ };
393
+ }
394
+ function errIllegalImportReassignment(name, importingId) {
395
+ return {
396
+ code: ILLEGAL_REASSIGNMENT,
397
+ message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
398
+ };
399
+ }
347
400
  function errInputHookInOutputPlugin(pluginName, hookName) {
348
401
  return {
349
- code: Errors.INPUT_HOOK_IN_OUTPUT_PLUGIN,
402
+ code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
350
403
  message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
351
404
  };
352
405
  }
353
406
  function errCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
354
407
  return {
355
- code: Errors.INVALID_CHUNK,
356
- message: `Cannot assign ${relativeId(moduleId)} to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
408
+ code: INVALID_CHUNK,
409
+ message: `Cannot assign "${relativeId(moduleId)}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
357
410
  };
358
411
  }
359
412
  function errInvalidExportOptionValue(optionValue) {
360
413
  return {
361
- code: Errors.INVALID_EXPORT_OPTION,
362
- message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}"`,
414
+ code: INVALID_EXPORT_OPTION,
415
+ message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`,
363
416
  url: `https://rollupjs.org/guide/en/#outputexports`
364
417
  };
365
418
  }
366
419
  function errIncompatibleExportOptionValue(optionValue, keys, entryModule) {
367
420
  return {
368
- code: 'INVALID_EXPORT_OPTION',
369
- message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${keys.join(', ')}`
421
+ code: INVALID_EXPORT_OPTION,
422
+ message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${printQuotedStringList(keys)}`,
423
+ url: 'https://rollupjs.org/guide/en/#outputexports'
370
424
  };
371
425
  }
372
426
  function errInternalIdCannotBeExternal(source, importer) {
373
427
  return {
374
- code: Errors.INVALID_EXTERNAL_ID,
375
- message: `'${source}' is imported as an external by ${relativeId(importer)}, but is already an existing non-external module id.`
428
+ code: INVALID_EXTERNAL_ID,
429
+ message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
376
430
  };
377
431
  }
378
432
  function errInvalidOption(option, urlHash, explanation, value) {
379
433
  return {
380
- code: Errors.INVALID_OPTION,
434
+ code: INVALID_OPTION,
381
435
  message: `Invalid value ${value !== undefined ? `${JSON.stringify(value)} ` : ''}for option "${option}" - ${explanation}.`,
382
436
  url: `https://rollupjs.org/guide/en/#${urlHash}`
383
437
  };
384
438
  }
439
+ function errInvalidAddonPluginHook(hook, plugin) {
440
+ return {
441
+ code: INVALID_PLUGIN_HOOK,
442
+ hook,
443
+ message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a string, a function hook or an object with a "handler" string or function.`,
444
+ plugin
445
+ };
446
+ }
447
+ function errInvalidFunctionPluginHook(hook, plugin) {
448
+ return {
449
+ code: INVALID_PLUGIN_HOOK,
450
+ hook,
451
+ message: `Error running plugin hook "${hook}" for plugin "${plugin}", expected a function hook or an object with a "handler" function.`,
452
+ plugin
453
+ };
454
+ }
385
455
  function errInvalidRollupPhaseForAddWatchFile() {
386
456
  return {
387
- code: Errors.INVALID_ROLLUP_PHASE,
388
- message: `Cannot call addWatchFile after the build has finished.`
457
+ code: INVALID_ROLLUP_PHASE,
458
+ message: `Cannot call "addWatchFile" after the build has finished.`
389
459
  };
390
460
  }
391
461
  function errInvalidRollupPhaseForChunkEmission() {
392
462
  return {
393
- code: Errors.INVALID_ROLLUP_PHASE,
463
+ code: INVALID_ROLLUP_PHASE,
394
464
  message: `Cannot emit chunks after module loading has finished.`
395
465
  };
396
466
  }
467
+ function errInvalidSetAssetSourceCall() {
468
+ return {
469
+ code: INVALID_SETASSETSOURCE,
470
+ message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
471
+ };
472
+ }
397
473
  function errInvalidFormatForTopLevelAwait(id, format) {
398
474
  return {
399
- code: Errors.INVALID_TLA_FORMAT,
475
+ code: INVALID_TLA_FORMAT,
400
476
  id,
401
- message: `Module format ${format} does not support top-level await. Use the "es" or "system" output formats rather.`
477
+ message: `Module format "${format}" does not support top-level await. Use the "es" or "system" output formats rather.`
478
+ };
479
+ }
480
+ function errMissingConfig() {
481
+ return {
482
+ code: MISSING_CONFIG,
483
+ message: 'Config file must export an options object, or an array of options objects',
484
+ url: 'https://rollupjs.org/guide/en/#configuration-files'
402
485
  };
403
486
  }
404
- function errMissingExport(exportName, importingModule, importedModule) {
487
+ function errMissingExport(binding, importingModule, exporter) {
405
488
  return {
406
- code: Errors.MISSING_EXPORT,
407
- message: `'${exportName}' is not exported by ${relativeId(importedModule)}, imported by ${relativeId(importingModule)}`,
489
+ binding,
490
+ code: MISSING_EXPORT,
491
+ exporter,
492
+ id: importingModule,
493
+ message: `"${binding}" is not exported by "${relativeId(exporter)}", imported by "${relativeId(importingModule)}".`,
408
494
  url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
409
495
  };
410
496
  }
497
+ function errMissingExternalConfig(file) {
498
+ return {
499
+ code: MISSING_EXTERNAL_CONFIG,
500
+ message: `Could not resolve config file "${file}"`
501
+ };
502
+ }
503
+ function errMissingGlobalName(externalId, guess) {
504
+ return {
505
+ code: MISSING_GLOBAL_NAME,
506
+ id: externalId,
507
+ message: `No name was provided for external module "${externalId}" in "output.globals" – guessing "${guess}".`,
508
+ names: [guess],
509
+ url: 'https://rollupjs.org/guide/en/#outputglobals'
510
+ };
511
+ }
411
512
  function errImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
412
513
  return {
413
- code: Errors.MISSING_IMPLICIT_DEPENDANT,
514
+ code: MISSING_IMPLICIT_DEPENDANT,
414
515
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
415
516
  };
416
517
  }
417
518
  function errUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
418
519
  return {
419
- code: Errors.MISSING_IMPLICIT_DEPENDANT,
520
+ code: MISSING_IMPLICIT_DEPENDANT,
420
521
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
421
522
  };
422
523
  }
423
524
  function errImplicitDependantIsNotIncluded(module) {
424
525
  const implicitDependencies = Array.from(module.implicitlyLoadedBefore, dependency => relativeId(dependency.id)).sort();
425
526
  return {
426
- code: Errors.MISSING_IMPLICIT_DEPENDANT,
527
+ code: MISSING_IMPLICIT_DEPENDANT,
427
528
  message: `Module "${relativeId(module.id)}" that should be implicitly loaded before ${printQuotedStringList(implicitDependencies)} is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.`
428
529
  };
429
530
  }
531
+ function errMissingNameOptionForIifeExport() {
532
+ return {
533
+ code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
534
+ message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`,
535
+ url: 'https://rollupjs.org/guide/en/#outputname'
536
+ };
537
+ }
538
+ function errMissingNameOptionForUmdExport() {
539
+ return {
540
+ code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
541
+ message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.',
542
+ url: 'https://rollupjs.org/guide/en/#outputname'
543
+ };
544
+ }
545
+ function errMissingNodeBuiltins(externalBuiltins) {
546
+ return {
547
+ code: MISSING_NODE_BUILTINS,
548
+ ids: externalBuiltins,
549
+ message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`
550
+ };
551
+ }
552
+ function errMissingFileOrDirOption() {
553
+ return {
554
+ code: MISSING_OPTION,
555
+ message: 'You must specify "output.file" or "output.dir" for the build.',
556
+ url: 'https://rollupjs.org/guide/en/#outputdir'
557
+ };
558
+ }
430
559
  function errMixedExport(facadeModuleId, name) {
431
560
  return {
432
- code: Errors.MIXED_EXPORTS,
561
+ code: MIXED_EXPORTS,
433
562
  id: facadeModuleId,
434
- message: `Entry module "${relativeId(facadeModuleId)}" is using named and default exports together. Consumers of your bundle will have to use \`${name || 'chunk'}["default"]\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning`,
563
+ message: `Entry module "${relativeId(facadeModuleId)}" is using named and default exports together. Consumers of your bundle will have to use \`${name || 'chunk'}.default\` to access the default export, which may not be what you want. Use \`output.exports: "named"\` to disable this warning.`,
435
564
  url: `https://rollupjs.org/guide/en/#outputexports`
436
565
  };
437
566
  }
438
- function errNamespaceConflict(name, reexportingModuleId, sources) {
567
+ function errModuleLevelDirective(directive, id) {
439
568
  return {
440
- code: Errors.NAMESPACE_CONFLICT,
441
- message: `Conflicting namespaces: "${relativeId(reexportingModuleId)}" re-exports "${name}" from one of the modules ${printQuotedStringList(sources.map(moduleId => relativeId(moduleId)))} (will be ignored)`,
442
- name,
443
- reexporter: reexportingModuleId,
444
- sources
569
+ code: MODULE_LEVEL_DIRECTIVE,
570
+ id,
571
+ message: `Module level directives cause errors when bundled, "${directive}" in "${relativeId(id)}" was ignored.`
445
572
  };
446
573
  }
447
- function errAmbiguousExternalNamespaces(name, reexportingModule, usedModule, sources) {
574
+ function errNamespaceConflict(binding, reexportingModuleId, sources) {
448
575
  return {
449
- code: Errors.AMBIGUOUS_EXTERNAL_NAMESPACES,
450
- message: `Ambiguous external namespace resolution: "${relativeId(reexportingModule)}" re-exports "${name}" from one of the external modules ${printQuotedStringList(sources.map(module => relativeId(module)))}, guessing "${relativeId(usedModule)}".`,
451
- name,
452
- reexporter: reexportingModule,
453
- sources
576
+ binding,
577
+ code: NAMESPACE_CONFLICT,
578
+ ids: sources,
579
+ message: `Conflicting namespaces: "${relativeId(reexportingModuleId)}" re-exports "${binding}" from one of the modules ${printQuotedStringList(sources.map(moduleId => relativeId(moduleId)))} (will be ignored).`,
580
+ reexporter: reexportingModuleId
454
581
  };
455
582
  }
456
583
  function errNoTransformMapOrAstWithoutCode(pluginName) {
457
584
  return {
458
- code: Errors.NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
585
+ code: NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
459
586
  message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
460
587
  'a "code". This will be ignored.'
461
588
  };
462
589
  }
590
+ function errOnlyInlineSourcemapsForStdout() {
591
+ return {
592
+ code: ONLY_INLINE_SOURCEMAPS,
593
+ message: 'Only inline sourcemaps are supported when bundling to stdout.'
594
+ };
595
+ }
596
+ function errParseError(error, moduleId) {
597
+ let message = error.message.replace(/ \(\d+:\d+\)$/, '');
598
+ if (moduleId.endsWith('.json')) {
599
+ message += ' (Note that you need @rollup/plugin-json to import JSON files)';
600
+ }
601
+ else if (!moduleId.endsWith('.js')) {
602
+ message += ' (Note that you need plugins to import files that are not JavaScript)';
603
+ }
604
+ return {
605
+ cause: error,
606
+ code: PARSE_ERROR,
607
+ id: moduleId,
608
+ message
609
+ };
610
+ }
611
+ function errPluginError(error, plugin, { hook, id } = {}) {
612
+ if (typeof error === 'string')
613
+ error = { message: error };
614
+ if (error.code && error.code !== PLUGIN_ERROR) {
615
+ error.pluginCode = error.code;
616
+ }
617
+ error.code = PLUGIN_ERROR;
618
+ error.plugin = plugin;
619
+ if (hook) {
620
+ error.hook = hook;
621
+ }
622
+ if (id) {
623
+ error.id = id;
624
+ }
625
+ return error;
626
+ }
463
627
  function errPreferNamedExports(facadeModuleId) {
464
628
  const file = relativeId(facadeModuleId);
465
629
  return {
466
- code: Errors.PREFER_NAMED_EXPORTS,
630
+ code: PREFER_NAMED_EXPORTS,
467
631
  id: facadeModuleId,
468
632
  message: `Entry module "${file}" is implicitly using "default" export mode, which means for CommonJS output that its default export is assigned to "module.exports". For many tools, such CommonJS output will not be interchangeable with the original ES module. If this is intended, explicitly set "output.exports" to either "auto" or "default", otherwise you might want to consider changing the signature of "${file}" to use named exports only.`,
469
633
  url: `https://rollupjs.org/guide/en/#outputexports`
470
634
  };
471
635
  }
472
- function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
636
+ function errShimmedExport(id, binding) {
637
+ return {
638
+ binding,
639
+ code: SHIMMED_EXPORT,
640
+ exporter: id,
641
+ message: `Missing export "${binding}" has been shimmed in module "${relativeId(id)}".`
642
+ };
643
+ }
644
+ function errSourcemapBroken(plugin) {
645
+ return {
646
+ code: SOURCEMAP_BROKEN,
647
+ message: `Sourcemap is likely to be incorrect: a plugin (${plugin}) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help`,
648
+ plugin,
649
+ url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect`
650
+ };
651
+ }
652
+ function errInvalidSourcemapForError(error, id, column, line, pos) {
473
653
  return {
474
- code: Errors.SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
654
+ cause: error,
655
+ code: SOURCEMAP_ERROR,
475
656
  id,
476
- message: `Module "${relativeId(id)}" that is marked with 'syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}' needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
657
+ loc: {
658
+ column,
659
+ file: id,
660
+ line
661
+ },
662
+ message: `Error when using sourcemap for reporting an error: ${error.message}`,
663
+ pos
664
+ };
665
+ }
666
+ function errSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
667
+ return {
668
+ code: SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
669
+ exporter: id,
670
+ message: `Module "${relativeId(id)}" that is marked with \`syntheticNamedExports: ${JSON.stringify(syntheticNamedExportsOption)}\` needs ${typeof syntheticNamedExportsOption === 'string' && syntheticNamedExportsOption !== 'default'
477
671
  ? `an explicit export named "${syntheticNamedExportsOption}"`
478
672
  : 'a default export'} that does not reexport an unresolved named export of the same module.`
479
673
  };
480
674
  }
675
+ function errThisIsUndefined() {
676
+ return {
677
+ code: THIS_IS_UNDEFINED,
678
+ message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
679
+ url: `https://rollupjs.org/guide/en/#error-this-is-undefined`
680
+ };
681
+ }
682
+ function errTranspiledEsmConfig(fileName) {
683
+ return {
684
+ code: TRANSPILED_ESM_CONFIG,
685
+ message: `While loading the Rollup configuration from "${relativeId(fileName)}", Node tried to require an ES module from a CommonJS file, which is not supported. A common cause is if there is a package.json file with "type": "module" in the same folder. You can try to fix this by changing the extension of your configuration file to ".cjs" or ".mjs" depending on the content, which will prevent Rollup from trying to preprocess the file but rather hand it to Node directly.`
686
+ };
687
+ }
481
688
  function errUnexpectedNamedImport(id, imported, isReexport) {
482
689
  const importType = isReexport ? 'reexport' : 'import';
483
690
  return {
484
- code: Errors.UNEXPECTED_NAMED_IMPORT,
485
- id,
486
- message: `The named export "${imported}" was ${importType}ed from the external module ${relativeId(id)} even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`,
691
+ code: UNEXPECTED_NAMED_IMPORT,
692
+ exporter: id,
693
+ message: `The named export "${imported}" was ${importType}ed from the external module "${relativeId(id)}" even though its interop type is "defaultOnly". Either remove or change this ${importType} or change the value of the "output.interop" option.`,
487
694
  url: 'https://rollupjs.org/guide/en/#outputinterop'
488
695
  };
489
696
  }
490
697
  function errUnexpectedNamespaceReexport(id) {
491
698
  return {
492
- code: Errors.UNEXPECTED_NAMED_IMPORT,
493
- id,
494
- message: `There was a namespace "*" reexport from the external module ${relativeId(id)} even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`,
699
+ code: UNEXPECTED_NAMED_IMPORT,
700
+ exporter: id,
701
+ message: `There was a namespace "*" reexport from the external module "${relativeId(id)}" even though its interop type is "defaultOnly". This will be ignored as namespace reexports only reexport named exports. If this is not intended, either remove or change this reexport or change the value of the "output.interop" option.`,
495
702
  url: 'https://rollupjs.org/guide/en/#outputinterop'
496
703
  };
497
704
  }
705
+ function errUnknownOption(optionType, unknownOptions, validOptions) {
706
+ return {
707
+ code: UNKNOWN_OPTION,
708
+ message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${validOptions.join(', ')}`
709
+ };
710
+ }
498
711
  function errEntryCannotBeExternal(unresolvedId) {
499
712
  return {
500
- code: Errors.UNRESOLVED_ENTRY,
501
- message: `Entry module cannot be external (${relativeId(unresolvedId)}).`
713
+ code: UNRESOLVED_ENTRY,
714
+ message: `Entry module "${relativeId(unresolvedId)}" cannot be external.`
502
715
  };
503
716
  }
504
717
  function errUnresolvedEntry(unresolvedId) {
505
718
  return {
506
- code: Errors.UNRESOLVED_ENTRY,
507
- message: `Could not resolve entry module (${relativeId(unresolvedId)}).`
719
+ code: UNRESOLVED_ENTRY,
720
+ message: `Could not resolve entry module "${relativeId(unresolvedId)}".`
508
721
  };
509
722
  }
510
723
  function errUnresolvedImport(source, importer) {
511
724
  return {
512
- code: Errors.UNRESOLVED_IMPORT,
513
- message: `Could not resolve '${source}' from ${relativeId(importer)}`
725
+ code: UNRESOLVED_IMPORT,
726
+ exporter: source,
727
+ id: importer,
728
+ message: `Could not resolve "${source}" from "${relativeId(importer)}"`
514
729
  };
515
730
  }
516
731
  function errUnresolvedImportTreatedAsExternal(source, importer) {
517
732
  return {
518
- code: Errors.UNRESOLVED_IMPORT,
519
- importer: relativeId(importer),
520
- message: `'${source}' is imported by ${relativeId(importer)}, but could not be resolved – treating it as an external dependency`,
521
- source,
733
+ code: UNRESOLVED_IMPORT,
734
+ exporter: source,
735
+ id: importer,
736
+ message: `"${source}" is imported by "${relativeId(importer)}", but could not be resolved – treating it as an external dependency.`,
522
737
  url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
523
738
  };
524
739
  }
525
- function errExternalSyntheticExports(source, importer) {
740
+ function errUnusedExternalImports(externalId, names, importers) {
526
741
  return {
527
- code: Errors.EXTERNAL_SYNTHETIC_EXPORTS,
528
- importer: relativeId(importer),
529
- message: `External '${source}' can not have 'syntheticNamedExports' enabled.`,
530
- source
742
+ code: UNUSED_EXTERNAL_IMPORT,
743
+ exporter: externalId,
744
+ ids: importers,
745
+ message: `${printQuotedStringList(names, [
746
+ 'is',
747
+ 'are'
748
+ ])} imported from external module "${externalId}" but never used in ${printQuotedStringList(importers.map(importer => relativeId(importer)))}.`,
749
+ names
531
750
  };
532
751
  }
533
752
  function errFailedValidation(message) {
534
753
  return {
535
- code: Errors.VALIDATION_ERROR,
754
+ code: VALIDATION_ERROR,
536
755
  message
537
756
  };
538
757
  }
539
- function errAlreadyClosed() {
540
- return {
541
- code: Errors.ALREADY_CLOSED,
542
- message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
543
- };
544
- }
545
758
  function warnDeprecation(deprecation, activeDeprecation, options) {
546
759
  warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
547
760
  }
@@ -560,14 +773,7 @@ function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignor
560
773
  const validOptionSet = new Set(validOptions);
561
774
  const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
562
775
  if (unknownOptions.length > 0) {
563
- warn({
564
- code: 'UNKNOWN_OPTION',
565
- message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${[
566
- ...validOptionSet
567
- ]
568
- .sort()
569
- .join(', ')}`
570
- });
776
+ warn(errUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
571
777
  }
572
778
  }
573
779
  const treeshakePresets = {
@@ -2161,7 +2367,7 @@ class ExternalChunk {
2161
2367
  const { paths } = this.options;
2162
2368
  return (this.fileName =
2163
2369
  (typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
2164
- (this.renormalizeRenderPath ? normalize(require$$0.relative(this.inputBase, this.id)) : this.id));
2370
+ (this.renormalizeRenderPath ? normalize(node_path.relative(this.inputBase, this.id)) : this.id));
2165
2371
  }
2166
2372
  getImportPath(importer) {
2167
2373
  return escapeId(this.renormalizeRenderPath
@@ -2529,13 +2735,7 @@ class ExternalModule {
2529
2735
  }
2530
2736
  }
2531
2737
  const importersArray = [...importersSet];
2532
- this.options.onwarn({
2533
- code: 'UNUSED_EXTERNAL_IMPORT',
2534
- message: `${printQuotedStringList(unused, ['is', 'are'])} imported from external module "${this.id}" but never used in ${printQuotedStringList(importersArray.map(importer => relativeId(importer)))}.`,
2535
- names: unused,
2536
- source: this.id,
2537
- sources: importersArray
2538
- });
2738
+ this.options.onwarn(errUnusedExternalImports(this.id, unused, importersArray));
2539
2739
  }
2540
2740
  }
2541
2741
 
@@ -5240,10 +5440,10 @@ const SequenceExpression$1 = 'SequenceExpression';
5240
5440
 
5241
5441
  // this looks ridiculous, but it prevents sourcemap tooling from mistaking
5242
5442
  // this for an actual sourceMappingURL
5243
- exports.SOURCEMAPPING_URL = 'sourceMa';
5244
- exports.SOURCEMAPPING_URL += 'ppingURL';
5443
+ let SOURCEMAPPING_URL = 'sourceMa';
5444
+ SOURCEMAPPING_URL += 'ppingURL';
5245
5445
  const whiteSpaceNoNewline = '[ \\f\\r\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]';
5246
- const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${exports.SOURCEMAPPING_URL}=.+`);
5446
+ const SOURCEMAPPING_URL_RE = new RegExp(`^#${whiteSpaceNoNewline}+${SOURCEMAPPING_URL}=.+`);
5247
5447
 
5248
5448
  const ANNOTATION_KEY = '_rollupAnnotations';
5249
5449
  const INVALID_COMMENT_KEY = '_rollupRemoved';
@@ -7734,10 +7934,7 @@ class Identifier extends NodeBase {
7734
7934
  }
7735
7935
  }
7736
7936
  disallowImportReassignment() {
7737
- return this.context.error({
7738
- code: 'ILLEGAL_REASSIGNMENT',
7739
- message: `Illegal reassignment to import '${this.name}'`
7740
- }, this.start);
7937
+ return this.context.error(errIllegalImportReassignment(this.name, this.context.module.id), this.start);
7741
7938
  }
7742
7939
  getVariableRespectingTDZ() {
7743
7940
  if (this.isPossibleTDZ()) {
@@ -7933,10 +8130,7 @@ class ExpressionStatement extends NodeBase {
7933
8130
  this.parent.type === Program$1) {
7934
8131
  this.context.warn(
7935
8132
  // This is necessary, because either way (deleting or not) can lead to errors.
7936
- {
7937
- code: 'MODULE_LEVEL_DIRECTIVE',
7938
- message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.`
7939
- }, this.start);
8133
+ errModuleLevelDirective(this.directive, this.context.module.id), this.start);
7940
8134
  }
7941
8135
  }
7942
8136
  render(code, options) {
@@ -8950,10 +9144,7 @@ class MemberExpression extends NodeBase {
8950
9144
  if (this.variable) {
8951
9145
  this.context.includeVariableInModule(this.variable);
8952
9146
  }
8953
- this.context.warn({
8954
- code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
8955
- message: `Illegal reassignment to import '${this.object.name}'`
8956
- }, this.start);
9147
+ this.context.warn(errIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
8957
9148
  }
8958
9149
  }
8959
9150
  }
@@ -8993,14 +9184,7 @@ function resolveNamespaceVariables(baseVariable, path, astContext) {
8993
9184
  const variable = baseVariable.context.traceExport(exportName);
8994
9185
  if (!variable) {
8995
9186
  const fileName = baseVariable.context.fileName;
8996
- astContext.warn({
8997
- code: 'MISSING_EXPORT',
8998
- exporter: relativeId(fileName),
8999
- importer: relativeId(astContext.fileName),
9000
- message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
9001
- missing: exportName,
9002
- url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
9003
- }, path[0].pos);
9187
+ astContext.warn(errMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9004
9188
  return 'undefined';
9005
9189
  }
9006
9190
  return resolveNamespaceVariables(variable, path.slice(1), astContext);
@@ -9090,17 +9274,10 @@ class CallExpression extends CallExpressionBase {
9090
9274
  if (this.callee instanceof Identifier) {
9091
9275
  const variable = this.scope.findVariable(this.callee.name);
9092
9276
  if (variable.isNamespace) {
9093
- this.context.warn({
9094
- code: 'CANNOT_CALL_NAMESPACE',
9095
- message: `Cannot call a namespace ('${this.callee.name}')`
9096
- }, this.start);
9277
+ this.context.warn(errCannotCallNamespace(this.callee.name), this.start);
9097
9278
  }
9098
9279
  if (this.callee.name === 'eval') {
9099
- this.context.warn({
9100
- code: 'EVAL',
9101
- message: `Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification`,
9102
- url: 'https://rollupjs.org/guide/en/#avoiding-eval'
9103
- }, this.start);
9280
+ this.context.warn(errEval(this.context.module.id), this.start);
9104
9281
  }
9105
9282
  }
9106
9283
  this.interaction = {
@@ -9145,10 +9322,6 @@ class CallExpression extends CallExpressionBase {
9145
9322
  this.callee.include(context, false);
9146
9323
  }
9147
9324
  this.callee.includeCallArguments(context, this.arguments);
9148
- const returnExpression = this.getReturnExpression();
9149
- if (!returnExpression.included) {
9150
- returnExpression.include(context, false);
9151
- }
9152
9325
  }
9153
9326
  render(code, options, { renderedSurroundingElement } = BLANK) {
9154
9327
  this.callee.render(code, options, {
@@ -9518,15 +9691,6 @@ class MultiExpression extends ExpressionEntity {
9518
9691
  }
9519
9692
  return false;
9520
9693
  }
9521
- include(context, includeChildrenRecursively) {
9522
- // This is only relevant to include values that do not have an AST representation,
9523
- // such as UnknownArrayExpression. Thus we only need to include them once.
9524
- for (const expression of this.expressions) {
9525
- if (!expression.included) {
9526
- expression.include(context, includeChildrenRecursively);
9527
- }
9528
- }
9529
- }
9530
9694
  }
9531
9695
 
9532
9696
  class ConditionalExpression extends NodeBase {
@@ -10447,6 +10611,7 @@ class ImportExpression extends NodeBase {
10447
10611
  }
10448
10612
  setExternalResolution(exportMode, resolution, options, snippets, pluginDriver, accessedGlobalsByScope, resolutionString, namespaceExportName) {
10449
10613
  const { format } = options;
10614
+ this.inlineNamespace = null;
10450
10615
  this.resolution = resolution;
10451
10616
  this.resolutionString = resolutionString;
10452
10617
  this.namespaceExportName = namespaceExportName;
@@ -10787,7 +10952,7 @@ class MetaProperty extends NodeBase {
10787
10952
  const chunkId = this.preliminaryChunkId;
10788
10953
  if (referenceId) {
10789
10954
  const fileName = pluginDriver.getFileName(referenceId);
10790
- const relativePath = normalize(require$$0.relative(require$$0.dirname(chunkId), fileName));
10955
+ const relativePath = normalize(node_path.relative(node_path.dirname(chunkId), fileName));
10791
10956
  const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
10792
10957
  {
10793
10958
  chunkId,
@@ -11357,10 +11522,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
11357
11522
  const name = this.tag.name;
11358
11523
  const variable = this.scope.findVariable(name);
11359
11524
  if (variable.isNamespace) {
11360
- this.context.warn({
11361
- code: 'CANNOT_CALL_NAMESPACE',
11362
- message: `Cannot call a namespace ('${name}')`
11363
- }, this.start);
11525
+ this.context.warn(errCannotCallNamespace(name), this.start);
11364
11526
  }
11365
11527
  }
11366
11528
  }
@@ -11610,11 +11772,7 @@ class ThisExpression extends NodeBase {
11610
11772
  this.alias =
11611
11773
  this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null;
11612
11774
  if (this.alias === 'undefined') {
11613
- this.context.warn({
11614
- code: 'THIS_IS_UNDEFINED',
11615
- message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
11616
- url: `https://rollupjs.org/guide/en/#error-this-is-undefined`
11617
- }, this.start);
11775
+ this.context.warn(errThisIsUndefined(), this.start);
11618
11776
  }
11619
11777
  }
11620
11778
  render(code) {
@@ -12304,7 +12462,7 @@ function getPersistedLabel(label, level) {
12304
12462
  function timeStartImpl(label, level = 3) {
12305
12463
  label = getPersistedLabel(label, level);
12306
12464
  const startMemory = process$1.memoryUsage().heapUsed;
12307
- const startTime = perf_hooks.performance.now();
12465
+ const startTime = node_perf_hooks.performance.now();
12308
12466
  const timer = timers.get(label);
12309
12467
  if (timer === undefined) {
12310
12468
  timers.set(label, {
@@ -12326,7 +12484,7 @@ function timeEndImpl(label, level = 3) {
12326
12484
  if (timer !== undefined) {
12327
12485
  const currentMemory = process$1.memoryUsage().heapUsed;
12328
12486
  timer.memory += currentMemory - timer.startMemory;
12329
- timer.time += perf_hooks.performance.now() - timer.startTime;
12487
+ timer.time += node_perf_hooks.performance.now() - timer.startTime;
12330
12488
  timer.totalMemory = Math.max(timer.totalMemory, currentMemory);
12331
12489
  }
12332
12490
  }
@@ -12339,7 +12497,26 @@ function getTimings() {
12339
12497
  }
12340
12498
  let timeStart = NOOP;
12341
12499
  let timeEnd = NOOP;
12342
- const TIMED_PLUGIN_HOOKS = ['load', 'resolveDynamicImport', 'resolveId', 'transform'];
12500
+ const TIMED_PLUGIN_HOOKS = [
12501
+ 'augmentChunkHash',
12502
+ 'buildEnd',
12503
+ 'buildStart',
12504
+ 'generateBundle',
12505
+ 'load',
12506
+ 'moduleParsed',
12507
+ 'options',
12508
+ 'outputOptions',
12509
+ 'renderChunk',
12510
+ 'renderDynamicImport',
12511
+ 'renderStart',
12512
+ 'resolveDynamicImport',
12513
+ 'resolveFileUrl',
12514
+ 'resolveId',
12515
+ 'resolveImportMeta',
12516
+ 'shouldTransformCachedModule',
12517
+ 'transform',
12518
+ 'writeBundle'
12519
+ ];
12343
12520
  function getPluginWithTimers(plugin, index) {
12344
12521
  for (const hook of TIMED_PLUGIN_HOOKS) {
12345
12522
  if (hook in plugin) {
@@ -12353,13 +12530,6 @@ function getPluginWithTimers(plugin, index) {
12353
12530
  timeStart(timerLabel, 4);
12354
12531
  const result = func.apply(this, args);
12355
12532
  timeEnd(timerLabel, 4);
12356
- if (result && typeof result.then === 'function') {
12357
- timeStart(`${timerLabel} (async)`, 4);
12358
- return result.then((hookResult) => {
12359
- timeEnd(`${timerLabel} (async)`, 4);
12360
- return hookResult;
12361
- });
12362
- }
12363
12533
  return result;
12364
12534
  };
12365
12535
  }
@@ -12554,8 +12724,8 @@ class Module {
12554
12724
  });
12555
12725
  }
12556
12726
  basename() {
12557
- const base = require$$0.basename(this.id);
12558
- const ext = require$$0.extname(this.id);
12727
+ const base = node_path.basename(this.id);
12728
+ const ext = node_path.extname(this.id);
12559
12729
  return makeLegal(ext ? base.slice(0, -ext.length) : base);
12560
12730
  }
12561
12731
  bindReferences() {
@@ -12837,6 +13007,7 @@ class Module {
12837
13007
  return { source, usesTopLevelAwait };
12838
13008
  }
12839
13009
  setSource({ ast, code, customTransformCache, originalCode, originalSourcemap, resolvedIds, sourcemapChain, transformDependencies, transformFiles, ...moduleOptions }) {
13010
+ timeStart('generate ast', 3);
12840
13011
  this.info.code = code;
12841
13012
  this.originalCode = originalCode;
12842
13013
  this.originalSourcemap = originalSourcemap;
@@ -12847,11 +13018,11 @@ class Module {
12847
13018
  this.transformDependencies = transformDependencies;
12848
13019
  this.customTransformCache = customTransformCache;
12849
13020
  this.updateOptions(moduleOptions);
12850
- timeStart('generate ast', 3);
12851
13021
  if (!ast) {
12852
13022
  ast = this.tryParse();
12853
13023
  }
12854
13024
  timeEnd('generate ast', 3);
13025
+ timeStart('analyze ast', 3);
12855
13026
  this.resolvedIds = resolvedIds || Object.create(null);
12856
13027
  // By default, `id` is the file name. Custom resolvers and loaders
12857
13028
  // can change that, but it makes sense to use it for the source file name
@@ -12860,7 +13031,6 @@ class Module {
12860
13031
  filename: (this.excludeFromSourcemap ? null : fileName),
12861
13032
  indentExclusionRanges: []
12862
13033
  });
12863
- timeStart('analyse ast', 3);
12864
13034
  this.astContext = {
12865
13035
  addDynamicImport: this.addDynamicImport.bind(this),
12866
13036
  addExport: this.addExport.bind(this),
@@ -12893,7 +13063,7 @@ class Module {
12893
13063
  this.namespace = new NamespaceVariable(this.astContext);
12894
13064
  this.ast = new Program(ast, { context: this.astContext, type: 'Module' }, this.scope);
12895
13065
  this.info.ast = ast;
12896
- timeEnd('analyse ast', 3);
13066
+ timeEnd('analyze ast', 3);
12897
13067
  }
12898
13068
  toJSON() {
12899
13069
  return {
@@ -12937,18 +13107,7 @@ class Module {
12937
13107
  return this.graph.contextParse(this.info.code);
12938
13108
  }
12939
13109
  catch (err) {
12940
- let message = err.message.replace(/ \(\d+:\d+\)$/, '');
12941
- if (this.id.endsWith('.json')) {
12942
- message += ' (Note that you need @rollup/plugin-json to import JSON files)';
12943
- }
12944
- else if (!this.id.endsWith('.js')) {
12945
- message += ' (Note that you need plugins to import files that are not JavaScript)';
12946
- }
12947
- return this.error({
12948
- code: 'PARSE_ERROR',
12949
- message,
12950
- parserError: err
12951
- }, err.pos);
13110
+ return this.error(errParseError(err, this.id), err.pos);
12952
13111
  }
12953
13112
  }
12954
13113
  updateOptions({ meta, moduleSideEffects, syntheticNamedExports }) {
@@ -13074,17 +13233,7 @@ class Module {
13074
13233
  code = this.originalCode;
13075
13234
  }
13076
13235
  catch (err) {
13077
- this.options.onwarn({
13078
- code: 'SOURCEMAP_ERROR',
13079
- id: this.id,
13080
- loc: {
13081
- column,
13082
- file: this.id,
13083
- line
13084
- },
13085
- message: `Error when using sourcemap for reporting an error: ${err.message}`,
13086
- pos
13087
- });
13236
+ this.options.onwarn(errInvalidSourcemapForError(err, this.id, column, line, pos));
13088
13237
  }
13089
13238
  augmentCodeLocation(props, { column, line }, code, this.id);
13090
13239
  }
@@ -13222,12 +13371,7 @@ class Module {
13222
13371
  }
13223
13372
  }
13224
13373
  shimMissingExport(name) {
13225
- this.options.onwarn({
13226
- code: 'SHIMMED_EXPORT',
13227
- exporter: relativeId(this.id),
13228
- exportName: name,
13229
- message: `Missing export "${name}" has been shimmed in module ${relativeId(this.id)}.`
13230
- });
13374
+ this.options.onwarn(errShimmedExport(this.id, name));
13231
13375
  this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
13232
13376
  }
13233
13377
  }
@@ -13464,39 +13608,35 @@ function removeExtensionFromRelativeAmdId(id) {
13464
13608
  }
13465
13609
 
13466
13610
  const builtins = {
13467
- assert: true,
13468
- buffer: true,
13469
- console: true,
13470
- constants: true,
13471
- domain: true,
13472
- events: true,
13473
- http: true,
13474
- https: true,
13475
- os: true,
13476
- path: true,
13477
- process: true,
13478
- punycode: true,
13479
- querystring: true,
13480
- stream: true,
13481
- string_decoder: true,
13482
- timers: true,
13483
- tty: true,
13484
- url: true,
13485
- util: true,
13486
- vm: true,
13487
- zlib: true
13611
+ assert: 1,
13612
+ buffer: 1,
13613
+ console: 1,
13614
+ constants: 1,
13615
+ domain: 1,
13616
+ events: 1,
13617
+ http: 1,
13618
+ https: 1,
13619
+ os: 1,
13620
+ path: 1,
13621
+ process: 1,
13622
+ punycode: 1,
13623
+ querystring: 1,
13624
+ stream: 1,
13625
+ string_decoder: 1,
13626
+ timers: 1,
13627
+ tty: 1,
13628
+ url: 1,
13629
+ util: 1,
13630
+ vm: 1,
13631
+ zlib: 1
13488
13632
  };
13489
13633
  function warnOnBuiltins(warn, dependencies) {
13490
13634
  const externalBuiltins = dependencies
13491
13635
  .map(({ importPath }) => importPath)
13492
- .filter(importPath => importPath in builtins);
13636
+ .filter(importPath => importPath in builtins || importPath.startsWith('node:'));
13493
13637
  if (!externalBuiltins.length)
13494
13638
  return;
13495
- warn({
13496
- code: 'MISSING_NODE_BUILTINS',
13497
- message: `Creating a browser bundle that depends on Node.js built-in modules (${printQuotedStringList(externalBuiltins)}). You might need to include https://github.com/FredKSchott/rollup-plugin-polyfill-node`,
13498
- modules: externalBuiltins
13499
- });
13639
+ warn(errMissingNodeBuiltins(externalBuiltins));
13500
13640
  }
13501
13641
 
13502
13642
  function amd(magicString, { accessedGlobals, dependencies, exports, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
@@ -13734,24 +13874,18 @@ function trimEmptyImports(dependencies) {
13734
13874
  }
13735
13875
 
13736
13876
  function iife(magicString, { accessedGlobals, dependencies, exports, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
13737
- const { _, cnst, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
13877
+ const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
13738
13878
  const isNamespaced = name && name.includes('.');
13739
13879
  const useVariableAssignment = !extend && !isNamespaced;
13740
13880
  if (name && useVariableAssignment && !isLegal(name)) {
13741
- return error({
13742
- code: 'ILLEGAL_IDENTIFIER_AS_NAME',
13743
- message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`
13744
- });
13881
+ return error(errIllegalIdentifierAsName(name));
13745
13882
  }
13746
13883
  warnOnBuiltins(onwarn, dependencies);
13747
13884
  const external = trimEmptyImports(dependencies);
13748
13885
  const deps = external.map(dep => dep.globalName || 'null');
13749
13886
  const args = external.map(m => m.name);
13750
13887
  if (hasExports && !name) {
13751
- onwarn({
13752
- code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT',
13753
- message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`
13754
- });
13888
+ onwarn(errMissingNameOptionForIifeExport());
13755
13889
  }
13756
13890
  if (namedExportsMode && hasExports) {
13757
13891
  if (extend) {
@@ -13773,7 +13907,7 @@ function iife(magicString, { accessedGlobals, dependencies, exports, hasExports,
13773
13907
  if (hasExports) {
13774
13908
  if (name && !(extend && namedExportsMode)) {
13775
13909
  wrapperIntro =
13776
- (useVariableAssignment ? `${cnst} ${name}` : `this${keypath(name, getPropertyAccess)}`) +
13910
+ (useVariableAssignment ? `var ${name}` : `this${keypath(name, getPropertyAccess)}`) +
13777
13911
  `${_}=${_}${wrapperIntro}`;
13778
13912
  }
13779
13913
  if (isNamespaced) {
@@ -13945,10 +14079,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
13945
14079
  const factoryVar = compact ? 'f' : 'factory';
13946
14080
  const globalVar = compact ? 'g' : 'global';
13947
14081
  if (hasExports && !name) {
13948
- return error({
13949
- code: 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT',
13950
- message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.'
13951
- });
14082
+ return error(errMissingNameOptionForUmdExport());
13952
14083
  }
13953
14084
  warnOnBuiltins(onwarn, dependencies);
13954
14085
  const amdDeps = dependencies.map(m => `'${removeExtensionFromRelativeAmdId(m.importPath)}'`);
@@ -14039,7 +14170,7 @@ function umd(magicString, { accessedGlobals, dependencies, exports, hasExports,
14039
14170
 
14040
14171
  const finalisers = { amd, cjs, es, iife, system, umd };
14041
14172
 
14042
- const createHash = () => crypto.createHash('sha256');
14173
+ const createHash = () => node_crypto.createHash('sha256');
14043
14174
 
14044
14175
  // Four random characters from the private use area to minimize risk of conflicts
14045
14176
  const hashPlaceholderLeft = '\uf7f9\ue4d3';
@@ -14094,7 +14225,7 @@ function makeUnique(name, existingNames) {
14094
14225
  const existingNamesLowercase = new Set(Object.keys(existingNames).map(key => key.toLowerCase()));
14095
14226
  if (!existingNamesLowercase.has(name.toLocaleLowerCase()))
14096
14227
  return name;
14097
- const ext = require$$0.extname(name);
14228
+ const ext = node_path.extname(name);
14098
14229
  name = name.substring(0, name.length - ext.length);
14099
14230
  let uniqueName, uniqueIndex = 1;
14100
14231
  while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()))
@@ -14107,13 +14238,13 @@ function generateAssetFileName(name, source, outputOptions, bundle) {
14107
14238
  return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
14108
14239
  ? outputOptions.assetFileNames({ name, source, type: 'asset' })
14109
14240
  : outputOptions.assetFileNames, 'output.assetFileNames', {
14110
- ext: () => require$$0.extname(emittedName).substring(1),
14111
- extname: () => require$$0.extname(emittedName),
14241
+ ext: () => node_path.extname(emittedName).substring(1),
14242
+ extname: () => node_path.extname(emittedName),
14112
14243
  hash: size => createHash()
14113
14244
  .update(source)
14114
14245
  .digest('hex')
14115
14246
  .substring(0, size || defaultHashSize),
14116
- name: () => emittedName.substring(0, emittedName.length - require$$0.extname(emittedName).length)
14247
+ name: () => emittedName.substring(0, emittedName.length - node_path.extname(emittedName).length)
14117
14248
  }), bundle);
14118
14249
  }
14119
14250
  function reserveFileNameInBundle(fileName, bundle, warn) {
@@ -14602,19 +14733,14 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
14602
14733
  }
14603
14734
  }
14604
14735
 
14605
- const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx'];
14736
+ const NON_ASSET_EXTENSIONS = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.mts', '.cjs', '.cts'];
14606
14737
  function getGlobalName(chunk, globals, hasExports, warn) {
14607
14738
  const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
14608
14739
  if (globalName) {
14609
14740
  return globalName;
14610
14741
  }
14611
14742
  if (hasExports) {
14612
- warn({
14613
- code: 'MISSING_GLOBAL_NAME',
14614
- guess: chunk.variableName,
14615
- message: `No name was provided for external module '${chunk.id}' in output.globals – guessing '${chunk.variableName}'`,
14616
- source: chunk.id
14617
- });
14743
+ warn(errMissingGlobalName(chunk.id, chunk.variableName));
14618
14744
  return chunk.variableName;
14619
14745
  }
14620
14746
  }
@@ -14719,17 +14845,6 @@ class Chunk {
14719
14845
  const moduleExportNamesByVariable = module.getExportNamesByVariable();
14720
14846
  for (const exposedVariable of this.exports) {
14721
14847
  if (!moduleExportNamesByVariable.has(exposedVariable)) {
14722
- if (moduleExportNamesByVariable.size === 0 &&
14723
- module.isUserDefinedEntryPoint &&
14724
- module.preserveSignature === 'strict' &&
14725
- this.unsetOptions.has('preserveEntrySignatures')) {
14726
- this.inputOptions.onwarn({
14727
- code: 'EMPTY_FACADE',
14728
- id: module.id,
14729
- message: `To preserve the export signature of the entry module "${relativeId(module.id)}", an empty facade chunk was created. This often happens when creating a bundle for a web app where chunks are placed in script tags and exports are ignored. In this case it is recommended to set "preserveEntrySignatures: false" to avoid this and reduce the number of chunks. Otherwise if this is intentional, set "preserveEntrySignatures: 'strict'" explicitly to silence this warning.`,
14730
- url: 'https://rollupjs.org/guide/en/#preserveentrysignatures'
14731
- });
14732
- }
14733
14848
  return false;
14734
14849
  }
14735
14850
  }
@@ -14800,7 +14915,7 @@ class Chunk {
14800
14915
  if (module.preserveSignature) {
14801
14916
  this.strictFacade = needsStrictFacade;
14802
14917
  }
14803
- this.assignFacadeName(requiredFacades.shift(), module);
14918
+ this.assignFacadeName(requiredFacades.shift(), module, this.outputOptions.preserveModules);
14804
14919
  }
14805
14920
  }
14806
14921
  for (const facadeName of requiredFacades) {
@@ -14865,6 +14980,7 @@ class Chunk {
14865
14980
  return escapeId(getImportPath(importer, this.getFileName(), this.outputOptions.format === 'amd', true));
14866
14981
  }
14867
14982
  getPreliminaryFileName() {
14983
+ var _a;
14868
14984
  if (this.preliminaryFileName) {
14869
14985
  return this.preliminaryFileName;
14870
14986
  }
@@ -14872,16 +14988,13 @@ class Chunk {
14872
14988
  let hashPlaceholder = null;
14873
14989
  const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
14874
14990
  if (file) {
14875
- fileName = require$$0.basename(file);
14876
- }
14877
- else if (preserveModules) {
14878
- fileName = this.generateIdPreserveModules();
14991
+ fileName = node_path.basename(file);
14879
14992
  }
14880
14993
  else if (this.fileName !== null) {
14881
14994
  fileName = this.fileName;
14882
14995
  }
14883
14996
  else {
14884
- const [pattern, patternName] = this.facadeModule && this.facadeModule.isUserDefinedEntryPoint
14997
+ const [pattern, patternName] = preserveModules || ((_a = this.facadeModule) === null || _a === void 0 ? void 0 : _a.isUserDefinedEntryPoint)
14885
14998
  ? [entryFileNames, 'output.entryFileNames']
14886
14999
  : [chunkFileNames, 'output.chunkFileNames'];
14887
15000
  fileName = renderNamePattern(typeof pattern === 'function' ? pattern(this.getPreRenderedChunkInfo()) : pattern, patternName, {
@@ -14941,13 +15054,10 @@ class Chunk {
14941
15054
  }
14942
15055
  const preliminaryFileName = this.getPreliminaryFileName();
14943
15056
  const { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait } = this.renderModules(preliminaryFileName.fileName);
14944
- timeStart('render format', 2);
14945
15057
  const renderedDependencies = [...this.getRenderedDependencies().values()];
14946
15058
  const renderedExports = exportMode === 'none' ? [] : this.getChunkExportDeclarations(format);
14947
15059
  const hasExports = renderedExports.length !== 0 ||
14948
15060
  renderedDependencies.some(dep => (dep.reexports && dep.reexports.length !== 0));
14949
- // TODO Lukas Note: Mention in docs, that users/plugins are responsible to do their own caching
14950
- // TODO Lukas adapt plugin hook graphs and order in docs
14951
15061
  const { intro, outro, banner, footer } = await createAddons(outputOptions, pluginDriver, this.getRenderedChunkInfo());
14952
15062
  finalisers[format](renderedSource, {
14953
15063
  accessedGlobals,
@@ -14969,7 +15079,6 @@ class Chunk {
14969
15079
  magicString.prepend(banner);
14970
15080
  if (footer)
14971
15081
  magicString.append(footer);
14972
- timeEnd('render format', 2);
14973
15082
  return {
14974
15083
  chunk: this,
14975
15084
  magicString,
@@ -14995,12 +15104,15 @@ class Chunk {
14995
15104
  }
14996
15105
  }
14997
15106
  }
14998
- assignFacadeName({ fileName, name }, facadedModule) {
15107
+ assignFacadeName({ fileName, name }, facadedModule, preservePath) {
14999
15108
  if (fileName) {
15000
15109
  this.fileName = fileName;
15001
15110
  }
15002
15111
  else {
15003
- this.name = this.outputOptions.sanitizeFileName(name || getChunkNameFromModule(facadedModule));
15112
+ this.name = this.outputOptions.sanitizeFileName(name ||
15113
+ (preservePath
15114
+ ? this.getPreserveModulesChunkNameFromModule(facadedModule)
15115
+ : getChunkNameFromModule(facadedModule)));
15004
15116
  }
15005
15117
  }
15006
15118
  checkCircularDependencyImport(variable, importingModule) {
@@ -15047,46 +15159,6 @@ class Chunk {
15047
15159
  this.includedReexportsByModule.set(module, includedReexports);
15048
15160
  }
15049
15161
  }
15050
- generateIdPreserveModules() {
15051
- const [{ id }] = this.orderedModules;
15052
- const { entryFileNames, format, preserveModulesRoot, sanitizeFileName } = this.outputOptions;
15053
- const sanitizedId = sanitizeFileName(id.split(QUERY_HASH_REGEX, 1)[0]);
15054
- let path;
15055
- const patternOpt = this.unsetOptions.has('entryFileNames')
15056
- ? '[name][assetExtname].js'
15057
- : entryFileNames;
15058
- const pattern = typeof patternOpt === 'function' ? patternOpt(this.getPreRenderedChunkInfo()) : patternOpt;
15059
- if (isAbsolute(sanitizedId)) {
15060
- const currentDir = require$$0.dirname(sanitizedId);
15061
- const extension = require$$0.extname(sanitizedId);
15062
- const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
15063
- assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
15064
- ext: () => extension.substring(1),
15065
- extname: () => extension,
15066
- format: () => format,
15067
- name: () => this.getChunkName()
15068
- });
15069
- const currentPath = `${currentDir}/${fileName}`;
15070
- if (preserveModulesRoot && currentPath.startsWith(preserveModulesRoot)) {
15071
- path = currentPath.slice(preserveModulesRoot.length).replace(/^[\\/]/, '');
15072
- }
15073
- else {
15074
- path = relative(this.inputBase, currentPath);
15075
- }
15076
- }
15077
- else {
15078
- const extension = require$$0.extname(sanitizedId);
15079
- const fileName = renderNamePattern(pattern, 'output.entryFileNames', {
15080
- assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension),
15081
- ext: () => extension.substring(1),
15082
- extname: () => extension,
15083
- format: () => format,
15084
- name: () => getAliasName(sanitizedId)
15085
- });
15086
- path = `_virtual/${fileName}`;
15087
- }
15088
- return makeUnique(normalize(path), this.bundle);
15089
- }
15090
15162
  generateVariableName() {
15091
15163
  if (this.manualChunkAlias) {
15092
15164
  return this.manualChunkAlias;
@@ -15275,6 +15347,25 @@ class Chunk {
15275
15347
  type: 'chunk'
15276
15348
  });
15277
15349
  }
15350
+ getPreserveModulesChunkNameFromModule(module) {
15351
+ const predefinedChunkName = getPredefinedChunkNameFromModule(module);
15352
+ if (predefinedChunkName)
15353
+ return predefinedChunkName;
15354
+ const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
15355
+ const sanitizedId = sanitizeFileName(module.id.split(QUERY_HASH_REGEX, 1)[0]);
15356
+ const extName = node_path.extname(sanitizedId);
15357
+ const idWithoutExtension = NON_ASSET_EXTENSIONS.includes(extName)
15358
+ ? sanitizedId.slice(0, -extName.length)
15359
+ : sanitizedId;
15360
+ if (isAbsolute(idWithoutExtension)) {
15361
+ return preserveModulesRoot && node_path.resolve(idWithoutExtension).startsWith(preserveModulesRoot)
15362
+ ? idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[\\/]/, '')
15363
+ : relative(this.inputBase, idWithoutExtension);
15364
+ }
15365
+ else {
15366
+ return `_virtual/${node_path.basename(idWithoutExtension)}`;
15367
+ }
15368
+ }
15278
15369
  getReexportSpecifiers() {
15279
15370
  const { externalLiveBindings, interop } = this.outputOptions;
15280
15371
  const reexportSpecifiers = new Map();
@@ -15447,12 +15538,7 @@ class Chunk {
15447
15538
  }
15448
15539
  const renderedSource = compact ? magicString : magicString.trim();
15449
15540
  if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
15450
- const chunkName = this.getChunkName();
15451
- onwarn({
15452
- chunkName,
15453
- code: 'EMPTY_BUNDLE',
15454
- message: `Generated an empty chunk: "${chunkName}"`
15455
- });
15541
+ onwarn(errEmptyChunk(this.getChunkName()));
15456
15542
  }
15457
15543
  return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
15458
15544
  }
@@ -15581,8 +15667,12 @@ class Chunk {
15581
15667
  }
15582
15668
  }
15583
15669
  function getChunkNameFromModule(module) {
15584
- var _a, _b, _c, _d;
15585
- return ((_d = (_b = (_a = module.chunkNames.find(({ isUserDefined }) => isUserDefined)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = module.chunkNames[0]) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : getAliasName(module.id));
15670
+ var _a;
15671
+ return (_a = getPredefinedChunkNameFromModule(module)) !== null && _a !== void 0 ? _a : getAliasName(module.id);
15672
+ }
15673
+ function getPredefinedChunkNameFromModule(module) {
15674
+ var _a, _b, _c;
15675
+ return ((_b = (_a = module.chunkNames.find(({ isUserDefined }) => isUserDefined)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : (_c = module.chunkNames[0]) === null || _c === void 0 ? void 0 : _c.name);
15586
15676
  }
15587
15677
  function getImportedBindingsPerDependency(renderedDependencies, resolveFileName) {
15588
15678
  const importedBindingsPerDependency = {};
@@ -15745,7 +15835,7 @@ function commondir(files) {
15745
15835
  if (files.length === 0)
15746
15836
  return '/';
15747
15837
  if (files.length === 1)
15748
- return require$$0.dirname(files[0]);
15838
+ return node_path.dirname(files[0]);
15749
15839
  const commonSegments = files.slice(1).reduce((commonSegments, file) => {
15750
15840
  const pathSegements = file.split(/\/+|\\+/);
15751
15841
  let i;
@@ -15810,12 +15900,12 @@ function analyseModuleExecution(entryModules) {
15810
15900
  }
15811
15901
  function getCyclePath(module, parent, parents) {
15812
15902
  const cycleSymbol = Symbol(module.id);
15813
- const path = [relativeId(module.id)];
15903
+ const path = [module.id];
15814
15904
  let nextModule = parent;
15815
15905
  module.cycles.add(cycleSymbol);
15816
15906
  while (nextModule !== module) {
15817
15907
  nextModule.cycles.add(cycleSymbol);
15818
- path.push(relativeId(nextModule.id));
15908
+ path.push(nextModule.id);
15819
15909
  nextModule = parents.get(nextModule);
15820
15910
  }
15821
15911
  path.push(path[0]);
@@ -15987,14 +16077,7 @@ function getLinkMap(warn) {
15987
16077
  if (map.mappings) {
15988
16078
  return new Link(map, [source]);
15989
16079
  }
15990
- warn({
15991
- code: 'SOURCEMAP_BROKEN',
15992
- message: `Sourcemap is likely to be incorrect: a plugin (${map.plugin}) was used to transform ` +
15993
- "files, but didn't generate a sourcemap for the transformation. Consult the plugin " +
15994
- 'documentation for help',
15995
- plugin: map.plugin,
15996
- url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect`
15997
- });
16080
+ warn(errSourcemapBroken(map.plugin));
15998
16081
  return new Link({
15999
16082
  mappings: [],
16000
16083
  names: []
@@ -16009,9 +16092,9 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
16009
16092
  else {
16010
16093
  const sources = originalSourcemap.sources;
16011
16094
  const sourcesContent = originalSourcemap.sourcesContent || [];
16012
- const directory = require$$0.dirname(id) || '.';
16095
+ const directory = node_path.dirname(id) || '.';
16013
16096
  const sourceRoot = originalSourcemap.sourceRoot || '.';
16014
- const baseSources = sources.map((source, i) => new Source(require$$0.resolve(directory, sourceRoot, source), sourcesContent[i]));
16097
+ const baseSources = sources.map((source, i) => new Source(node_path.resolve(directory, sourceRoot, source), sourcesContent[i]));
16015
16098
  source = new Link(originalSourcemap, baseSources);
16016
16099
  }
16017
16100
  return sourcemapChain.reduce(linkMap, source);
@@ -16025,9 +16108,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
16025
16108
  const source = bundleSourcemapChain.reduce(linkMap, link);
16026
16109
  let { sources, sourcesContent, names, mappings } = source.traceMappings();
16027
16110
  if (file) {
16028
- const directory = require$$0.dirname(file);
16029
- sources = sources.map((source) => require$$0.relative(directory, source));
16030
- file = require$$0.basename(file);
16111
+ const directory = node_path.dirname(file);
16112
+ sources = sources.map((source) => node_path.relative(directory, source));
16113
+ file = node_path.basename(file);
16031
16114
  }
16032
16115
  sourcesContent = (excludeContent ? null : sourcesContent);
16033
16116
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
@@ -16060,12 +16143,16 @@ function decodedSourcemap(map) {
16060
16143
  }
16061
16144
 
16062
16145
  async function renderChunks(chunks, outputBundle, pluginDriver, outputOptions, onwarn) {
16146
+ timeStart('render chunks', 2);
16063
16147
  reserveEntryChunksInBundle(chunks);
16064
16148
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
16149
+ timeEnd('render chunks', 2);
16150
+ timeStart('transform chunks', 2);
16065
16151
  const chunkGraph = getChunkGraph(chunks);
16066
16152
  const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
16067
16153
  const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, outputBundle);
16068
- addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders);
16154
+ addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
16155
+ timeEnd('transform chunks', 2);
16069
16156
  }
16070
16157
  function reserveEntryChunksInBundle(chunks) {
16071
16158
  for (const chunk of chunks) {
@@ -16103,14 +16190,14 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16103
16190
  if (!compact && code[code.length - 1] !== '\n')
16104
16191
  code += '\n';
16105
16192
  if (sourcemap) {
16106
- timeStart('sourcemap', 2);
16193
+ timeStart('sourcemaps', 3);
16107
16194
  let file;
16108
16195
  if (options.file)
16109
- file = require$$0.resolve(options.sourcemapFile || options.file);
16196
+ file = node_path.resolve(options.sourcemapFile || options.file);
16110
16197
  else if (options.dir)
16111
- file = require$$0.resolve(options.dir, fileName);
16198
+ file = node_path.resolve(options.dir, fileName);
16112
16199
  else
16113
- file = require$$0.resolve(fileName);
16200
+ file = node_path.resolve(fileName);
16114
16201
  const decodedMap = magicString.generateDecodedMap({});
16115
16202
  map = collapseSourcemaps(file, decodedMap, usedModules, sourcemapChain, options.sourcemapExcludeSources, onwarn);
16116
16203
  map.sources = map.sources
@@ -16125,7 +16212,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
16125
16212
  return sourcePath;
16126
16213
  })
16127
16214
  .map(normalize);
16128
- timeEnd('sourcemap', 2);
16215
+ timeEnd('sourcemaps', 3);
16129
16216
  }
16130
16217
  return {
16131
16218
  code,
@@ -16208,22 +16295,40 @@ function generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlac
16208
16295
  }
16209
16296
  return hashesByPlaceholder;
16210
16297
  }
16211
- function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders) {
16298
+ function addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, outputBundle, nonHashedChunksWithPlaceholders, pluginDriver, options) {
16212
16299
  for (const { chunk, code, fileName, map } of renderedChunksByPlaceholder.values()) {
16213
- const updatedCode = replacePlaceholders(code, hashesByPlaceholder);
16300
+ let updatedCode = replacePlaceholders(code, hashesByPlaceholder);
16214
16301
  const finalFileName = replacePlaceholders(fileName, hashesByPlaceholder);
16215
16302
  if (map) {
16216
16303
  map.file = replacePlaceholders(map.file, hashesByPlaceholder);
16304
+ updatedCode += emitSourceMapAndGetComment(finalFileName, map, pluginDriver, options);
16217
16305
  }
16218
16306
  outputBundle[finalFileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16219
16307
  }
16220
16308
  for (const { chunk, code, fileName, map } of nonHashedChunksWithPlaceholders) {
16221
- const updatedCode = hashesByPlaceholder.size
16309
+ let updatedCode = hashesByPlaceholder.size
16222
16310
  ? replacePlaceholders(code, hashesByPlaceholder)
16223
16311
  : code;
16312
+ if (map) {
16313
+ updatedCode += emitSourceMapAndGetComment(fileName, map, pluginDriver, options);
16314
+ }
16224
16315
  outputBundle[fileName] = chunk.generateOutputChunk(updatedCode, map, hashesByPlaceholder);
16225
16316
  }
16226
16317
  }
16318
+ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, sourcemapBaseUrl }) {
16319
+ let url;
16320
+ if (sourcemap === 'inline') {
16321
+ url = map.toUrl();
16322
+ }
16323
+ else {
16324
+ const sourcemapFileName = `${node_path.basename(fileName)}.map`;
16325
+ url = sourcemapBaseUrl
16326
+ ? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
16327
+ : sourcemapFileName;
16328
+ pluginDriver.emitFile({ fileName: `${fileName}.map`, source: map.toString(), type: 'asset' });
16329
+ }
16330
+ return sourcemap === 'hidden' ? '' : `//# ${SOURCEMAPPING_URL}=${url}\n`;
16331
+ }
16227
16332
 
16228
16333
  class Bundle {
16229
16334
  constructor(outputOptions, unsetOptions, inputOptions, pluginDriver, graph) {
@@ -16239,9 +16344,10 @@ class Bundle {
16239
16344
  timeStart('GENERATE', 1);
16240
16345
  const outputBundle = Object.create(null);
16241
16346
  this.pluginDriver.setOutputBundle(outputBundle, this.outputOptions);
16242
- // TODO Lukas rethink time measuring points
16243
16347
  try {
16348
+ timeStart('initialize render', 2);
16244
16349
  await this.pluginDriver.hookParallel('renderStart', [this.outputOptions, this.inputOptions]);
16350
+ timeEnd('initialize render', 2);
16245
16351
  timeStart('generate chunks', 2);
16246
16352
  const getHashPlaceholder = getHashPlaceholderGenerator();
16247
16353
  const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
@@ -16249,24 +16355,24 @@ class Bundle {
16249
16355
  validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
16250
16356
  }
16251
16357
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
16252
- timeEnd('generate chunks', 2);
16253
- timeStart('render chunks', 2);
16254
16358
  for (const chunk of chunks) {
16255
16359
  chunk.generateExports();
16256
16360
  }
16361
+ timeEnd('generate chunks', 2);
16257
16362
  await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
16258
- timeEnd('render chunks', 2);
16259
16363
  }
16260
16364
  catch (err) {
16261
16365
  await this.pluginDriver.hookParallel('renderError', [err]);
16262
16366
  throw err;
16263
16367
  }
16368
+ timeStart('generate bundle', 2);
16264
16369
  await this.pluginDriver.hookSeq('generateBundle', [
16265
16370
  this.outputOptions,
16266
16371
  outputBundle,
16267
16372
  isWrite
16268
16373
  ]);
16269
16374
  this.finaliseAssets(outputBundle);
16375
+ timeEnd('generate bundle', 2);
16270
16376
  timeEnd('GENERATE', 1);
16271
16377
  return outputBundle;
16272
16378
  }
@@ -21946,37 +22052,6 @@ Parser.acorn = {
21946
22052
  nonASCIIwhitespace: nonASCIIwhitespace
21947
22053
  };
21948
22054
 
21949
- class Queue {
21950
- constructor(maxParallel) {
21951
- this.maxParallel = maxParallel;
21952
- this.queue = [];
21953
- this.workerCount = 0;
21954
- }
21955
- run(task) {
21956
- return new Promise((resolve, reject) => {
21957
- this.queue.push({ reject, resolve, task });
21958
- this.work();
21959
- });
21960
- }
21961
- async work() {
21962
- if (this.workerCount >= this.maxParallel)
21963
- return;
21964
- this.workerCount++;
21965
- let entry;
21966
- while ((entry = this.queue.shift())) {
21967
- const { reject, resolve, task } = entry;
21968
- try {
21969
- const result = await task();
21970
- resolve(result);
21971
- }
21972
- catch (err) {
21973
- reject(err);
21974
- }
21975
- }
21976
- this.workerCount--;
21977
- }
21978
- }
21979
-
21980
22055
  function resolveIdViaPlugins(source, importer, pluginDriver, moduleLoaderResolveId, skip, customOptions, isEntry) {
21981
22056
  let skipped = null;
21982
22057
  let replaceContext = null;
@@ -22009,7 +22084,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
22009
22084
  // absolute path is created. Absolute importees therefore shortcircuit the
22010
22085
  // resolve call and require no special handing on our part.
22011
22086
  // See https://nodejs.org/api/path.html#path_path_resolve_paths
22012
- return addJsExtensionIfNecessary(importer ? require$$0.resolve(require$$0.dirname(importer), source) : require$$0.resolve(source), preserveSymlinks);
22087
+ return addJsExtensionIfNecessary(importer ? node_path.resolve(node_path.dirname(importer), source) : node_path.resolve(source), preserveSymlinks);
22013
22088
  }
22014
22089
  async function addJsExtensionIfNecessary(file, preserveSymlinks) {
22015
22090
  var _a, _b;
@@ -22017,13 +22092,13 @@ async function addJsExtensionIfNecessary(file, preserveSymlinks) {
22017
22092
  }
22018
22093
  async function findFile(file, preserveSymlinks) {
22019
22094
  try {
22020
- const stats = await require$$0$1.promises.lstat(file);
22095
+ const stats = await node_fs.promises.lstat(file);
22021
22096
  if (!preserveSymlinks && stats.isSymbolicLink())
22022
- return await findFile(await require$$0$1.promises.realpath(file), preserveSymlinks);
22097
+ return await findFile(await node_fs.promises.realpath(file), preserveSymlinks);
22023
22098
  if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
22024
22099
  // check case
22025
- const name = require$$0.basename(file);
22026
- const files = await require$$0$1.promises.readdir(require$$0.dirname(file));
22100
+ const name = node_path.basename(file);
22101
+ const files = await node_fs.promises.readdir(node_path.dirname(file));
22027
22102
  if (files.includes(name))
22028
22103
  return file;
22029
22104
  }
@@ -22035,22 +22110,6 @@ async function findFile(file, preserveSymlinks) {
22035
22110
 
22036
22111
  const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
22037
22112
  const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position ';
22038
- function throwPluginError(err, plugin, { hook, id } = {}) {
22039
- if (typeof err === 'string')
22040
- err = { message: err };
22041
- if (err.code && err.code !== Errors.PLUGIN_ERROR) {
22042
- err.pluginCode = err.code;
22043
- }
22044
- err.code = Errors.PLUGIN_ERROR;
22045
- err.plugin = plugin;
22046
- if (hook) {
22047
- err.hook = hook;
22048
- }
22049
- if (id) {
22050
- err.id = id;
22051
- }
22052
- return error(err);
22053
- }
22054
22113
 
22055
22114
  function createPluginCache(cache) {
22056
22115
  return {
@@ -22111,15 +22170,9 @@ const NO_CACHE = {
22111
22170
  function uncacheablePluginError(pluginName) {
22112
22171
  if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
22113
22172
  pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
22114
- return error({
22115
- code: 'ANONYMOUS_PLUGIN_CACHE',
22116
- message: 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.'
22117
- });
22173
+ return error(errAnonymousPluginCache());
22118
22174
  }
22119
- return error({
22120
- code: 'DUPLICATE_PLUGIN_NAME',
22121
- message: `The plugin name ${pluginName} is being used twice in the same build. Plugin names must be distinct or provide a cacheKey (please post an issue to the plugin if you are a plugin user).`
22122
- });
22175
+ return error(errDuplicatePluginName(pluginName));
22123
22176
  }
22124
22177
  function getCacheForUncacheablePlugin(pluginName) {
22125
22178
  return {
@@ -22222,10 +22275,7 @@ async function transform(source, module, pluginDriver, warn) {
22222
22275
  });
22223
22276
  },
22224
22277
  setAssetSource() {
22225
- return this.error({
22226
- code: 'INVALID_SETASSETSOURCE',
22227
- message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
22228
- });
22278
+ return this.error(errInvalidSetAssetSourceCall());
22229
22279
  },
22230
22280
  warn(warning, pos) {
22231
22281
  if (typeof warning === 'string')
@@ -22240,7 +22290,7 @@ async function transform(source, module, pluginDriver, warn) {
22240
22290
  });
22241
22291
  }
22242
22292
  catch (err) {
22243
- throwPluginError(err, pluginName, { hook: 'transform', id });
22293
+ return error(errPluginError(err, pluginName, { hook: 'transform', id }));
22244
22294
  }
22245
22295
  if (!customTransformCache) {
22246
22296
  // files emitted by a transform hook need to be emitted again if the hook is skipped
@@ -22280,7 +22330,6 @@ class ModuleLoader {
22280
22330
  this.hasModuleSideEffects = options.treeshake
22281
22331
  ? options.treeshake.moduleSideEffects
22282
22332
  : () => true;
22283
- this.readQueue = new Queue(options.maxParallelFileReads);
22284
22333
  }
22285
22334
  async addAdditionalModules(unresolvedModules) {
22286
22335
  const result = this.extendLoadModulesPromise(Promise.all(unresolvedModules.map(id => this.loadEntryModule(id, false, undefined, null))));
@@ -22356,13 +22405,11 @@ class ModuleLoader {
22356
22405
  }));
22357
22406
  }
22358
22407
  async addModuleSource(id, importer, module) {
22359
- timeStart('load modules', 3);
22360
22408
  let source;
22361
22409
  try {
22362
- 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')); });
22410
+ source = await this.graph.fileOperationQueue.run(async () => { var _a; return (_a = (await this.pluginDriver.hookFirst('load', [id]))) !== null && _a !== void 0 ? _a : (await node_fs.promises.readFile(id, 'utf8')); });
22363
22411
  }
22364
22412
  catch (err) {
22365
- timeEnd('load modules', 3);
22366
22413
  let msg = `Could not load ${id}`;
22367
22414
  if (importer)
22368
22415
  msg += ` (imported by ${relativeId(importer)})`;
@@ -22370,7 +22417,6 @@ class ModuleLoader {
22370
22417
  err.message = msg;
22371
22418
  throw err;
22372
22419
  }
22373
- timeEnd('load modules', 3);
22374
22420
  const sourceDescription = typeof source === 'string'
22375
22421
  ? { code: source }
22376
22422
  : source != null && typeof source === 'object' && typeof source.code === 'string'
@@ -22658,8 +22704,8 @@ class ModuleLoader {
22658
22704
  function normalizeRelativeExternalId(source, importer) {
22659
22705
  return isRelative(source)
22660
22706
  ? importer
22661
- ? require$$0.resolve(importer, '..', source)
22662
- : require$$0.resolve(source)
22707
+ ? node_path.resolve(importer, '..', source)
22708
+ : node_path.resolve(source)
22663
22709
  : source;
22664
22710
  }
22665
22711
  function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
@@ -22724,7 +22770,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22724
22770
  else {
22725
22771
  cacheInstance = getCacheForUncacheablePlugin(plugin.name);
22726
22772
  }
22727
- const context = {
22773
+ return {
22728
22774
  addWatchFile(id) {
22729
22775
  if (graph.phase >= BuildPhase.GENERATE) {
22730
22776
  return this.error(errInvalidRollupPhaseForAddWatchFile());
@@ -22734,7 +22780,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22734
22780
  cache: cacheInstance,
22735
22781
  emitFile: fileEmitter.emitFile.bind(fileEmitter),
22736
22782
  error(err) {
22737
- return throwPluginError(err, plugin.name);
22783
+ return error(errPluginError(err, plugin.name));
22738
22784
  },
22739
22785
  getFileName: fileEmitter.getFileName,
22740
22786
  getModuleIds: () => graph.modulesById.keys(),
@@ -22774,9 +22820,9 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
22774
22820
  options.onwarn(warning);
22775
22821
  }
22776
22822
  };
22777
- return context;
22778
22823
  }
22779
22824
 
22825
+ // This will make sure no input hook is omitted
22780
22826
  const inputHookNames = {
22781
22827
  buildEnd: 1,
22782
22828
  buildStart: 1,
@@ -22792,18 +22838,13 @@ const inputHookNames = {
22792
22838
  watchChange: 1
22793
22839
  };
22794
22840
  const inputHooks = Object.keys(inputHookNames);
22795
- function throwInvalidHookError(hookName, pluginName) {
22796
- return error({
22797
- code: 'INVALID_PLUGIN_HOOK',
22798
- message: `Error running plugin hook ${hookName} for ${pluginName}, expected a function hook.`
22799
- });
22800
- }
22801
22841
  class PluginDriver {
22802
22842
  constructor(graph, options, userPlugins, pluginCache, basePluginDriver) {
22803
22843
  this.graph = graph;
22804
22844
  this.options = options;
22805
- this.unfulfilledActions = new Set();
22806
22845
  this.pluginCache = pluginCache;
22846
+ this.sortedPlugins = new Map();
22847
+ this.unfulfilledActions = new Set();
22807
22848
  this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
22808
22849
  this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
22809
22850
  this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
@@ -22834,21 +22875,21 @@ class PluginDriver {
22834
22875
  }
22835
22876
  // chains, first non-null result stops and returns
22836
22877
  hookFirst(hookName, args, replaceContext, skipped) {
22837
- let promise = Promise.resolve(undefined);
22838
- for (const plugin of this.plugins) {
22878
+ let promise = Promise.resolve(null);
22879
+ for (const plugin of this.getSortedPlugins(hookName)) {
22839
22880
  if (skipped && skipped.has(plugin))
22840
22881
  continue;
22841
22882
  promise = promise.then(result => {
22842
22883
  if (result != null)
22843
22884
  return result;
22844
- return this.runHook(hookName, args, plugin, false, replaceContext);
22885
+ return this.runHook(hookName, args, plugin, replaceContext);
22845
22886
  });
22846
22887
  }
22847
22888
  return promise;
22848
22889
  }
22849
22890
  // chains synchronously, first non-null result stops and returns
22850
22891
  hookFirstSync(hookName, args, replaceContext) {
22851
- for (const plugin of this.plugins) {
22892
+ for (const plugin of this.getSortedPlugins(hookName)) {
22852
22893
  const result = this.runHookSync(hookName, args, plugin, replaceContext);
22853
22894
  if (result != null)
22854
22895
  return result;
@@ -22856,56 +22897,58 @@ class PluginDriver {
22856
22897
  return null;
22857
22898
  }
22858
22899
  // parallel, ignores returns
22859
- hookParallel(hookName, args, replaceContext) {
22860
- const promises = [];
22861
- for (const plugin of this.plugins) {
22862
- const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext);
22863
- if (!hookPromise)
22864
- continue;
22865
- promises.push(hookPromise);
22900
+ async hookParallel(hookName, args, replaceContext) {
22901
+ const parallelPromises = [];
22902
+ for (const plugin of this.getSortedPlugins(hookName)) {
22903
+ if (plugin[hookName].sequential) {
22904
+ await Promise.all(parallelPromises);
22905
+ parallelPromises.length = 0;
22906
+ await this.runHook(hookName, args, plugin, replaceContext);
22907
+ }
22908
+ else {
22909
+ parallelPromises.push(this.runHook(hookName, args, plugin, replaceContext));
22910
+ }
22866
22911
  }
22867
- return Promise.all(promises).then(() => { });
22912
+ await Promise.all(parallelPromises);
22868
22913
  }
22869
22914
  // chains, reduces returned value, handling the reduced value as the first hook argument
22870
22915
  hookReduceArg0(hookName, [arg0, ...rest], reduce, replaceContext) {
22871
22916
  let promise = Promise.resolve(arg0);
22872
- for (const plugin of this.plugins) {
22873
- promise = promise.then(arg0 => {
22874
- const args = [arg0, ...rest];
22875
- const hookPromise = this.runHook(hookName, args, plugin, false, replaceContext);
22876
- if (!hookPromise)
22877
- return arg0;
22878
- return hookPromise.then(result => reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin));
22879
- });
22917
+ for (const plugin of this.getSortedPlugins(hookName)) {
22918
+ promise = promise.then(arg0 => this.runHook(hookName, [arg0, ...rest], plugin, replaceContext).then(result => reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin)));
22880
22919
  }
22881
22920
  return promise;
22882
22921
  }
22883
22922
  // chains synchronously, reduces returned value, handling the reduced value as the first hook argument
22884
22923
  hookReduceArg0Sync(hookName, [arg0, ...rest], reduce, replaceContext) {
22885
- for (const plugin of this.plugins) {
22924
+ for (const plugin of this.getSortedPlugins(hookName)) {
22886
22925
  const args = [arg0, ...rest];
22887
22926
  const result = this.runHookSync(hookName, args, plugin, replaceContext);
22888
22927
  arg0 = reduce.call(this.pluginContexts.get(plugin), arg0, result, plugin);
22889
22928
  }
22890
22929
  return arg0;
22891
22930
  }
22892
- // chains, reduces returned value to type T, handling the reduced value separately. permits hooks as values.
22893
- hookReduceValue(hookName, initialValue, args, reduce, replaceContext) {
22894
- let promise = Promise.resolve(initialValue);
22895
- for (const plugin of this.plugins) {
22896
- promise = promise.then(value => {
22897
- const hookPromise = this.runHook(hookName, args, plugin, true, replaceContext);
22898
- if (!hookPromise)
22899
- return value;
22900
- return hookPromise.then(result => reduce.call(this.pluginContexts.get(plugin), value, result, plugin));
22901
- });
22931
+ // chains, reduces returned value to type string, handling the reduced value separately. permits hooks as values.
22932
+ async hookReduceValue(hookName, initialValue, args, reducer) {
22933
+ const results = [];
22934
+ const parallelResults = [];
22935
+ for (const plugin of this.getSortedPlugins(hookName, validateAddonPluginHandler)) {
22936
+ if (plugin[hookName].sequential) {
22937
+ results.push(...(await Promise.all(parallelResults)));
22938
+ parallelResults.length = 0;
22939
+ results.push(await this.runHook(hookName, args, plugin));
22940
+ }
22941
+ else {
22942
+ parallelResults.push(this.runHook(hookName, args, plugin));
22943
+ }
22902
22944
  }
22903
- return promise;
22945
+ results.push(...(await Promise.all(parallelResults)));
22946
+ return results.reduce(reducer, await initialValue);
22904
22947
  }
22905
22948
  // chains synchronously, reduces returned value to type T, handling the reduced value separately. permits hooks as values.
22906
22949
  hookReduceValueSync(hookName, initialValue, args, reduce, replaceContext) {
22907
22950
  let acc = initialValue;
22908
- for (const plugin of this.plugins) {
22951
+ for (const plugin of this.getSortedPlugins(hookName)) {
22909
22952
  const result = this.runHookSync(hookName, args, plugin, replaceContext);
22910
22953
  acc = reduce.call(this.pluginContexts.get(plugin), acc, result, plugin);
22911
22954
  }
@@ -22914,31 +22957,32 @@ class PluginDriver {
22914
22957
  // chains, ignores returns
22915
22958
  hookSeq(hookName, args, replaceContext) {
22916
22959
  let promise = Promise.resolve();
22917
- for (const plugin of this.plugins) {
22918
- promise = promise.then(() => this.runHook(hookName, args, plugin, false, replaceContext));
22960
+ for (const plugin of this.getSortedPlugins(hookName)) {
22961
+ promise = promise.then(() => this.runHook(hookName, args, plugin, replaceContext));
22919
22962
  }
22920
- return promise;
22963
+ return promise.then(noReturn);
22964
+ }
22965
+ getSortedPlugins(hookName, validateHandler) {
22966
+ return getOrCreate(this.sortedPlugins, hookName, () => getSortedValidatedPlugins(hookName, this.plugins, validateHandler));
22921
22967
  }
22922
- runHook(hookName, args, plugin, permitValues, hookContext) {
22968
+ // Implementation signature
22969
+ runHook(hookName, args, plugin, replaceContext) {
22970
+ // We always filter for plugins that support the hook before running it
22923
22971
  const hook = plugin[hookName];
22924
- if (!hook)
22925
- return undefined;
22972
+ const handler = typeof hook === 'object' ? hook.handler : hook;
22926
22973
  let context = this.pluginContexts.get(plugin);
22927
- if (hookContext) {
22928
- context = hookContext(context, plugin);
22974
+ if (replaceContext) {
22975
+ context = replaceContext(context, plugin);
22929
22976
  }
22930
22977
  let action = null;
22931
22978
  return Promise.resolve()
22932
22979
  .then(() => {
22933
- // permit values allows values to be returned instead of a functional hook
22934
- if (typeof hook !== 'function') {
22935
- if (permitValues)
22936
- return hook;
22937
- return throwInvalidHookError(hookName, plugin.name);
22980
+ if (typeof handler !== 'function') {
22981
+ return handler;
22938
22982
  }
22939
22983
  // eslint-disable-next-line @typescript-eslint/ban-types
22940
- const hookResult = hook.apply(context, args);
22941
- if (!hookResult || !hookResult.then) {
22984
+ const hookResult = handler.apply(context, args);
22985
+ if (!(hookResult === null || hookResult === void 0 ? void 0 : hookResult.then)) {
22942
22986
  // short circuit for non-thenables and non-Promises
22943
22987
  return hookResult;
22944
22988
  }
@@ -22963,7 +23007,7 @@ class PluginDriver {
22963
23007
  // action considered to be fulfilled since error being handled
22964
23008
  this.unfulfilledActions.delete(action);
22965
23009
  }
22966
- return throwPluginError(err, plugin.name, { hook: hookName });
23010
+ return error(errPluginError(err, plugin.name, { hook: hookName }));
22967
23011
  });
22968
23012
  }
22969
23013
  /**
@@ -22971,29 +23015,92 @@ class PluginDriver {
22971
23015
  * @param hookName Name of the plugin hook. Must be in `PluginHooks`.
22972
23016
  * @param args Arguments passed to the plugin hook.
22973
23017
  * @param plugin The acutal plugin
22974
- * @param hookContext When passed, the plugin context can be overridden.
23018
+ * @param replaceContext When passed, the plugin context can be overridden.
22975
23019
  */
22976
- runHookSync(hookName, args, plugin, hookContext) {
23020
+ runHookSync(hookName, args, plugin, replaceContext) {
22977
23021
  const hook = plugin[hookName];
22978
- if (!hook)
22979
- return undefined;
23022
+ const handler = typeof hook === 'object' ? hook.handler : hook;
22980
23023
  let context = this.pluginContexts.get(plugin);
22981
- if (hookContext) {
22982
- context = hookContext(context, plugin);
23024
+ if (replaceContext) {
23025
+ context = replaceContext(context, plugin);
22983
23026
  }
22984
23027
  try {
22985
- // permit values allows values to be returned instead of a functional hook
22986
- if (typeof hook !== 'function') {
22987
- return throwInvalidHookError(hookName, plugin.name);
22988
- }
22989
23028
  // eslint-disable-next-line @typescript-eslint/ban-types
22990
- return hook.apply(context, args);
23029
+ return handler.apply(context, args);
22991
23030
  }
22992
23031
  catch (err) {
22993
- return throwPluginError(err, plugin.name, { hook: hookName });
23032
+ return error(errPluginError(err, plugin.name, { hook: hookName }));
22994
23033
  }
22995
23034
  }
22996
23035
  }
23036
+ function getSortedValidatedPlugins(hookName, plugins, validateHandler = validateFunctionPluginHandler) {
23037
+ const pre = [];
23038
+ const normal = [];
23039
+ const post = [];
23040
+ for (const plugin of plugins) {
23041
+ const hook = plugin[hookName];
23042
+ if (hook) {
23043
+ if (typeof hook === 'object') {
23044
+ validateHandler(hook.handler, hookName, plugin);
23045
+ if (hook.order === 'pre') {
23046
+ pre.push(plugin);
23047
+ continue;
23048
+ }
23049
+ if (hook.order === 'post') {
23050
+ post.push(plugin);
23051
+ continue;
23052
+ }
23053
+ }
23054
+ else {
23055
+ validateHandler(hook, hookName, plugin);
23056
+ }
23057
+ normal.push(plugin);
23058
+ }
23059
+ }
23060
+ return [...pre, ...normal, ...post];
23061
+ }
23062
+ function validateFunctionPluginHandler(handler, hookName, plugin) {
23063
+ if (typeof handler !== 'function') {
23064
+ error(errInvalidFunctionPluginHook(hookName, plugin.name));
23065
+ }
23066
+ }
23067
+ function validateAddonPluginHandler(handler, hookName, plugin) {
23068
+ if (typeof handler !== 'string' && typeof handler !== 'function') {
23069
+ return error(errInvalidAddonPluginHook(hookName, plugin.name));
23070
+ }
23071
+ }
23072
+ function noReturn() { }
23073
+
23074
+ class Queue {
23075
+ constructor(maxParallel) {
23076
+ this.maxParallel = maxParallel;
23077
+ this.queue = [];
23078
+ this.workerCount = 0;
23079
+ }
23080
+ run(task) {
23081
+ return new Promise((resolve, reject) => {
23082
+ this.queue.push({ reject, resolve, task });
23083
+ this.work();
23084
+ });
23085
+ }
23086
+ async work() {
23087
+ if (this.workerCount >= this.maxParallel)
23088
+ return;
23089
+ this.workerCount++;
23090
+ let entry;
23091
+ while ((entry = this.queue.shift())) {
23092
+ const { reject, resolve, task } = entry;
23093
+ try {
23094
+ const result = await task();
23095
+ resolve(result);
23096
+ }
23097
+ catch (err) {
23098
+ reject(err);
23099
+ }
23100
+ }
23101
+ this.workerCount--;
23102
+ }
23103
+ }
22997
23104
 
22998
23105
  function normalizeEntryModules(entryModules) {
22999
23106
  if (Array.isArray(entryModules)) {
@@ -23058,15 +23165,16 @@ class Graph {
23058
23165
  this.pluginDriver = new PluginDriver(this, options, options.plugins, this.pluginCache);
23059
23166
  this.acornParser = Parser.extend(...options.acornInjectPlugins);
23060
23167
  this.moduleLoader = new ModuleLoader(this, this.modulesById, this.options, this.pluginDriver);
23168
+ this.fileOperationQueue = new Queue(options.maxParallelFileOps);
23061
23169
  }
23062
23170
  async build() {
23063
23171
  timeStart('generate module graph', 2);
23064
23172
  await this.generateModuleGraph();
23065
23173
  timeEnd('generate module graph', 2);
23066
- timeStart('sort modules', 2);
23174
+ timeStart('sort and bind modules', 2);
23067
23175
  this.phase = BuildPhase.ANALYSE;
23068
23176
  this.sortModules();
23069
- timeEnd('sort modules', 2);
23177
+ timeEnd('sort and bind modules', 2);
23070
23178
  timeStart('mark included statements', 2);
23071
23179
  this.includeStatements();
23072
23180
  timeEnd('mark included statements', 2);
@@ -23178,12 +23286,7 @@ class Graph {
23178
23286
  sortModules() {
23179
23287
  const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
23180
23288
  for (const cyclePath of cyclePaths) {
23181
- this.options.onwarn({
23182
- code: 'CIRCULAR_DEPENDENCY',
23183
- cycle: cyclePath,
23184
- importer: cyclePath[0],
23185
- message: `Circular dependency: ${cyclePath.join(' -> ')}`
23186
- });
23289
+ this.options.onwarn(errCircularDependency(cyclePath));
23187
23290
  }
23188
23291
  this.modules = orderedModules;
23189
23292
  for (const module of this.modules) {
@@ -23196,12 +23299,7 @@ class Graph {
23196
23299
  for (const importDescription of module.importDescriptions.values()) {
23197
23300
  if (importDescription.name !== '*' &&
23198
23301
  !importDescription.module.getVariableForExportName(importDescription.name)[0]) {
23199
- module.warn({
23200
- code: 'NON_EXISTENT_EXPORT',
23201
- message: `Non-existent export '${importDescription.name}' is imported from ${relativeId(importDescription.module.id)}`,
23202
- name: importDescription.name,
23203
- source: importDescription.module.id
23204
- }, importDescription.start);
23302
+ module.warn(errMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
23205
23303
  }
23206
23304
  }
23207
23305
  }
@@ -23228,7 +23326,7 @@ function formatAction([pluginName, hookName, args]) {
23228
23326
  // We do not directly listen on process to avoid max listeners warnings for
23229
23327
  // complicated build processes
23230
23328
  const beforeExitEvent = 'beforeExit';
23231
- const beforeExitEmitter = new require$$0$2.EventEmitter();
23329
+ const beforeExitEmitter = new node_events.EventEmitter();
23232
23330
  beforeExitEmitter.setMaxListeners(0);
23233
23331
  process$1.on(beforeExitEvent, () => beforeExitEmitter.emit(beforeExitEvent));
23234
23332
  async function catchUnfinishedHookActions(pluginDriver, callback) {
@@ -23247,13 +23345,14 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
23247
23345
  }
23248
23346
 
23249
23347
  function normalizeInputOptions(config) {
23250
- var _a, _b, _c;
23348
+ var _a, _b, _c, _d;
23251
23349
  // These are options that may trigger special warnings or behaviour later
23252
23350
  // if the user did not select an explicit value
23253
23351
  const unsetOptions = new Set();
23254
23352
  const context = (_a = config.context) !== null && _a !== void 0 ? _a : 'undefined';
23255
23353
  const onwarn = getOnwarn(config);
23256
23354
  const strictDeprecations = config.strictDeprecations || false;
23355
+ const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
23257
23356
  const options = {
23258
23357
  acorn: getAcorn(config),
23259
23358
  acornInjectPlugins: getAcornInjectPlugins(config),
@@ -23263,14 +23362,15 @@ function normalizeInputOptions(config) {
23263
23362
  external: getIdMatcher(config.external),
23264
23363
  inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
23265
23364
  input: getInput(config),
23266
- makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : true,
23365
+ makeAbsoluteExternalsRelative: (_c = config.makeAbsoluteExternalsRelative) !== null && _c !== void 0 ? _c : 'ifRelativeSource',
23267
23366
  manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
23268
- maxParallelFileReads: getMaxParallelFileReads(config),
23367
+ maxParallelFileOps,
23368
+ maxParallelFileReads: maxParallelFileOps,
23269
23369
  moduleContext: getModuleContext(config, context),
23270
23370
  onwarn,
23271
23371
  perf: config.perf || false,
23272
23372
  plugins: ensureArray$1(config.plugins),
23273
- preserveEntrySignatures: getPreserveEntrySignatures(config, unsetOptions),
23373
+ preserveEntrySignatures: (_d = config.preserveEntrySignatures) !== null && _d !== void 0 ? _d : 'exports-only',
23274
23374
  preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
23275
23375
  preserveSymlinks: config.preserveSymlinks || false,
23276
23376
  shimMissingExports: config.shimMissingExports || false,
@@ -23346,12 +23446,17 @@ const getManualChunks$1 = (config, warn, strictDeprecations) => {
23346
23446
  }
23347
23447
  return configManualChunks;
23348
23448
  };
23349
- const getMaxParallelFileReads = (config) => {
23449
+ const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
23450
+ var _a;
23350
23451
  const maxParallelFileReads = config.maxParallelFileReads;
23351
23452
  if (typeof maxParallelFileReads === 'number') {
23352
- if (maxParallelFileReads <= 0)
23453
+ warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
23454
+ }
23455
+ const maxParallelFileOps = (_a = config.maxParallelFileOps) !== null && _a !== void 0 ? _a : maxParallelFileReads;
23456
+ if (typeof maxParallelFileOps === 'number') {
23457
+ if (maxParallelFileOps <= 0)
23353
23458
  return Infinity;
23354
- return maxParallelFileReads;
23459
+ return maxParallelFileOps;
23355
23460
  }
23356
23461
  return 20;
23357
23462
  };
@@ -23363,19 +23468,12 @@ const getModuleContext = (config, context) => {
23363
23468
  if (configModuleContext) {
23364
23469
  const contextByModuleId = Object.create(null);
23365
23470
  for (const [key, moduleContext] of Object.entries(configModuleContext)) {
23366
- contextByModuleId[require$$0.resolve(key)] = moduleContext;
23471
+ contextByModuleId[node_path.resolve(key)] = moduleContext;
23367
23472
  }
23368
23473
  return id => contextByModuleId[id] || context;
23369
23474
  }
23370
23475
  return () => context;
23371
23476
  };
23372
- const getPreserveEntrySignatures = (config, unsetOptions) => {
23373
- const configPreserveEntrySignatures = config.preserveEntrySignatures;
23374
- if (configPreserveEntrySignatures == null) {
23375
- unsetOptions.add('preserveEntrySignatures');
23376
- }
23377
- return configPreserveEntrySignatures !== null && configPreserveEntrySignatures !== void 0 ? configPreserveEntrySignatures : 'strict';
23378
- };
23379
23477
  const getPreserveModules$1 = (config, warn, strictDeprecations) => {
23380
23478
  const configPreserveModules = config.preserveModules;
23381
23479
  if (configPreserveModules) {
@@ -23576,7 +23674,7 @@ const getPreserveModulesRoot = (config) => {
23576
23674
  if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
23577
23675
  return undefined;
23578
23676
  }
23579
- return require$$0.resolve(preserveModulesRoot);
23677
+ return node_path.resolve(preserveModulesRoot);
23580
23678
  };
23581
23679
  const getAmd = (config) => {
23582
23680
  const mergedOption = {
@@ -23655,7 +23753,7 @@ const getGeneratedCode = (config, preferConst) => {
23655
23753
  arrowFunctions: configWithPreset.arrowFunctions === true,
23656
23754
  constBindings: configWithPreset.constBindings === true || preferConst,
23657
23755
  objectShorthand: configWithPreset.objectShorthand === true,
23658
- reservedNamesAsProps: configWithPreset.reservedNamesAsProps === true,
23756
+ reservedNamesAsProps: configWithPreset.reservedNamesAsProps !== false,
23659
23757
  symbols: configWithPreset.symbols === true
23660
23758
  };
23661
23759
  };
@@ -23748,7 +23846,9 @@ async function rollupInternal(rawInputOptions, watcher) {
23748
23846
  timeStart('BUILD', 1);
23749
23847
  await catchUnfinishedHookActions(graph.pluginDriver, async () => {
23750
23848
  try {
23849
+ timeStart('initialize', 2);
23751
23850
  await graph.pluginDriver.hookParallel('buildStart', [inputOptions]);
23851
+ timeEnd('initialize', 2);
23752
23852
  await graph.build();
23753
23853
  }
23754
23854
  catch (err) {
@@ -23792,17 +23892,15 @@ async function getInputOptions(rawInputOptions, watchMode) {
23792
23892
  if (!rawInputOptions) {
23793
23893
  throw new Error('You must supply an options object to rollup');
23794
23894
  }
23795
- const rawPlugins = ensureArray$1(rawInputOptions.plugins);
23895
+ const rawPlugins = getSortedValidatedPlugins('options', ensureArray$1(rawInputOptions.plugins));
23796
23896
  const { options, unsetOptions } = normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
23797
23897
  normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
23798
23898
  return { options, unsetOptions };
23799
23899
  }
23800
23900
  function applyOptionHook(watchMode) {
23801
23901
  return async (inputOptions, plugin) => {
23802
- if (plugin.options) {
23803
- return ((await plugin.options.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) || inputOptions);
23804
- }
23805
- return inputOptions;
23902
+ const handler = 'handler' in plugin.options ? plugin.options.handler : plugin.options;
23903
+ return ((await handler.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) || inputOptions);
23806
23904
  };
23807
23905
  }
23808
23906
  function normalizePlugins(plugins, anonymousPrefix) {
@@ -23818,14 +23916,13 @@ function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, rawOutput
23818
23916
  const bundle = new Bundle(outputOptions, unsetOptions, inputOptions, outputPluginDriver, graph);
23819
23917
  const generated = await bundle.generate(isWrite);
23820
23918
  if (isWrite) {
23919
+ timeStart('WRITE', 1);
23821
23920
  if (!outputOptions.dir && !outputOptions.file) {
23822
- return error({
23823
- code: 'MISSING_OPTION',
23824
- message: 'You must specify "output.file" or "output.dir" for the build.'
23825
- });
23921
+ return error(errMissingFileOrDirOption());
23826
23922
  }
23827
- await Promise.all(Object.values(generated).map(chunk => writeOutputFile(chunk, outputOptions)));
23923
+ await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
23828
23924
  await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
23925
+ timeEnd('WRITE', 1);
23829
23926
  }
23830
23927
  return createOutput(generated);
23831
23928
  });
@@ -23879,35 +23976,10 @@ function getSortingFileType(file) {
23879
23976
  return SortingFileType.SECONDARY_CHUNK;
23880
23977
  }
23881
23978
  async function writeOutputFile(outputFile, outputOptions) {
23882
- const fileName = require$$0.resolve(outputOptions.dir || require$$0.dirname(outputOptions.file), outputFile.fileName);
23979
+ const fileName = node_path.resolve(outputOptions.dir || node_path.dirname(outputOptions.file), outputFile.fileName);
23883
23980
  // 'recursive: true' does not throw if the folder structure, or parts of it, already exist
23884
- await require$$0$1.promises.mkdir(require$$0.dirname(fileName), { recursive: true });
23885
- let writeSourceMapPromise;
23886
- let source;
23887
- if (outputFile.type === 'asset') {
23888
- source = outputFile.source;
23889
- }
23890
- else {
23891
- source = outputFile.code;
23892
- if (outputOptions.sourcemap && outputFile.map) {
23893
- let url;
23894
- if (outputOptions.sourcemap === 'inline') {
23895
- url = outputFile.map.toUrl();
23896
- }
23897
- else {
23898
- const { sourcemapBaseUrl } = outputOptions;
23899
- const sourcemapFileName = `${require$$0.basename(outputFile.fileName)}.map`;
23900
- url = sourcemapBaseUrl
23901
- ? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
23902
- : sourcemapFileName;
23903
- writeSourceMapPromise = require$$0$1.promises.writeFile(`${fileName}.map`, outputFile.map.toString());
23904
- }
23905
- if (outputOptions.sourcemap !== 'hidden') {
23906
- source += `//# ${exports.SOURCEMAPPING_URL}=${url}\n`;
23907
- }
23908
- }
23909
- }
23910
- return Promise.all([require$$0$1.promises.writeFile(fileName, source), writeSourceMapPromise]);
23981
+ await node_fs.promises.mkdir(node_path.dirname(fileName), { recursive: true });
23982
+ return node_fs.promises.writeFile(fileName, outputFile.type === 'asset' ? outputFile.source : outputFile.code);
23911
23983
  }
23912
23984
  /**
23913
23985
  * Auxiliary function for defining rollup configuration
@@ -23918,7 +23990,7 @@ function defineConfig(options) {
23918
23990
  return options;
23919
23991
  }
23920
23992
 
23921
- class WatchEmitter extends require$$0$2.EventEmitter {
23993
+ class WatchEmitter extends node_events.EventEmitter {
23922
23994
  constructor() {
23923
23995
  super();
23924
23996
  this.awaitedHandlers = Object.create(null);
@@ -23963,6 +24035,12 @@ exports.createFilter = createFilter;
23963
24035
  exports.defaultOnWarn = defaultOnWarn;
23964
24036
  exports.defineConfig = defineConfig;
23965
24037
  exports.ensureArray = ensureArray$1;
24038
+ exports.errDuplicateImportOptions = errDuplicateImportOptions;
24039
+ exports.errFailAfterWarnings = errFailAfterWarnings;
24040
+ exports.errMissingConfig = errMissingConfig;
24041
+ exports.errMissingExternalConfig = errMissingExternalConfig;
24042
+ exports.errOnlyInlineSourcemapsForStdout = errOnlyInlineSourcemapsForStdout;
24043
+ exports.errTranspiledEsmConfig = errTranspiledEsmConfig;
23966
24044
  exports.error = error;
23967
24045
  exports.fseventsImporter = fseventsImporter;
23968
24046
  exports.generatedCodePresets = generatedCodePresets;