rollup 3.10.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v3.10.1
4
- Fri, 20 Jan 2023 15:10:53 GMT - commit c8c40c8fbb05a58b318231f9d8df6c6fee0c1447
3
+ Rollup.js v3.12.0
4
+ Sat, 28 Jan 2023 05:55:49 GMT - commit 01ddea09dfdf1c396c1c24ba3d97743698fe1508
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -16,7 +16,7 @@ import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/pr
16
16
  import { EventEmitter } from 'node:events';
17
17
  import * as tty from 'tty';
18
18
 
19
- var version$1 = "3.10.1";
19
+ var version$1 = "3.12.0";
20
20
 
21
21
  const comma = ','.charCodeAt(0);
22
22
  const semicolon = ';'.charCodeAt(0);
@@ -2036,6 +2036,53 @@ function printQuotedStringList(list, verbs) {
2036
2036
  return output;
2037
2037
  }
2038
2038
 
2039
+ function isValidUrl(url) {
2040
+ try {
2041
+ new URL(url);
2042
+ }
2043
+ catch {
2044
+ return false;
2045
+ }
2046
+ return true;
2047
+ }
2048
+ function getRollupUrl(snippet) {
2049
+ return `https://rollupjs.org/${snippet}`;
2050
+ }
2051
+
2052
+ // troubleshooting
2053
+ const URL_AVOIDING_EVAL = 'troubleshooting/#avoiding-eval';
2054
+ const URL_NAME_IS_NOT_EXPORTED = 'troubleshooting/#error-name-is-not-exported-by-module';
2055
+ const URL_THIS_IS_UNDEFINED = 'troubleshooting/#error-this-is-undefined';
2056
+ const URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = 'troubleshooting/#warning-treating-module-as-external-dependency';
2057
+ const URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = 'troubleshooting/#warning-sourcemap-is-likely-to-be-incorrect';
2058
+ // configuration-options
2059
+ const URL_MAXPARALLELFILEOPS = 'configuration-options/#maxparallelfileops';
2060
+ const URL_OUTPUT_AMD_ID = 'configuration-options/#output-amd-id';
2061
+ const URL_OUTPUT_AMD_BASEPATH = 'configuration-options/#output-amd-basepath';
2062
+ const URL_OUTPUT_DIR = 'configuration-options/#output-dir';
2063
+ const URL_OUTPUT_DYNAMICIMPORTFUNCTION = 'configuration-options/#output-dynamicimportfunction';
2064
+ const URL_OUTPUT_EXPORTS = 'configuration-options/#output-exports';
2065
+ const URL_OUTPUT_EXTEND = 'configuration-options/#output-extend';
2066
+ const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
2067
+ const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
2068
+ const URL_OUTPUT_GENERATEDCODE_CONSTBINDINGS = 'configuration-options/#output-generatedcode-constbindings';
2069
+ const URL_OUTPUT_GENERATEDCODE_SYMBOLS = 'configuration-options/#output-generatedcode-symbols';
2070
+ const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
2071
+ const URL_OUTPUT_INLINEDYNAMICIMPORTS = 'configuration-options/#output-inlinedynamicimports';
2072
+ const URL_OUTPUT_INTEROP = 'configuration-options/#output-interop';
2073
+ const URL_OUTPUT_MANUALCHUNKS = 'configuration-options/#output-manualchunks';
2074
+ const URL_OUTPUT_NAME = 'configuration-options/#output-name';
2075
+ const URL_OUTPUT_PRESERVEMODULES = 'configuration-options/#output-preservemodules';
2076
+ const URL_OUTPUT_SOURCEMAPBASEURL = 'configuration-options/#output-sourcemapbaseurl';
2077
+ const URL_OUTPUT_SOURCEMAPFILE = 'configuration-options/#output-sourcemapfile';
2078
+ const URL_PRESERVEENTRYSIGNATURES = 'configuration-options/#preserveentrysignatures';
2079
+ const URL_TREESHAKE = 'configuration-options/#treeshake';
2080
+ const URL_TREESHAKE_MODULESIDEEFFECTS = 'configuration-options/#treeshake-modulesideeffects';
2081
+ const URL_WATCH = 'configuration-options/#watch';
2082
+ const URL_RENDERDYNAMICIMPORT = 'plugin-development/#renderdynamicimport';
2083
+ const URL_THIS_GETMODULEIDS = 'plugin-development/#this-getmoduleids';
2084
+ const URL_THIS_GETMODULEINFO = 'plugin-development/#this-getmoduleinfo';
2085
+
2039
2086
  function error(base) {
2040
2087
  if (!(base instanceof Error)) {
2041
2088
  base = Object.assign(new Error(base.message), base);
@@ -2168,10 +2215,12 @@ function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importe
2168
2215
  reexporter
2169
2216
  };
2170
2217
  }
2171
- function errorDeprecation(deprecation) {
2218
+ function errorDeprecation(deprecation, urlSnippet, plugin) {
2172
2219
  return {
2173
2220
  code: DEPRECATED_FEATURE,
2174
- ...(typeof deprecation === 'string' ? { message: deprecation } : deprecation)
2221
+ message: deprecation,
2222
+ url: getRollupUrl(urlSnippet),
2223
+ ...(plugin ? { plugin } : {})
2175
2224
  };
2176
2225
  }
2177
2226
  function errorDuplicatePluginName(plugin) {
@@ -2192,7 +2241,7 @@ function errorEval(id) {
2192
2241
  code: EVAL,
2193
2242
  id,
2194
2243
  message: `Use of eval in "${relativeId(id)}" is strongly discouraged as it poses security risks and may cause issues with minification.`,
2195
- url: 'https://rollupjs.org/guide/en/#avoiding-eval'
2244
+ url: getRollupUrl(URL_AVOIDING_EVAL)
2196
2245
  };
2197
2246
  }
2198
2247
  function errorExternalSyntheticExports(id, importer) {
@@ -2218,7 +2267,7 @@ function errorIllegalIdentifierAsName(name) {
2218
2267
  return {
2219
2268
  code: ILLEGAL_IDENTIFIER_AS_NAME,
2220
2269
  message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`,
2221
- url: 'https://rollupjs.org/guide/en/#outputextend'
2270
+ url: getRollupUrl(URL_OUTPUT_EXTEND)
2222
2271
  };
2223
2272
  }
2224
2273
  function errorIllegalImportReassignment(name, importingId) {
@@ -2255,14 +2304,14 @@ function errorInvalidExportOptionValue(optionValue) {
2255
2304
  return {
2256
2305
  code: INVALID_EXPORT_OPTION,
2257
2306
  message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`,
2258
- url: `https://rollupjs.org/guide/en/#outputexports`
2307
+ url: getRollupUrl(URL_OUTPUT_EXPORTS)
2259
2308
  };
2260
2309
  }
2261
2310
  function errorIncompatibleExportOptionValue(optionValue, keys, entryModule) {
2262
2311
  return {
2263
2312
  code: INVALID_EXPORT_OPTION,
2264
2313
  message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${printQuotedStringList(keys)}`,
2265
- url: 'https://rollupjs.org/guide/en/#outputexports'
2314
+ url: getRollupUrl(URL_OUTPUT_EXPORTS)
2266
2315
  };
2267
2316
  }
2268
2317
  function errorInternalIdCannotBeExternal(source, importer) {
@@ -2271,11 +2320,11 @@ function errorInternalIdCannotBeExternal(source, importer) {
2271
2320
  message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
2272
2321
  };
2273
2322
  }
2274
- function errorInvalidOption(option, urlHash, explanation, value) {
2323
+ function errorInvalidOption(option, urlSnippet, explanation, value) {
2275
2324
  return {
2276
2325
  code: INVALID_OPTION,
2277
2326
  message: `Invalid value ${value === undefined ? '' : `${JSON.stringify(value)} `}for option "${option}" - ${explanation}.`,
2278
- url: `https://rollupjs.org/guide/en/#${urlHash}`
2327
+ url: getRollupUrl(urlSnippet)
2279
2328
  };
2280
2329
  }
2281
2330
  function errorInvalidAddonPluginHook(hook, plugin) {
@@ -2327,7 +2376,7 @@ function errorMissingExport(binding, importingModule, exporter) {
2327
2376
  exporter,
2328
2377
  id: importingModule,
2329
2378
  message: `"${binding}" is not exported by "${relativeId(exporter)}", imported by "${relativeId(importingModule)}".${isJson ? ' (Note that you need @rollup/plugin-json to import JSON files)' : ''}`,
2330
- url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
2379
+ url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED)
2331
2380
  };
2332
2381
  }
2333
2382
  function errorMissingGlobalName(externalId, guess) {
@@ -2336,7 +2385,7 @@ function errorMissingGlobalName(externalId, guess) {
2336
2385
  id: externalId,
2337
2386
  message: `No name was provided for external module "${externalId}" in "output.globals" – guessing "${guess}".`,
2338
2387
  names: [guess],
2339
- url: 'https://rollupjs.org/guide/en/#outputglobals'
2388
+ url: getRollupUrl(URL_OUTPUT_GLOBALS)
2340
2389
  };
2341
2390
  }
2342
2391
  function errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
@@ -2364,14 +2413,14 @@ function errorMissingNameOptionForIifeExport() {
2364
2413
  return {
2365
2414
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
2366
2415
  message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`,
2367
- url: 'https://rollupjs.org/guide/en/#outputname'
2416
+ url: getRollupUrl(URL_OUTPUT_NAME)
2368
2417
  };
2369
2418
  }
2370
2419
  function errorMissingNameOptionForUmdExport() {
2371
2420
  return {
2372
2421
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
2373
2422
  message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.',
2374
- url: 'https://rollupjs.org/guide/en/#outputname'
2423
+ url: getRollupUrl(URL_OUTPUT_NAME)
2375
2424
  };
2376
2425
  }
2377
2426
  function errorMissingNodeBuiltins(externalBuiltins) {
@@ -2386,7 +2435,7 @@ function errorMissingFileOrDirOption() {
2386
2435
  return {
2387
2436
  code: MISSING_OPTION,
2388
2437
  message: 'You must specify "output.file" or "output.dir" for the build.',
2389
- url: 'https://rollupjs.org/guide/en/#outputdir'
2438
+ url: getRollupUrl(URL_OUTPUT_DIR)
2390
2439
  };
2391
2440
  }
2392
2441
  function errorMixedExport(facadeModuleId, name) {
@@ -2394,7 +2443,7 @@ function errorMixedExport(facadeModuleId, name) {
2394
2443
  code: MIXED_EXPORTS,
2395
2444
  id: facadeModuleId,
2396
2445
  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.`,
2397
- url: `https://rollupjs.org/guide/en/#outputexports`
2446
+ url: getRollupUrl(URL_OUTPUT_EXPORTS)
2398
2447
  };
2399
2448
  }
2400
2449
  function errorModuleLevelDirective(directive, id) {
@@ -2464,7 +2513,13 @@ function errorSourcemapBroken(plugin) {
2464
2513
  code: SOURCEMAP_BROKEN,
2465
2514
  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`,
2466
2515
  plugin,
2467
- url: `https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect`
2516
+ url: getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT)
2517
+ };
2518
+ }
2519
+ function errorConflictingSourcemapSources(filename) {
2520
+ return {
2521
+ code: SOURCEMAP_BROKEN,
2522
+ message: `Multiple conflicting contents for sourcemap source ${filename}`
2468
2523
  };
2469
2524
  }
2470
2525
  function errorInvalidSourcemapForError(error, id, column, line, pos) {
@@ -2494,7 +2549,7 @@ function errorThisIsUndefined() {
2494
2549
  return {
2495
2550
  code: THIS_IS_UNDEFINED,
2496
2551
  message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
2497
- url: `https://rollupjs.org/guide/en/#error-this-is-undefined`
2552
+ url: getRollupUrl(URL_THIS_IS_UNDEFINED)
2498
2553
  };
2499
2554
  }
2500
2555
  function errorUnexpectedNamedImport(id, imported, isReexport) {
@@ -2503,7 +2558,7 @@ function errorUnexpectedNamedImport(id, imported, isReexport) {
2503
2558
  code: UNEXPECTED_NAMED_IMPORT,
2504
2559
  exporter: id,
2505
2560
  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.`,
2506
- url: 'https://rollupjs.org/guide/en/#outputinterop'
2561
+ url: getRollupUrl(URL_OUTPUT_INTEROP)
2507
2562
  };
2508
2563
  }
2509
2564
  function errorUnexpectedNamespaceReexport(id) {
@@ -2511,7 +2566,7 @@ function errorUnexpectedNamespaceReexport(id) {
2511
2566
  code: UNEXPECTED_NAMED_IMPORT,
2512
2567
  exporter: id,
2513
2568
  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.`,
2514
- url: 'https://rollupjs.org/guide/en/#outputinterop'
2569
+ url: getRollupUrl(URL_OUTPUT_INTEROP)
2515
2570
  };
2516
2571
  }
2517
2572
  function errorUnknownOption(optionType, unknownOptions, validOptions) {
@@ -2546,7 +2601,7 @@ function errorUnresolvedImportTreatedAsExternal(source, importer) {
2546
2601
  exporter: source,
2547
2602
  id: importer,
2548
2603
  message: `"${source}" is imported by "${relativeId(importer)}", but could not be resolved – treating it as an external dependency.`,
2549
- url: 'https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency'
2604
+ url: getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY)
2550
2605
  };
2551
2606
  }
2552
2607
  function errorUnusedExternalImports(externalId, names, importers) {
@@ -2567,12 +2622,12 @@ function errorFailedValidation(message) {
2567
2622
  message
2568
2623
  };
2569
2624
  }
2570
- function warnDeprecation(deprecation, activeDeprecation, options) {
2571
- warnDeprecationWithOptions(deprecation, activeDeprecation, options.onwarn, options.strictDeprecations);
2625
+ function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
2626
+ warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onwarn, options.strictDeprecations, plugin);
2572
2627
  }
2573
- function warnDeprecationWithOptions(deprecation, activeDeprecation, warn, strictDeprecations) {
2628
+ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, warn, strictDeprecations, plugin) {
2574
2629
  if (activeDeprecation || strictDeprecations) {
2575
- const warning = errorDeprecation(deprecation);
2630
+ const warning = errorDeprecation(deprecation, urlSnippet, plugin);
2576
2631
  if (strictDeprecations) {
2577
2632
  return error(warning);
2578
2633
  }
@@ -2680,7 +2735,7 @@ class ExternalModule {
2680
2735
  exports: null,
2681
2736
  hasDefaultExport: null,
2682
2737
  get hasModuleSideEffects() {
2683
- warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
2738
+ warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', URL_THIS_GETMODULEINFO, true, options);
2684
2739
  return info.moduleSideEffects;
2685
2740
  },
2686
2741
  id,
@@ -13006,7 +13061,7 @@ class Module {
13006
13061
  return module.exports.has('default') || reexportDescriptions.has('default');
13007
13062
  },
13008
13063
  get hasModuleSideEffects() {
13009
- warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', true, options);
13064
+ warnDeprecation('Accessing ModuleInfo.hasModuleSideEffects from plugins is deprecated. Please use ModuleInfo.moduleSideEffects instead.', URL_THIS_GETMODULEINFO, true, options);
13010
13065
  return this.moduleSideEffects;
13011
13066
  },
13012
13067
  id,
@@ -13771,7 +13826,7 @@ function getCompleteAmdId(options, chunkId) {
13771
13826
  }
13772
13827
 
13773
13828
  function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snippets, t, externalLiveBindings, mechanism = 'return ') {
13774
- const { _, cnst, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets;
13829
+ const { _, getDirectReturnFunction, getFunctionIntro, getPropertyAccess, n, s } = snippets;
13775
13830
  if (!namedExportsMode) {
13776
13831
  return `${n}${n}${mechanism}${getSingleDefaultExport(exports, dependencies, interop, externalLiveBindings, getPropertyAccess)};`;
13777
13832
  }
@@ -13817,13 +13872,10 @@ function getExportBlock$1(exports, dependencies, namedExportsMode, interop, snip
13817
13872
  if (exportBlock)
13818
13873
  exportBlock += n;
13819
13874
  const copyPropertyIfNecessary = `{${n}${t}if${_}(k${_}!==${_}'default'${_}&&${_}!exports.hasOwnProperty(k))${_}${getDefineProperty(name, specifier.needsLiveBinding, t, snippets)}${s}${n}}`;
13820
- exportBlock +=
13821
- cnst === 'var' && specifier.needsLiveBinding
13822
- ? `Object.keys(${name}).forEach(${getFunctionIntro(['k'], {
13823
- isAsync: false,
13824
- name: null
13825
- })}${copyPropertyIfNecessary});`
13826
- : `for${_}(${cnst} k in ${name})${_}${copyPropertyIfNecessary}`;
13875
+ exportBlock += `Object.keys(${name}).forEach(${getFunctionIntro(['k'], {
13876
+ isAsync: false,
13877
+ name: null
13878
+ })}${copyPropertyIfNecessary});`;
13827
13879
  }
13828
13880
  }
13829
13881
  }
@@ -14913,6 +14965,23 @@ const getOutputBundle = (outputBundleBase) => {
14913
14965
  }
14914
14966
  });
14915
14967
  };
14968
+ const removeUnreferencedAssets = (outputBundle) => {
14969
+ const unreferencedAssets = new Set();
14970
+ const bundleEntries = Object.values(outputBundle);
14971
+ for (const asset of bundleEntries) {
14972
+ asset.type === 'asset' && asset.needsCodeReference && unreferencedAssets.add(asset.fileName);
14973
+ }
14974
+ for (const chunk of bundleEntries) {
14975
+ if (chunk.type === 'chunk') {
14976
+ for (const referencedFile of chunk.referencedFiles) {
14977
+ unreferencedAssets.has(referencedFile) && unreferencedAssets.delete(referencedFile);
14978
+ }
14979
+ }
14980
+ }
14981
+ for (const file of unreferencedAssets) {
14982
+ delete outputBundle[file];
14983
+ }
14984
+ };
14916
14985
 
14917
14986
  function renderNamePattern(pattern, patternName, replacements) {
14918
14987
  if (isPathFragment(pattern))
@@ -16397,9 +16466,7 @@ class Link {
16397
16466
  sourcesContent[sourceIndex] = content;
16398
16467
  }
16399
16468
  else if (content != null && sourcesContent[sourceIndex] !== content) {
16400
- return error({
16401
- message: `Multiple conflicting contents for sourcemap source ${filename}`
16402
- });
16469
+ return error(errorConflictingSourcemapSources(filename));
16403
16470
  }
16404
16471
  const tracedSegment = [segment[0], sourceIndex, line, column];
16405
16472
  if (name) {
@@ -16743,6 +16810,7 @@ class Bundle {
16743
16810
  await this.pluginDriver.hookParallel('renderError', [error_]);
16744
16811
  throw error_;
16745
16812
  }
16813
+ removeUnreferencedAssets(outputBundle);
16746
16814
  timeStart('generate bundle', 2);
16747
16815
  await this.pluginDriver.hookSeq('generateBundle', [
16748
16816
  this.outputOptions,
@@ -16838,13 +16906,13 @@ class Bundle {
16838
16906
  }
16839
16907
  function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
16840
16908
  if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
16841
- return error(errorInvalidOption('output.format', 'outputformat', 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
16909
+ return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
16842
16910
  if (typeof outputOptions.file === 'string')
16843
- return error(errorInvalidOption('output.file', 'outputdir', 'when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option'));
16911
+ return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'when building multiple chunks, the "output.dir" option must be used, not "output.file". To inline dynamic imports, set the "inlineDynamicImports" option'));
16844
16912
  if (outputOptions.sourcemapFile)
16845
- return error(errorInvalidOption('output.sourcemapFile', 'outputsourcemapfile', '"output.sourcemapFile" is only supported for single-file builds'));
16913
+ return error(errorInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
16846
16914
  if (!outputOptions.amd.autoId && outputOptions.amd.id)
16847
- onWarn(errorInvalidOption('output.amd.id', 'outputamd', 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
16915
+ onWarn(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option is only properly supported for single-file builds. Use "output.amd.autoId" and "output.amd.basePath" instead'));
16848
16916
  }
16849
16917
  function getIncludedModules(modulesById) {
16850
16918
  const includedModules = [];
@@ -23398,6 +23466,7 @@ class FileEmitter {
23398
23466
  const consumedAsset = {
23399
23467
  fileName: emittedAsset.fileName,
23400
23468
  name: emittedAsset.name,
23469
+ needsCodeReference: !!emittedAsset.needsCodeReference,
23401
23470
  source,
23402
23471
  type: 'asset'
23403
23472
  };
@@ -23460,6 +23529,7 @@ class FileEmitter {
23460
23529
  bundle[fileName] = {
23461
23530
  fileName,
23462
23531
  name: consumedFile.name,
23532
+ needsCodeReference: consumedFile.needsCodeReference,
23463
23533
  source,
23464
23534
  type: 'asset'
23465
23535
  };
@@ -23515,10 +23585,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
23515
23585
  get moduleIds() {
23516
23586
  function* wrappedModuleIds() {
23517
23587
  // We are wrapping this in a generator to only show the message once we are actually iterating
23518
- warnDeprecation({
23519
- message: `Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`,
23520
- plugin: plugin.name
23521
- }, true, options);
23588
+ warnDeprecation(`Accessing "this.moduleIds" on the plugin context by plugin ${plugin.name} is deprecated. The "this.getModuleIds" plugin context function should be used instead.`, URL_THIS_GETMODULEIDS, true, options, plugin.name);
23522
23589
  yield* moduleIds;
23523
23590
  }
23524
23591
  const moduleIds = graph.modulesById.keys();
@@ -24380,17 +24447,17 @@ const generatedCodePresets = {
24380
24447
  }
24381
24448
  };
24382
24449
  const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
24383
- const objectifyOptionWithPresets = (presets, optionName, additionalValues) => (value) => {
24450
+ const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
24384
24451
  if (typeof value === 'string') {
24385
24452
  const preset = presets[value];
24386
24453
  if (preset) {
24387
24454
  return preset;
24388
24455
  }
24389
- error(errorInvalidOption(optionName, getHashFromObjectOption(optionName), `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
24456
+ error(errorInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
24390
24457
  }
24391
24458
  return objectifyOption(value);
24392
24459
  };
24393
- const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
24460
+ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
24394
24461
  const presetName = value?.preset;
24395
24462
  if (presetName) {
24396
24463
  const preset = presets[presetName];
@@ -24398,12 +24465,11 @@ const getOptionWithPreset = (value, presets, optionName, additionalValues) => {
24398
24465
  return { ...preset, ...value };
24399
24466
  }
24400
24467
  else {
24401
- error(errorInvalidOption(`${optionName}.preset`, getHashFromObjectOption(optionName), `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
24468
+ error(errorInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
24402
24469
  }
24403
24470
  }
24404
- return objectifyOptionWithPresets(presets, optionName, additionalValues)(value);
24471
+ return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
24405
24472
  };
24406
- const getHashFromObjectOption = (optionName) => optionName.split('.').join('').toLowerCase();
24407
24473
  const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
24408
24474
 
24409
24475
  async function normalizeInputOptions(config) {
@@ -24493,7 +24559,7 @@ const getIdMatcher = (option) => {
24493
24559
  const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
24494
24560
  const configInlineDynamicImports = config.inlineDynamicImports;
24495
24561
  if (configInlineDynamicImports) {
24496
- warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', true, warn, strictDeprecations);
24562
+ warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, warn, strictDeprecations);
24497
24563
  }
24498
24564
  return configInlineDynamicImports;
24499
24565
  };
@@ -24504,14 +24570,14 @@ const getInput = (config) => {
24504
24570
  const getManualChunks$1 = (config, warn, strictDeprecations) => {
24505
24571
  const configManualChunks = config.manualChunks;
24506
24572
  if (configManualChunks) {
24507
- warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', true, warn, strictDeprecations);
24573
+ warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, warn, strictDeprecations);
24508
24574
  }
24509
24575
  return configManualChunks;
24510
24576
  };
24511
24577
  const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
24512
24578
  const maxParallelFileReads = config.maxParallelFileReads;
24513
24579
  if (typeof maxParallelFileReads === 'number') {
24514
- warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', true, warn, strictDeprecations);
24580
+ warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, warn, strictDeprecations);
24515
24581
  }
24516
24582
  const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
24517
24583
  if (typeof maxParallelFileOps === 'number') {
@@ -24538,7 +24604,7 @@ const getModuleContext = (config, context) => {
24538
24604
  const getPreserveModules$1 = (config, warn, strictDeprecations) => {
24539
24605
  const configPreserveModules = config.preserveModules;
24540
24606
  if (configPreserveModules) {
24541
- warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', true, warn, strictDeprecations);
24607
+ warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, warn, strictDeprecations);
24542
24608
  }
24543
24609
  return configPreserveModules;
24544
24610
  };
@@ -24547,7 +24613,7 @@ const getTreeshake = (config) => {
24547
24613
  if (configTreeshake === false) {
24548
24614
  return false;
24549
24615
  }
24550
- const configWithPreset = getOptionWithPreset(config.treeshake, treeshakePresets, 'treeshake', 'false, true, ');
24616
+ const configWithPreset = getOptionWithPreset(config.treeshake, treeshakePresets, 'treeshake', URL_TREESHAKE, 'false, true, ');
24551
24617
  return {
24552
24618
  annotations: configWithPreset.annotations !== false,
24553
24619
  correctVarValueBeforeDeclaration: configWithPreset.correctVarValueBeforeDeclaration === true,
@@ -24575,7 +24641,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption) => {
24575
24641
  return id => ids.has(id);
24576
24642
  }
24577
24643
  if (moduleSideEffectsOption) {
24578
- error(errorInvalidOption('treeshake.moduleSideEffects', 'treeshake', 'please use one of false, "no-external", a function or an array'));
24644
+ error(errorInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
24579
24645
  }
24580
24646
  return () => true;
24581
24647
  };
@@ -24592,16 +24658,6 @@ function sanitizeFileName(name) {
24592
24658
  return driveLetter + name.slice(driveLetter.length).replace(INVALID_CHAR_REGEX, '_');
24593
24659
  }
24594
24660
 
24595
- function isValidUrl(url) {
24596
- try {
24597
- new URL(url);
24598
- }
24599
- catch {
24600
- return false;
24601
- }
24602
- return true;
24603
- }
24604
-
24605
24661
  async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
24606
24662
  // These are options that may trigger special warnings or behaviour later
24607
24663
  // if the user did not select an explicit value
@@ -24672,10 +24728,10 @@ const getFile = (config, preserveModules, inputOptions) => {
24672
24728
  const { file } = config;
24673
24729
  if (typeof file === 'string') {
24674
24730
  if (preserveModules) {
24675
- return error(errorInvalidOption('output.file', 'outputdir', 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
24731
+ return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
24676
24732
  }
24677
24733
  if (!Array.isArray(inputOptions.input))
24678
- return error(errorInvalidOption('output.file', 'outputdir', 'you must set "output.dir" instead of "output.file" when providing named inputs'));
24734
+ return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
24679
24735
  }
24680
24736
  return file;
24681
24737
  };
@@ -24702,10 +24758,7 @@ const getFormat = (config) => {
24702
24758
  return configFormat;
24703
24759
  }
24704
24760
  default: {
24705
- return error({
24706
- message: `You must specify "output.format", which can be one of "amd", "cjs", "system", "es", "iife" or "umd".`,
24707
- url: `https://rollupjs.org/guide/en/#outputformat`
24708
- });
24761
+ return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
24709
24762
  }
24710
24763
  }
24711
24764
  };
@@ -24713,7 +24766,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
24713
24766
  const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
24714
24767
  const { input } = inputOptions;
24715
24768
  if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
24716
- return error(errorInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
24769
+ return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
24717
24770
  }
24718
24771
  return inlineDynamicImports;
24719
24772
  };
@@ -24721,10 +24774,10 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
24721
24774
  const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
24722
24775
  if (preserveModules) {
24723
24776
  if (inlineDynamicImports) {
24724
- return error(errorInvalidOption('output.inlineDynamicImports', 'outputinlinedynamicimports', `this option is not supported for "output.preserveModules"`));
24777
+ return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
24725
24778
  }
24726
24779
  if (inputOptions.preserveEntrySignatures === false) {
24727
- return error(errorInvalidOption('preserveEntrySignatures', 'preserveentrysignatures', 'setting this option to false is not supported for "output.preserveModules"'));
24780
+ return error(errorInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
24728
24781
  }
24729
24782
  }
24730
24783
  return preserveModules;
@@ -24732,7 +24785,7 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
24732
24785
  const getPreferConst = (config, inputOptions) => {
24733
24786
  const configPreferConst = config.preferConst;
24734
24787
  if (configPreferConst != null) {
24735
- warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`, true, inputOptions);
24788
+ warnDeprecation(`The "output.preferConst" option is deprecated. Use the "output.generatedCode.constBindings" option instead.`, URL_OUTPUT_GENERATEDCODE_CONSTBINDINGS, true, inputOptions);
24736
24789
  }
24737
24790
  return !!configPreferConst;
24738
24791
  };
@@ -24752,10 +24805,10 @@ const getAmd = (config) => {
24752
24805
  ...config.amd
24753
24806
  };
24754
24807
  if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
24755
- return error(errorInvalidOption('output.amd.id', 'outputamd', 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
24808
+ return error(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
24756
24809
  }
24757
24810
  if (mergedOption.basePath && !mergedOption.autoId) {
24758
- return error(errorInvalidOption('output.amd.basePath', 'outputamd', 'this option only works with "output.amd.autoId"'));
24811
+ return error(errorInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
24759
24812
  }
24760
24813
  return mergedOption.autoId
24761
24814
  ? {
@@ -24782,16 +24835,16 @@ const getAddon = (config, name) => {
24782
24835
  const getDir = (config, file) => {
24783
24836
  const { dir } = config;
24784
24837
  if (typeof dir === 'string' && typeof file === 'string') {
24785
- return error(errorInvalidOption('output.dir', 'outputdir', 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks'));
24838
+ return error(errorInvalidOption('output.dir', URL_OUTPUT_DIR, 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks'));
24786
24839
  }
24787
24840
  return dir;
24788
24841
  };
24789
24842
  const getDynamicImportFunction = (config, inputOptions, format) => {
24790
24843
  const configDynamicImportFunction = config.dynamicImportFunction;
24791
24844
  if (configDynamicImportFunction) {
24792
- warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, true, inputOptions);
24845
+ warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, URL_RENDERDYNAMICIMPORT, true, inputOptions);
24793
24846
  if (format !== 'es') {
24794
- inputOptions.onwarn(errorInvalidOption('output.dynamicImportFunction', 'outputdynamicImportFunction', 'this option is ignored for formats other than "es"'));
24847
+ inputOptions.onwarn(errorInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
24795
24848
  }
24796
24849
  }
24797
24850
  return configDynamicImportFunction;
@@ -24814,7 +24867,7 @@ function getExports(config, unsetOptions) {
24814
24867
  return configExports || 'auto';
24815
24868
  }
24816
24869
  const getGeneratedCode = (config, preferConst) => {
24817
- const configWithPreset = getOptionWithPreset(config.generatedCode, generatedCodePresets, 'output.generatedCode', '');
24870
+ const configWithPreset = getOptionWithPreset(config.generatedCode, generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '');
24818
24871
  return {
24819
24872
  arrowFunctions: configWithPreset.arrowFunctions === true,
24820
24873
  constBindings: configWithPreset.constBindings === true || preferConst,
@@ -24852,7 +24905,7 @@ const getInterop = (config) => {
24852
24905
  };
24853
24906
  const validateInterop = (interop) => {
24854
24907
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
24855
- return error(errorInvalidOption('output.interop', 'outputinterop',
24908
+ return error(errorInvalidOption('output.interop', URL_OUTPUT_INTEROP,
24856
24909
  // eslint-disable-next-line unicorn/prefer-spread
24857
24910
  `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
24858
24911
  }
@@ -24862,10 +24915,10 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
24862
24915
  const configManualChunks = config.manualChunks || inputOptions.manualChunks;
24863
24916
  if (configManualChunks) {
24864
24917
  if (inlineDynamicImports) {
24865
- return error(errorInvalidOption('output.manualChunks', 'outputmanualchunks', 'this option is not supported for "output.inlineDynamicImports"'));
24918
+ return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
24866
24919
  }
24867
24920
  if (preserveModules) {
24868
- return error(errorInvalidOption('output.manualChunks', 'outputmanualchunks', 'this option is not supported for "output.preserveModules"'));
24921
+ return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
24869
24922
  }
24870
24923
  }
24871
24924
  return configManualChunks || {};
@@ -24874,7 +24927,7 @@ const getMinifyInternalExports = (config, format, compact) => config.minifyInter
24874
24927
  const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
24875
24928
  const configNamespaceToStringTag = config.namespaceToStringTag;
24876
24929
  if (configNamespaceToStringTag != null) {
24877
- warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, true, inputOptions);
24930
+ warnDeprecation(`The "output.namespaceToStringTag" option is deprecated. Use the "output.generatedCode.symbols" option instead.`, URL_OUTPUT_GENERATEDCODE_SYMBOLS, true, inputOptions);
24878
24931
  return configNamespaceToStringTag;
24879
24932
  }
24880
24933
  return generatedCode.symbols || false;
@@ -24885,7 +24938,7 @@ const getSourcemapBaseUrl = (config) => {
24885
24938
  if (isValidUrl(sourcemapBaseUrl)) {
24886
24939
  return sourcemapBaseUrl;
24887
24940
  }
24888
- return error(errorInvalidOption('output.sourcemapBaseUrl', 'outputsourcemapbaseurl', `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
24941
+ return error(errorInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
24889
24942
  }
24890
24943
  };
24891
24944
 
@@ -25274,7 +25327,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
25274
25327
  preserveSymlinks: getOption('preserveSymlinks'),
25275
25328
  shimMissingExports: getOption('shimMissingExports'),
25276
25329
  strictDeprecations: getOption('strictDeprecations'),
25277
- treeshake: getObjectOption(config, overrides, 'treeshake', objectifyOptionWithPresets(treeshakePresets, 'treeshake', 'false, true, ')),
25330
+ treeshake: getObjectOption(config, overrides, 'treeshake', objectifyOptionWithPresets(treeshakePresets, 'treeshake', URL_TREESHAKE, 'false, true, ')),
25278
25331
  watch: getWatch(config, overrides)
25279
25332
  };
25280
25333
  warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
@@ -25327,7 +25380,7 @@ async function mergeOutputOptions(config, overrides, warn) {
25327
25380
  footer: getOption('footer'),
25328
25381
  format: getOption('format'),
25329
25382
  freeze: getOption('freeze'),
25330
- generatedCode: getObjectOption(config, overrides, 'generatedCode', objectifyOptionWithPresets(generatedCodePresets, 'output.generatedCode', '')),
25383
+ generatedCode: getObjectOption(config, overrides, 'generatedCode', objectifyOptionWithPresets(generatedCodePresets, 'output.generatedCode', URL_OUTPUT_GENERATEDCODE, '')),
25331
25384
  globals: getOption('globals'),
25332
25385
  hoistTransitiveImports: getOption('hoistTransitiveImports'),
25333
25386
  indent: getOption('indent'),
@@ -25446,7 +25499,7 @@ async function watchInternal(configs, emitter) {
25446
25499
  const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config)));
25447
25500
  const watchOptionsList = optionsList.filter(config => config.watch !== false);
25448
25501
  if (watchOptionsList.length === 0) {
25449
- return error(errorInvalidOption('watch', 'watch', 'there must be at least one config where "watch" is not set to "false"'));
25502
+ return error(errorInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
25450
25503
  }
25451
25504
  await loadFsEvents();
25452
25505
  const { Watcher } = await import('./watch.js');