rollup 3.24.0 → 3.25.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.24.0
4
- Wed, 07 Jun 2023 04:46:58 GMT - commit bcd64961f92535d2d6d0b663d1e17a500374358b
3
+ Rollup.js v3.25.0
4
+ Sun, 11 Jun 2023 05:02:46 GMT - commit 23c111c87145d15b0de032a6c7eeb6596764d1cf
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -15,7 +15,7 @@ import { createHash as createHash$1 } from 'node:crypto';
15
15
  import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
16
16
  import * as tty from 'tty';
17
17
 
18
- var version$1 = "3.24.0";
18
+ var version$1 = "3.25.0";
19
19
 
20
20
  const comma = ','.charCodeAt(0);
21
21
  const semicolon = ';'.charCodeAt(0);
@@ -1971,6 +1971,89 @@ const EMPTY_SET = Object.freeze(new (class extends Set {
1971
1971
  }
1972
1972
  })());
1973
1973
 
1974
+ const RESERVED_NAMES = new Set([
1975
+ 'await',
1976
+ 'break',
1977
+ 'case',
1978
+ 'catch',
1979
+ 'class',
1980
+ 'const',
1981
+ 'continue',
1982
+ 'debugger',
1983
+ 'default',
1984
+ 'delete',
1985
+ 'do',
1986
+ 'else',
1987
+ 'enum',
1988
+ 'eval',
1989
+ 'export',
1990
+ 'extends',
1991
+ 'false',
1992
+ 'finally',
1993
+ 'for',
1994
+ 'function',
1995
+ 'if',
1996
+ 'implements',
1997
+ 'import',
1998
+ 'in',
1999
+ 'instanceof',
2000
+ 'interface',
2001
+ 'let',
2002
+ 'NaN',
2003
+ 'new',
2004
+ 'null',
2005
+ 'package',
2006
+ 'private',
2007
+ 'protected',
2008
+ 'public',
2009
+ 'return',
2010
+ 'static',
2011
+ 'super',
2012
+ 'switch',
2013
+ 'this',
2014
+ 'throw',
2015
+ 'true',
2016
+ 'try',
2017
+ 'typeof',
2018
+ 'undefined',
2019
+ 'var',
2020
+ 'void',
2021
+ 'while',
2022
+ 'with',
2023
+ 'yield'
2024
+ ]);
2025
+ const RESERVED_NAMES$1 = RESERVED_NAMES;
2026
+
2027
+ const illegalCharacters = /[^\w$]/g;
2028
+ const startsWithDigit = (value) => /\d/.test(value[0]);
2029
+ const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES$1.has(value) || value === 'arguments';
2030
+ function isLegal(value) {
2031
+ if (needsEscape(value)) {
2032
+ return false;
2033
+ }
2034
+ return !illegalCharacters.test(value);
2035
+ }
2036
+ function makeLegal(value) {
2037
+ value = value
2038
+ .replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
2039
+ .replace(illegalCharacters, '_');
2040
+ if (needsEscape(value))
2041
+ value = `_${value}`;
2042
+ return value || '_';
2043
+ }
2044
+
2045
+ const LOGLEVEL_SILENT = 'silent';
2046
+ const LOGLEVEL_ERROR = 'error';
2047
+ const LOGLEVEL_WARN = 'warn';
2048
+ const LOGLEVEL_INFO = 'info';
2049
+ const LOGLEVEL_DEBUG = 'debug';
2050
+ const logLevelPriority = {
2051
+ [LOGLEVEL_DEBUG]: 0,
2052
+ [LOGLEVEL_INFO]: 1,
2053
+ [LOGLEVEL_SILENT]: 3,
2054
+ [LOGLEVEL_WARN]: 2
2055
+ };
2056
+
1974
2057
  function getLocator(source, options) {
1975
2058
  if (options === void 0) { options = {}; }
1976
2059
  var offsetLine = options.offsetLine || 0;
@@ -2149,21 +2232,21 @@ function augmentCodeLocation(properties, pos, source, id) {
2149
2232
  }
2150
2233
  // Error codes should be sorted alphabetically while errors should be sorted by
2151
2234
  // error code below
2152
- 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_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', 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_EXPORT = 'MISSING_EXPORT', 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', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', 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', 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';
2153
- function errorAddonNotGenerated(message, hook, plugin) {
2235
+ 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_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INCONSISTENT_IMPORT_ASSERTIONS = 'INCONSISTENT_IMPORT_ASSERTIONS', 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_LOG_POSITION = 'INVALID_LOG_POSITION', 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_EXPORT = 'MISSING_EXPORT', 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', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', 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', 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';
2236
+ function logAddonNotGenerated(message, hook, plugin) {
2154
2237
  return {
2155
2238
  code: ADDON_ERROR,
2156
2239
  message: `Could not retrieve "${hook}". Check configuration of plugin "${plugin}".
2157
2240
  \tError Message: ${message}`
2158
2241
  };
2159
2242
  }
2160
- function errorAlreadyClosed() {
2243
+ function logAlreadyClosed() {
2161
2244
  return {
2162
2245
  code: ALREADY_CLOSED,
2163
2246
  message: 'Bundle is already closed, no more calls to "generate" or "write" are allowed.'
2164
2247
  };
2165
2248
  }
2166
- function errorAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
2249
+ function logAmbiguousExternalNamespaces(binding, reexportingModule, usedModule, sources) {
2167
2250
  return {
2168
2251
  binding,
2169
2252
  code: AMBIGUOUS_EXTERNAL_NAMESPACES,
@@ -2172,61 +2255,61 @@ function errorAmbiguousExternalNamespaces(binding, reexportingModule, usedModule
2172
2255
  reexporter: reexportingModule
2173
2256
  };
2174
2257
  }
2175
- function errorAnonymousPluginCache() {
2258
+ function logAnonymousPluginCache() {
2176
2259
  return {
2177
2260
  code: ANONYMOUS_PLUGIN_CACHE,
2178
2261
  message: 'A plugin is trying to use the Rollup cache but is not declaring a plugin name or cacheKey.'
2179
2262
  };
2180
2263
  }
2181
- function errorAssetNotFinalisedForFileName(name) {
2264
+ function logAssetNotFinalisedForFileName(name) {
2182
2265
  return {
2183
2266
  code: ASSET_NOT_FINALISED,
2184
2267
  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.`
2185
2268
  };
2186
2269
  }
2187
- function errorAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
2270
+ function logAssetReferenceIdNotFoundForSetSource(assetReferenceId) {
2188
2271
  return {
2189
2272
  code: ASSET_NOT_FOUND,
2190
2273
  message: `Plugin error - Unable to set the source for unknown asset "${assetReferenceId}".`
2191
2274
  };
2192
2275
  }
2193
- function errorAssetSourceAlreadySet(name) {
2276
+ function logAssetSourceAlreadySet(name) {
2194
2277
  return {
2195
2278
  code: ASSET_SOURCE_ALREADY_SET,
2196
2279
  message: `Unable to set the source for asset "${name}", source already set.`
2197
2280
  };
2198
2281
  }
2199
- function errorNoAssetSourceSet(assetName) {
2282
+ function logNoAssetSourceSet(assetName) {
2200
2283
  return {
2201
2284
  code: ASSET_SOURCE_MISSING,
2202
2285
  message: `Plugin error creating asset "${assetName}" - no asset source set.`
2203
2286
  };
2204
2287
  }
2205
- function errorBadLoader(id) {
2288
+ function logBadLoader(id) {
2206
2289
  return {
2207
2290
  code: BAD_LOADER,
2208
2291
  message: `Error loading "${relativeId(id)}": plugin load hook should return a string, a { code, map } object, or nothing/null.`
2209
2292
  };
2210
2293
  }
2211
- function errorCannotCallNamespace(name) {
2294
+ function logCannotCallNamespace(name) {
2212
2295
  return {
2213
2296
  code: CANNOT_CALL_NAMESPACE,
2214
2297
  message: `Cannot call a namespace ("${name}").`
2215
2298
  };
2216
2299
  }
2217
- function errorCannotEmitFromOptionsHook() {
2300
+ function logCannotEmitFromOptionsHook() {
2218
2301
  return {
2219
2302
  code: CANNOT_EMIT_FROM_OPTIONS_HOOK,
2220
2303
  message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
2221
2304
  };
2222
2305
  }
2223
- function errorChunkNotGeneratedForFileName(name) {
2306
+ function logChunkNotGeneratedForFileName(name) {
2224
2307
  return {
2225
2308
  code: CHUNK_NOT_GENERATED,
2226
2309
  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.`
2227
2310
  };
2228
2311
  }
2229
- function errorChunkInvalid({ fileName, code }, exception) {
2312
+ function logChunkInvalid({ fileName, code }, exception) {
2230
2313
  const errorProperties = {
2231
2314
  code: CHUNK_INVALID,
2232
2315
  message: `Chunk "${fileName}" is not valid JavaScript: ${exception.message}.`
@@ -2234,21 +2317,21 @@ function errorChunkInvalid({ fileName, code }, exception) {
2234
2317
  augmentCodeLocation(errorProperties, exception.loc, code, fileName);
2235
2318
  return errorProperties;
2236
2319
  }
2237
- function errorCircularDependency(cyclePath) {
2320
+ function logCircularDependency(cyclePath) {
2238
2321
  return {
2239
2322
  code: CIRCULAR_DEPENDENCY,
2240
2323
  ids: cyclePath,
2241
2324
  message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
2242
2325
  };
2243
2326
  }
2244
- function errorCircularReexport(exportName, exporter) {
2327
+ function logCircularReexport(exportName, exporter) {
2245
2328
  return {
2246
2329
  code: CIRCULAR_REEXPORT,
2247
2330
  exporter,
2248
2331
  message: `"${exportName}" cannot be exported from "${relativeId(exporter)}" as it is a reexport that references itself.`
2249
2332
  };
2250
2333
  }
2251
- function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
2334
+ function logCyclicCrossChunkReexport(exportName, exporter, reexporter, importer, preserveModules) {
2252
2335
  return {
2253
2336
  code: CYCLIC_CROSS_CHUNK_REEXPORT,
2254
2337
  exporter,
@@ -2257,7 +2340,7 @@ function errorCyclicCrossChunkReexport(exportName, exporter, reexporter, importe
2257
2340
  reexporter
2258
2341
  };
2259
2342
  }
2260
- function errorDeprecation(deprecation, urlSnippet, plugin) {
2343
+ function logDeprecation(deprecation, urlSnippet, plugin) {
2261
2344
  return {
2262
2345
  code: DEPRECATED_FEATURE,
2263
2346
  message: deprecation,
@@ -2265,20 +2348,20 @@ function errorDeprecation(deprecation, urlSnippet, plugin) {
2265
2348
  ...(plugin ? { plugin } : {})
2266
2349
  };
2267
2350
  }
2268
- function errorDuplicatePluginName(plugin) {
2351
+ function logDuplicatePluginName(plugin) {
2269
2352
  return {
2270
2353
  code: DUPLICATE_PLUGIN_NAME,
2271
2354
  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).`
2272
2355
  };
2273
2356
  }
2274
- function errorEmptyChunk(chunkName) {
2357
+ function logEmptyChunk(chunkName) {
2275
2358
  return {
2276
2359
  code: EMPTY_BUNDLE,
2277
2360
  message: `Generated an empty chunk: "${chunkName}".`,
2278
2361
  names: [chunkName]
2279
2362
  };
2280
2363
  }
2281
- function errorEval(id) {
2364
+ function logEval(id) {
2282
2365
  return {
2283
2366
  code: EVAL,
2284
2367
  id,
@@ -2286,39 +2369,45 @@ function errorEval(id) {
2286
2369
  url: getRollupUrl(URL_AVOIDING_EVAL)
2287
2370
  };
2288
2371
  }
2289
- function errorExternalSyntheticExports(id, importer) {
2372
+ function logExternalSyntheticExports(id, importer) {
2290
2373
  return {
2291
2374
  code: EXTERNAL_SYNTHETIC_EXPORTS,
2292
2375
  exporter: id,
2293
2376
  message: `External "${id}" cannot have "syntheticNamedExports" enabled (imported by "${relativeId(importer)}").`
2294
2377
  };
2295
2378
  }
2296
- function errorFileNameConflict(fileName) {
2379
+ function logFileNameConflict(fileName) {
2297
2380
  return {
2298
2381
  code: FILE_NAME_CONFLICT,
2299
2382
  message: `The emitted file "${fileName}" overwrites a previously emitted file of the same name.`
2300
2383
  };
2301
2384
  }
2302
- function errorFileReferenceIdNotFoundForFilename(assetReferenceId) {
2385
+ function logFileReferenceIdNotFoundForFilename(assetReferenceId) {
2303
2386
  return {
2304
2387
  code: FILE_NOT_FOUND,
2305
2388
  message: `Plugin error - Unable to get file name for unknown file "${assetReferenceId}".`
2306
2389
  };
2307
2390
  }
2308
- function errorIllegalIdentifierAsName(name) {
2391
+ function logFirstSideEffect(source, id, { line, column }) {
2392
+ return {
2393
+ code: FIRST_SIDE_EFFECT,
2394
+ message: `First side effect in ${relativeId(id)} is at (${line}:${column})\n${getCodeFrame(source, line, column)}`
2395
+ };
2396
+ }
2397
+ function logIllegalIdentifierAsName(name) {
2309
2398
  return {
2310
2399
  code: ILLEGAL_IDENTIFIER_AS_NAME,
2311
2400
  message: `Given name "${name}" is not a legal JS identifier. If you need this, you can try "output.extend: true".`,
2312
2401
  url: getRollupUrl(URL_OUTPUT_EXTEND)
2313
2402
  };
2314
2403
  }
2315
- function errorIllegalImportReassignment(name, importingId) {
2404
+ function logIllegalImportReassignment(name, importingId) {
2316
2405
  return {
2317
2406
  code: ILLEGAL_REASSIGNMENT,
2318
2407
  message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
2319
2408
  };
2320
2409
  }
2321
- function errorInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
2410
+ function logInconsistentImportAssertions(existingAssertions, newAssertions, source, importer) {
2322
2411
  return {
2323
2412
  code: INCONSISTENT_IMPORT_ASSERTIONS,
2324
2413
  message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAssertions(newAssertions)} assertions, but it was already imported elsewhere with ${formatAssertions(existingAssertions)} assertions. Please ensure that import assertions for the same module are always consistent.`
@@ -2330,46 +2419,52 @@ const formatAssertions = (assertions) => {
2330
2419
  return 'no';
2331
2420
  return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
2332
2421
  };
2333
- function errorInputHookInOutputPlugin(pluginName, hookName) {
2422
+ function logInputHookInOutputPlugin(pluginName, hookName) {
2334
2423
  return {
2335
2424
  code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
2336
2425
  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.`
2337
2426
  };
2338
2427
  }
2339
- function errorCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
2428
+ function logCannotAssignModuleToChunk(moduleId, assignToAlias, currentAlias) {
2340
2429
  return {
2341
2430
  code: INVALID_CHUNK,
2342
2431
  message: `Cannot assign "${relativeId(moduleId)}" to the "${assignToAlias}" chunk as it is already in the "${currentAlias}" chunk.`
2343
2432
  };
2344
2433
  }
2345
- function errorInvalidExportOptionValue(optionValue) {
2434
+ function logInvalidExportOptionValue(optionValue) {
2346
2435
  return {
2347
2436
  code: INVALID_EXPORT_OPTION,
2348
2437
  message: `"output.exports" must be "default", "named", "none", "auto", or left unspecified (defaults to "auto"), received "${optionValue}".`,
2349
2438
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
2350
2439
  };
2351
2440
  }
2352
- function errorIncompatibleExportOptionValue(optionValue, keys, entryModule) {
2441
+ function logIncompatibleExportOptionValue(optionValue, keys, entryModule) {
2353
2442
  return {
2354
2443
  code: INVALID_EXPORT_OPTION,
2355
2444
  message: `"${optionValue}" was specified for "output.exports", but entry module "${relativeId(entryModule)}" has the following exports: ${printQuotedStringList(keys)}`,
2356
2445
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
2357
2446
  };
2358
2447
  }
2359
- function errorInternalIdCannotBeExternal(source, importer) {
2448
+ function logInternalIdCannotBeExternal(source, importer) {
2360
2449
  return {
2361
2450
  code: INVALID_EXTERNAL_ID,
2362
2451
  message: `"${source}" is imported as an external by "${relativeId(importer)}", but is already an existing non-external module id.`
2363
2452
  };
2364
2453
  }
2365
- function errorInvalidOption(option, urlSnippet, explanation, value) {
2454
+ function logInvalidLogPosition(plugin) {
2455
+ return {
2456
+ code: INVALID_LOG_POSITION,
2457
+ message: `Plugin "${plugin}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
2458
+ };
2459
+ }
2460
+ function logInvalidOption(option, urlSnippet, explanation, value) {
2366
2461
  return {
2367
2462
  code: INVALID_OPTION,
2368
2463
  message: `Invalid value ${value === undefined ? '' : `${JSON.stringify(value)} `}for option "${option}" - ${explanation}.`,
2369
2464
  url: getRollupUrl(urlSnippet)
2370
2465
  };
2371
2466
  }
2372
- function errorInvalidAddonPluginHook(hook, plugin) {
2467
+ function logInvalidAddonPluginHook(hook, plugin) {
2373
2468
  return {
2374
2469
  code: INVALID_PLUGIN_HOOK,
2375
2470
  hook,
@@ -2377,7 +2472,7 @@ function errorInvalidAddonPluginHook(hook, plugin) {
2377
2472
  plugin
2378
2473
  };
2379
2474
  }
2380
- function errorInvalidFunctionPluginHook(hook, plugin) {
2475
+ function logInvalidFunctionPluginHook(hook, plugin) {
2381
2476
  return {
2382
2477
  code: INVALID_PLUGIN_HOOK,
2383
2478
  hook,
@@ -2385,32 +2480,32 @@ function errorInvalidFunctionPluginHook(hook, plugin) {
2385
2480
  plugin
2386
2481
  };
2387
2482
  }
2388
- function errorInvalidRollupPhaseForAddWatchFile() {
2483
+ function logInvalidRollupPhaseForAddWatchFile() {
2389
2484
  return {
2390
2485
  code: INVALID_ROLLUP_PHASE,
2391
2486
  message: `Cannot call "addWatchFile" after the build has finished.`
2392
2487
  };
2393
2488
  }
2394
- function errorInvalidRollupPhaseForChunkEmission() {
2489
+ function logInvalidRollupPhaseForChunkEmission() {
2395
2490
  return {
2396
2491
  code: INVALID_ROLLUP_PHASE,
2397
2492
  message: `Cannot emit chunks after module loading has finished.`
2398
2493
  };
2399
2494
  }
2400
- function errorInvalidSetAssetSourceCall() {
2495
+ function logInvalidSetAssetSourceCall() {
2401
2496
  return {
2402
2497
  code: INVALID_SETASSETSOURCE,
2403
2498
  message: `setAssetSource cannot be called in transform for caching reasons. Use emitFile with a source, or call setAssetSource in another hook.`
2404
2499
  };
2405
2500
  }
2406
- function errorInvalidFormatForTopLevelAwait(id, format) {
2501
+ function logInvalidFormatForTopLevelAwait(id, format) {
2407
2502
  return {
2408
2503
  code: INVALID_TLA_FORMAT,
2409
2504
  id,
2410
2505
  message: `Module format "${format}" does not support top-level await. Use the "es" or "system" output formats rather.`
2411
2506
  };
2412
2507
  }
2413
- function errorMissingExport(binding, importingModule, exporter) {
2508
+ function logMissingExport(binding, importingModule, exporter) {
2414
2509
  const isJson = extname(exporter) === '.json';
2415
2510
  return {
2416
2511
  binding,
@@ -2421,7 +2516,7 @@ function errorMissingExport(binding, importingModule, exporter) {
2421
2516
  url: getRollupUrl(URL_NAME_IS_NOT_EXPORTED)
2422
2517
  };
2423
2518
  }
2424
- function errorMissingGlobalName(externalId, guess) {
2519
+ function logMissingGlobalName(externalId, guess) {
2425
2520
  return {
2426
2521
  code: MISSING_GLOBAL_NAME,
2427
2522
  id: externalId,
@@ -2430,19 +2525,19 @@ function errorMissingGlobalName(externalId, guess) {
2430
2525
  url: getRollupUrl(URL_OUTPUT_GLOBALS)
2431
2526
  };
2432
2527
  }
2433
- function errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
2528
+ function logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore) {
2434
2529
  return {
2435
2530
  code: MISSING_IMPLICIT_DEPENDANT,
2436
2531
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" cannot be external.`
2437
2532
  };
2438
2533
  }
2439
- function errorUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
2534
+ function logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore) {
2440
2535
  return {
2441
2536
  code: MISSING_IMPLICIT_DEPENDANT,
2442
2537
  message: `Module "${relativeId(unresolvedId)}" that should be implicitly loaded before "${relativeId(implicitlyLoadedBefore)}" could not be resolved.`
2443
2538
  };
2444
2539
  }
2445
- function errorImplicitDependantIsNotIncluded(module) {
2540
+ function logImplicitDependantIsNotIncluded(module) {
2446
2541
  const implicitDependencies = [...module.implicitlyLoadedBefore]
2447
2542
  .map(dependency => relativeId(dependency.id))
2448
2543
  .sort();
@@ -2451,21 +2546,21 @@ function errorImplicitDependantIsNotIncluded(module) {
2451
2546
  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.`
2452
2547
  };
2453
2548
  }
2454
- function errorMissingNameOptionForIifeExport() {
2549
+ function logMissingNameOptionForIifeExport() {
2455
2550
  return {
2456
2551
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
2457
2552
  message: `If you do not supply "output.name", you may not be able to access the exports of an IIFE bundle.`,
2458
2553
  url: getRollupUrl(URL_OUTPUT_NAME)
2459
2554
  };
2460
2555
  }
2461
- function errorMissingNameOptionForUmdExport() {
2556
+ function logMissingNameOptionForUmdExport() {
2462
2557
  return {
2463
2558
  code: MISSING_NAME_OPTION_FOR_IIFE_EXPORT,
2464
2559
  message: 'You must supply "output.name" for UMD bundles that have exports so that the exports are accessible in environments without a module loader.',
2465
2560
  url: getRollupUrl(URL_OUTPUT_NAME)
2466
2561
  };
2467
2562
  }
2468
- function errorMissingNodeBuiltins(externalBuiltins) {
2563
+ function logMissingNodeBuiltins(externalBuiltins) {
2469
2564
  return {
2470
2565
  code: MISSING_NODE_BUILTINS,
2471
2566
  ids: externalBuiltins,
@@ -2473,14 +2568,14 @@ function errorMissingNodeBuiltins(externalBuiltins) {
2473
2568
  };
2474
2569
  }
2475
2570
  // eslint-disable-next-line unicorn/prevent-abbreviations
2476
- function errorMissingFileOrDirOption() {
2571
+ function logMissingFileOrDirOption() {
2477
2572
  return {
2478
2573
  code: MISSING_OPTION,
2479
2574
  message: 'You must specify "output.file" or "output.dir" for the build.',
2480
2575
  url: getRollupUrl(URL_OUTPUT_DIR)
2481
2576
  };
2482
2577
  }
2483
- function errorMixedExport(facadeModuleId, name) {
2578
+ function logMixedExport(facadeModuleId, name) {
2484
2579
  return {
2485
2580
  code: MIXED_EXPORTS,
2486
2581
  id: facadeModuleId,
@@ -2488,14 +2583,14 @@ function errorMixedExport(facadeModuleId, name) {
2488
2583
  url: getRollupUrl(URL_OUTPUT_EXPORTS)
2489
2584
  };
2490
2585
  }
2491
- function errorModuleLevelDirective(directive, id) {
2586
+ function logModuleLevelDirective(directive, id) {
2492
2587
  return {
2493
2588
  code: MODULE_LEVEL_DIRECTIVE,
2494
2589
  id,
2495
2590
  message: `Module level directives cause errors when bundled, "${directive}" in "${relativeId(id)}" was ignored.`
2496
2591
  };
2497
2592
  }
2498
- function errorNamespaceConflict(binding, reexportingModuleId, sources) {
2593
+ function logNamespaceConflict(binding, reexportingModuleId, sources) {
2499
2594
  return {
2500
2595
  binding,
2501
2596
  code: NAMESPACE_CONFLICT,
@@ -2504,14 +2599,22 @@ function errorNamespaceConflict(binding, reexportingModuleId, sources) {
2504
2599
  reexporter: reexportingModuleId
2505
2600
  };
2506
2601
  }
2507
- function errorNoTransformMapOrAstWithoutCode(pluginName) {
2602
+ function logNoTransformMapOrAstWithoutCode(pluginName) {
2508
2603
  return {
2509
2604
  code: NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE,
2510
2605
  message: `The plugin "${pluginName}" returned a "map" or "ast" without returning ` +
2511
2606
  'a "code". This will be ignored.'
2512
2607
  };
2513
2608
  }
2514
- function errorParseError(error, moduleId) {
2609
+ function logOptimizeChunkStatus(chunks, smallChunks, pointInTime) {
2610
+ return {
2611
+ code: OPTIMIZE_CHUNK_STATUS,
2612
+ message: `${pointInTime}, there are\n` +
2613
+ `${chunks} chunks, of which\n` +
2614
+ `${smallChunks} are below minChunkSize.`
2615
+ };
2616
+ }
2617
+ function logParseError(error, moduleId) {
2515
2618
  let message = error.message.replace(/ \(\d+:\d+\)$/, '');
2516
2619
  if (moduleId.endsWith('.json')) {
2517
2620
  message += ' (Note that you need @rollup/plugin-json to import JSON files)';
@@ -2526,10 +2629,8 @@ function errorParseError(error, moduleId) {
2526
2629
  message
2527
2630
  };
2528
2631
  }
2529
- function errorPluginError(error, plugin, { hook, id } = {}) {
2530
- if (typeof error === 'string')
2531
- error = { message: error };
2532
- if (error.code && error.code !== PLUGIN_ERROR) {
2632
+ function logPluginError(error, plugin, { hook, id } = {}) {
2633
+ if (error.code && !error.code.startsWith('PLUGIN_') && !error.pluginCode) {
2533
2634
  error.pluginCode = error.code;
2534
2635
  }
2535
2636
  error.code = PLUGIN_ERROR;
@@ -2542,7 +2643,7 @@ function errorPluginError(error, plugin, { hook, id } = {}) {
2542
2643
  }
2543
2644
  return error;
2544
2645
  }
2545
- function errorShimmedExport(id, binding) {
2646
+ function logShimmedExport(id, binding) {
2546
2647
  return {
2547
2648
  binding,
2548
2649
  code: SHIMMED_EXPORT,
@@ -2550,7 +2651,7 @@ function errorShimmedExport(id, binding) {
2550
2651
  message: `Missing export "${binding}" has been shimmed in module "${relativeId(id)}".`
2551
2652
  };
2552
2653
  }
2553
- function errorSourcemapBroken(plugin) {
2654
+ function logSourcemapBroken(plugin) {
2554
2655
  return {
2555
2656
  code: SOURCEMAP_BROKEN,
2556
2657
  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`,
@@ -2558,13 +2659,13 @@ function errorSourcemapBroken(plugin) {
2558
2659
  url: getRollupUrl(URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT)
2559
2660
  };
2560
2661
  }
2561
- function errorConflictingSourcemapSources(filename) {
2662
+ function logConflictingSourcemapSources(filename) {
2562
2663
  return {
2563
2664
  code: SOURCEMAP_BROKEN,
2564
2665
  message: `Multiple conflicting contents for sourcemap source ${filename}`
2565
2666
  };
2566
2667
  }
2567
- function errorInvalidSourcemapForError(error, id, column, line, pos) {
2668
+ function logInvalidSourcemapForError(error, id, column, line, pos) {
2568
2669
  return {
2569
2670
  cause: error,
2570
2671
  code: SOURCEMAP_ERROR,
@@ -2578,7 +2679,7 @@ function errorInvalidSourcemapForError(error, id, column, line, pos) {
2578
2679
  pos
2579
2680
  };
2580
2681
  }
2581
- function errorSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
2682
+ function logSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExportsOption) {
2582
2683
  return {
2583
2684
  code: SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT,
2584
2685
  exporter: id,
@@ -2587,14 +2688,14 @@ function errorSyntheticNamedExportsNeedNamespaceExport(id, syntheticNamedExports
2587
2688
  : 'a default export'} that does not reexport an unresolved named export of the same module.`
2588
2689
  };
2589
2690
  }
2590
- function errorThisIsUndefined() {
2691
+ function logThisIsUndefined() {
2591
2692
  return {
2592
2693
  code: THIS_IS_UNDEFINED,
2593
2694
  message: `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten`,
2594
2695
  url: getRollupUrl(URL_THIS_IS_UNDEFINED)
2595
2696
  };
2596
2697
  }
2597
- function errorUnexpectedNamedImport(id, imported, isReexport) {
2698
+ function logUnexpectedNamedImport(id, imported, isReexport) {
2598
2699
  const importType = isReexport ? 'reexport' : 'import';
2599
2700
  return {
2600
2701
  code: UNEXPECTED_NAMED_IMPORT,
@@ -2603,7 +2704,7 @@ function errorUnexpectedNamedImport(id, imported, isReexport) {
2603
2704
  url: getRollupUrl(URL_OUTPUT_INTEROP)
2604
2705
  };
2605
2706
  }
2606
- function errorUnexpectedNamespaceReexport(id) {
2707
+ function logUnexpectedNamespaceReexport(id) {
2607
2708
  return {
2608
2709
  code: UNEXPECTED_NAMED_IMPORT,
2609
2710
  exporter: id,
@@ -2611,25 +2712,25 @@ function errorUnexpectedNamespaceReexport(id) {
2611
2712
  url: getRollupUrl(URL_OUTPUT_INTEROP)
2612
2713
  };
2613
2714
  }
2614
- function errorUnknownOption(optionType, unknownOptions, validOptions) {
2715
+ function logUnknownOption(optionType, unknownOptions, validOptions) {
2615
2716
  return {
2616
2717
  code: UNKNOWN_OPTION,
2617
2718
  message: `Unknown ${optionType}: ${unknownOptions.join(', ')}. Allowed options: ${validOptions.join(', ')}`
2618
2719
  };
2619
2720
  }
2620
- function errorEntryCannotBeExternal(unresolvedId) {
2721
+ function logEntryCannotBeExternal(unresolvedId) {
2621
2722
  return {
2622
2723
  code: UNRESOLVED_ENTRY,
2623
2724
  message: `Entry module "${relativeId(unresolvedId)}" cannot be external.`
2624
2725
  };
2625
2726
  }
2626
- function errorUnresolvedEntry(unresolvedId) {
2727
+ function logUnresolvedEntry(unresolvedId) {
2627
2728
  return {
2628
2729
  code: UNRESOLVED_ENTRY,
2629
2730
  message: `Could not resolve entry module "${relativeId(unresolvedId)}".`
2630
2731
  };
2631
2732
  }
2632
- function errorUnresolvedImport(source, importer) {
2733
+ function logUnresolvedImport(source, importer) {
2633
2734
  return {
2634
2735
  code: UNRESOLVED_IMPORT,
2635
2736
  exporter: source,
@@ -2637,7 +2738,7 @@ function errorUnresolvedImport(source, importer) {
2637
2738
  message: `Could not resolve "${source}" from "${relativeId(importer)}"`
2638
2739
  };
2639
2740
  }
2640
- function errorUnresolvedImportTreatedAsExternal(source, importer) {
2741
+ function logUnresolvedImportTreatedAsExternal(source, importer) {
2641
2742
  return {
2642
2743
  code: UNRESOLVED_IMPORT,
2643
2744
  exporter: source,
@@ -2646,7 +2747,7 @@ function errorUnresolvedImportTreatedAsExternal(source, importer) {
2646
2747
  url: getRollupUrl(URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY)
2647
2748
  };
2648
2749
  }
2649
- function errorUnusedExternalImports(externalId, names, importers) {
2750
+ function logUnusedExternalImports(externalId, names, importers) {
2650
2751
  return {
2651
2752
  code: UNUSED_EXTERNAL_IMPORT,
2652
2753
  exporter: externalId,
@@ -2658,96 +2759,25 @@ function errorUnusedExternalImports(externalId, names, importers) {
2658
2759
  names
2659
2760
  };
2660
2761
  }
2661
- function errorFailedValidation(message) {
2762
+ function logFailedValidation(message) {
2662
2763
  return {
2663
2764
  code: VALIDATION_ERROR,
2664
2765
  message
2665
2766
  };
2666
2767
  }
2667
2768
  function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
2668
- warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onwarn, options.strictDeprecations, plugin);
2769
+ warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
2669
2770
  }
2670
- function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, warn, strictDeprecations, plugin) {
2771
+ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
2671
2772
  if (activeDeprecation || strictDeprecations) {
2672
- const warning = errorDeprecation(deprecation, urlSnippet, plugin);
2773
+ const warning = logDeprecation(deprecation, urlSnippet, plugin);
2673
2774
  if (strictDeprecations) {
2674
2775
  return error(warning);
2675
2776
  }
2676
- warn(warning);
2777
+ log(LOGLEVEL_WARN, warning);
2677
2778
  }
2678
2779
  }
2679
2780
 
2680
- const RESERVED_NAMES = new Set([
2681
- 'await',
2682
- 'break',
2683
- 'case',
2684
- 'catch',
2685
- 'class',
2686
- 'const',
2687
- 'continue',
2688
- 'debugger',
2689
- 'default',
2690
- 'delete',
2691
- 'do',
2692
- 'else',
2693
- 'enum',
2694
- 'eval',
2695
- 'export',
2696
- 'extends',
2697
- 'false',
2698
- 'finally',
2699
- 'for',
2700
- 'function',
2701
- 'if',
2702
- 'implements',
2703
- 'import',
2704
- 'in',
2705
- 'instanceof',
2706
- 'interface',
2707
- 'let',
2708
- 'NaN',
2709
- 'new',
2710
- 'null',
2711
- 'package',
2712
- 'private',
2713
- 'protected',
2714
- 'public',
2715
- 'return',
2716
- 'static',
2717
- 'super',
2718
- 'switch',
2719
- 'this',
2720
- 'throw',
2721
- 'true',
2722
- 'try',
2723
- 'typeof',
2724
- 'undefined',
2725
- 'var',
2726
- 'void',
2727
- 'while',
2728
- 'with',
2729
- 'yield'
2730
- ]);
2731
- const RESERVED_NAMES$1 = RESERVED_NAMES;
2732
-
2733
- const illegalCharacters = /[^\w$]/g;
2734
- const startsWithDigit = (value) => /\d/.test(value[0]);
2735
- const needsEscape = (value) => startsWithDigit(value) || RESERVED_NAMES$1.has(value) || value === 'arguments';
2736
- function isLegal(value) {
2737
- if (needsEscape(value)) {
2738
- return false;
2739
- }
2740
- return !illegalCharacters.test(value);
2741
- }
2742
- function makeLegal(value) {
2743
- value = value
2744
- .replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
2745
- .replace(illegalCharacters, '_');
2746
- if (needsEscape(value))
2747
- value = `_${value}`;
2748
- return value || '_';
2749
- }
2750
-
2751
2781
  class ExternalModule {
2752
2782
  constructor(options, id, moduleSideEffects, meta, renormalizeRenderPath, assertions) {
2753
2783
  this.options = options;
@@ -2830,7 +2860,7 @@ class ExternalModule {
2830
2860
  }
2831
2861
  }
2832
2862
  const importersArray = [...importersSet];
2833
- this.options.onwarn(errorUnusedExternalImports(this.id, unused, importersArray));
2863
+ this.options.onLog(LOGLEVEL_WARN, logUnusedExternalImports(this.id, unused, importersArray));
2834
2864
  }
2835
2865
  }
2836
2866
 
@@ -8325,7 +8355,7 @@ class Identifier extends NodeBase {
8325
8355
  }
8326
8356
  }
8327
8357
  disallowImportReassignment() {
8328
- return this.context.error(errorIllegalImportReassignment(this.name, this.context.module.id), this.start);
8358
+ return this.context.error(logIllegalImportReassignment(this.name, this.context.module.id), this.start);
8329
8359
  }
8330
8360
  getVariableRespectingTDZ() {
8331
8361
  if (this.isPossibleTDZ()) {
@@ -8533,9 +8563,9 @@ class ExpressionStatement extends NodeBase {
8533
8563
  if (this.directive &&
8534
8564
  this.directive !== 'use strict' &&
8535
8565
  this.parent.type === Program$1) {
8536
- this.context.warn(
8566
+ this.context.log(LOGLEVEL_WARN,
8537
8567
  // This is necessary, because either way (deleting or not) can lead to errors.
8538
- errorModuleLevelDirective(this.directive, this.context.module.id), this.start);
8568
+ logModuleLevelDirective(this.directive, this.context.module.id), this.start);
8539
8569
  }
8540
8570
  }
8541
8571
  render(code, options) {
@@ -9580,7 +9610,7 @@ class MemberExpression extends NodeBase {
9580
9610
  if (this.variable) {
9581
9611
  this.context.includeVariableInModule(this.variable);
9582
9612
  }
9583
- this.context.warn(errorIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9613
+ this.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9584
9614
  }
9585
9615
  }
9586
9616
  }
@@ -9626,7 +9656,7 @@ function resolveNamespaceVariables(baseVariable, path, astContext) {
9626
9656
  if (!variable) {
9627
9657
  if (path.length === 1) {
9628
9658
  const fileName = baseVariable.context.fileName;
9629
- astContext.warn(errorMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9659
+ astContext.log(LOGLEVEL_WARN, logMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9630
9660
  return 'undefined';
9631
9661
  }
9632
9662
  return null;
@@ -9733,10 +9763,10 @@ class CallExpression extends CallExpressionBase {
9733
9763
  if (this.callee instanceof Identifier) {
9734
9764
  const variable = this.scope.findVariable(this.callee.name);
9735
9765
  if (variable.isNamespace) {
9736
- this.context.warn(errorCannotCallNamespace(this.callee.name), this.start);
9766
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(this.callee.name), this.start);
9737
9767
  }
9738
9768
  if (this.callee.name === 'eval') {
9739
- this.context.warn(errorEval(this.context.module.id), this.start);
9769
+ this.context.log(LOGLEVEL_WARN, logEval(this.context.module.id), this.start);
9740
9770
  }
9741
9771
  }
9742
9772
  this.interaction = {
@@ -11849,29 +11879,6 @@ class ObjectExpression extends NodeBase {
11849
11879
  class PrivateIdentifier extends NodeBase {
11850
11880
  }
11851
11881
 
11852
- function getOriginalLocation(sourcemapChain, location) {
11853
- const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
11854
- traceSourcemap: while (filteredSourcemapChain.length > 0) {
11855
- const sourcemap = filteredSourcemapChain.pop();
11856
- const line = sourcemap.mappings[location.line - 1];
11857
- if (line) {
11858
- const filteredLine = line.filter((segment) => segment.length > 1);
11859
- const lastSegment = filteredLine[filteredLine.length - 1];
11860
- for (const segment of filteredLine) {
11861
- if (segment[0] >= location.column || segment === lastSegment) {
11862
- location = {
11863
- column: segment[3],
11864
- line: segment[2] + 1
11865
- };
11866
- continue traceSourcemap;
11867
- }
11868
- }
11869
- }
11870
- throw new Error("Can't resolve original location of error.");
11871
- }
11872
- return location;
11873
- }
11874
-
11875
11882
  class Program extends NodeBase {
11876
11883
  constructor() {
11877
11884
  super(...arguments);
@@ -11891,19 +11898,8 @@ class Program extends NodeBase {
11891
11898
  if (node.hasEffects(context)) {
11892
11899
  if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11893
11900
  this.hasLoggedEffect = true;
11894
- const { code, module } = this.context;
11895
- const { line, column } = locate(code, node.start, { offsetLine: 1 });
11896
- console.log(`First side effect in ${relativeId(module.id)} is at (${line}:${column})\n${getCodeFrame(code, line, column)}`);
11897
- try {
11898
- const { column: originalColumn, line: originalLine } = getOriginalLocation(module.sourcemapChain, { column, line });
11899
- if (originalLine !== line) {
11900
- console.log(`Original location is at (${originalLine}:${originalColumn})\n${getCodeFrame(module.originalCode, originalLine, originalColumn)}\n`);
11901
- }
11902
- }
11903
- catch {
11904
- /* ignored */
11905
- }
11906
- console.log();
11901
+ const { code, log, module } = this.context;
11902
+ log(LOGLEVEL_INFO, logFirstSideEffect(code, module.id, locate(code, node.start, { offsetLine: 1 })), node.start);
11907
11903
  }
11908
11904
  return (this.hasCachedEffect = true);
11909
11905
  }
@@ -12264,7 +12260,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
12264
12260
  const name = this.tag.name;
12265
12261
  const variable = this.scope.findVariable(name);
12266
12262
  if (variable.isNamespace) {
12267
- this.context.warn(errorCannotCallNamespace(name), this.start);
12263
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start);
12268
12264
  }
12269
12265
  }
12270
12266
  }
@@ -12511,7 +12507,7 @@ class ThisExpression extends NodeBase {
12511
12507
  this.alias =
12512
12508
  this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null;
12513
12509
  if (this.alias === 'undefined') {
12514
- this.context.warn(errorThisIsUndefined(), this.start);
12510
+ this.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
12515
12511
  }
12516
12512
  }
12517
12513
  render(code) {
@@ -13154,6 +13150,29 @@ function getId(m) {
13154
13150
  return m.id;
13155
13151
  }
13156
13152
 
13153
+ function getOriginalLocation(sourcemapChain, location) {
13154
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
13155
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
13156
+ const sourcemap = filteredSourcemapChain.pop();
13157
+ const line = sourcemap.mappings[location.line - 1];
13158
+ if (line) {
13159
+ const filteredLine = line.filter((segment) => segment.length > 1);
13160
+ const lastSegment = filteredLine[filteredLine.length - 1];
13161
+ for (const segment of filteredLine) {
13162
+ if (segment[0] >= location.column || segment === lastSegment) {
13163
+ location = {
13164
+ column: segment[3],
13165
+ line: segment[2] + 1
13166
+ };
13167
+ continue traceSourcemap;
13168
+ }
13169
+ }
13170
+ }
13171
+ throw new Error("Can't resolve original location of error.");
13172
+ }
13173
+ return location;
13174
+ }
13175
+
13157
13176
  function getAssertionsFromImportExpression(node) {
13158
13177
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
13159
13178
  if (!assertProperty) {
@@ -13330,7 +13349,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
13330
13349
  const searchedModules = searchedNamesAndModules.get(name);
13331
13350
  if (searchedModules) {
13332
13351
  if (searchedModules.has(target)) {
13333
- return isExportAllSearch ? [null] : error(errorCircularReexport(name, target.id));
13352
+ return isExportAllSearch ? [null] : error(logCircularReexport(name, target.id));
13334
13353
  }
13335
13354
  searchedModules.add(target);
13336
13355
  }
@@ -13656,7 +13675,7 @@ class Module {
13656
13675
  : 'default', { onlyExplicit: true });
13657
13676
  }
13658
13677
  if (!this.syntheticNamespace) {
13659
- return error(errorSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13678
+ return error(logSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13660
13679
  }
13661
13680
  return this.syntheticNamespace;
13662
13681
  }
@@ -13675,7 +13694,7 @@ class Module {
13675
13694
  if (reexportDeclaration) {
13676
13695
  const [variable] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
13677
13696
  if (!variable) {
13678
- return this.error(errorMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13697
+ return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13679
13698
  }
13680
13699
  if (importerForSideEffects) {
13681
13700
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -13812,13 +13831,17 @@ class Module {
13812
13831
  }
13813
13832
  this.exportAllModules.push(...externalExportAllModules);
13814
13833
  }
13834
+ log(level, properties, pos) {
13835
+ this.addLocationToLogProps(properties, pos);
13836
+ this.options.onLog(level, properties);
13837
+ }
13815
13838
  render(options) {
13816
13839
  const source = this.magicString.clone();
13817
13840
  this.ast.render(source, options);
13818
13841
  source.trim();
13819
13842
  const { usesTopLevelAwait } = this.astContext;
13820
13843
  if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') {
13821
- return error(errorInvalidFormatForTopLevelAwait(this.id, options.format));
13844
+ return error(logInvalidFormatForTopLevelAwait(this.id, options.format));
13822
13845
  }
13823
13846
  return { source, usesTopLevelAwait };
13824
13847
  }
@@ -13863,6 +13886,7 @@ class Module {
13863
13886
  includeAllExports: () => this.includeAllExports(true),
13864
13887
  includeDynamicImport: this.includeDynamicImport.bind(this),
13865
13888
  includeVariableInModule: this.includeVariableInModule.bind(this),
13889
+ log: this.log.bind(this),
13866
13890
  magicString: this.magicString,
13867
13891
  manualPureFunctions: this.graph.pureFunctions,
13868
13892
  module: this,
@@ -13871,8 +13895,7 @@ class Module {
13871
13895
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
13872
13896
  traceExport: (name) => this.getVariableForExportName(name)[0],
13873
13897
  traceVariable: this.traceVariable.bind(this),
13874
- usesTopLevelAwait: false,
13875
- warn: this.warn.bind(this)
13898
+ usesTopLevelAwait: false
13876
13899
  };
13877
13900
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13878
13901
  this.namespace = new NamespaceVariable(this.astContext);
@@ -13932,7 +13955,7 @@ class Module {
13932
13955
  }
13933
13956
  const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13934
13957
  if (!declaration) {
13935
- return this.error(errorMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13958
+ return this.error(logMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13936
13959
  }
13937
13960
  return declaration;
13938
13961
  }
@@ -13949,10 +13972,6 @@ class Module {
13949
13972
  Object.assign(this.info.meta, meta);
13950
13973
  }
13951
13974
  }
13952
- warn(properties, pos) {
13953
- this.addLocationToLogProps(properties, pos);
13954
- this.options.onwarn(properties);
13955
- }
13956
13975
  addDynamicImport(node) {
13957
13976
  let argument = node.source;
13958
13977
  if (argument instanceof TemplateLiteral) {
@@ -14066,7 +14085,7 @@ class Module {
14066
14085
  code = this.originalCode;
14067
14086
  }
14068
14087
  catch (error_) {
14069
- this.options.onwarn(errorInvalidSourcemapForError(error_, this.id, column, line, pos));
14088
+ this.options.onLog(LOGLEVEL_WARN, logInvalidSourcemapForError(error_, this.id, column, line, pos));
14070
14089
  }
14071
14090
  augmentCodeLocation(properties, { column, line }, code, this.id);
14072
14091
  }
@@ -14107,7 +14126,7 @@ class Module {
14107
14126
  const existingAssertions = this.sourcesWithAssertions.get(source);
14108
14127
  if (existingAssertions) {
14109
14128
  if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
14110
- this.warn(errorInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
14129
+ this.log(LOGLEVEL_WARN, logInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
14111
14130
  }
14112
14131
  }
14113
14132
  else {
@@ -14145,7 +14164,7 @@ class Module {
14145
14164
  if (foundDeclarationList.length === 1) {
14146
14165
  return [usedDeclaration];
14147
14166
  }
14148
- this.options.onwarn(errorNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
14167
+ this.options.onLog(LOGLEVEL_WARN, logNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
14149
14168
  // TODO we are pretending it was not found while it should behave like "undefined"
14150
14169
  return [null];
14151
14170
  }
@@ -14153,7 +14172,7 @@ class Module {
14153
14172
  const foundDeclarationList = [...foundExternalDeclarations];
14154
14173
  const usedDeclaration = foundDeclarationList[0];
14155
14174
  if (foundDeclarationList.length > 1) {
14156
- this.options.onwarn(errorAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
14175
+ this.options.onLog(LOGLEVEL_WARN, logAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
14157
14176
  }
14158
14177
  return [usedDeclaration, true];
14159
14178
  }
@@ -14197,10 +14216,15 @@ class Module {
14197
14216
  }
14198
14217
  }
14199
14218
  includeVariable(variable) {
14200
- if (!variable.included) {
14219
+ const variableModule = variable.module;
14220
+ if (variable.included) {
14221
+ if (variableModule instanceof Module && variableModule !== this) {
14222
+ getAndExtendSideEffectModules(variable, this);
14223
+ }
14224
+ }
14225
+ else {
14201
14226
  variable.include();
14202
14227
  this.graph.needsTreeshakingPass = true;
14203
- const variableModule = variable.module;
14204
14228
  if (variableModule instanceof Module) {
14205
14229
  if (!variableModule.isExecuted) {
14206
14230
  markModuleAndImpureDependenciesAsExecuted(variableModule);
@@ -14224,7 +14248,7 @@ class Module {
14224
14248
  }
14225
14249
  }
14226
14250
  shimMissingExport(name) {
14227
- this.options.onwarn(errorShimmedExport(this.id, name));
14251
+ this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name));
14228
14252
  this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
14229
14253
  }
14230
14254
  tryParse() {
@@ -14232,7 +14256,7 @@ class Module {
14232
14256
  return this.graph.contextParse(this.info.code);
14233
14257
  }
14234
14258
  catch (error_) {
14235
- return this.error(errorParseError(error_, this.id), error_.pos);
14259
+ return this.error(logParseError(error_, this.id), error_.pos);
14236
14260
  }
14237
14261
  }
14238
14262
  }
@@ -14533,17 +14557,17 @@ const nodeBuiltins = new Set([
14533
14557
  'timers/promises',
14534
14558
  'util/types'
14535
14559
  ]);
14536
- function warnOnBuiltins(warn, dependencies) {
14560
+ function warnOnBuiltins(log, dependencies) {
14537
14561
  const externalBuiltins = dependencies
14538
14562
  .map(({ importPath }) => importPath)
14539
14563
  .filter(importPath => nodeBuiltins.has(importPath) || importPath.startsWith('node:'));
14540
14564
  if (externalBuiltins.length === 0)
14541
14565
  return;
14542
- warn(errorMissingNodeBuiltins(externalBuiltins));
14566
+ log(LOGLEVEL_WARN, logMissingNodeBuiltins(externalBuiltins));
14543
14567
  }
14544
14568
 
14545
- function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, outro, snippets, onwarn }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
14546
- warnOnBuiltins(onwarn, dependencies);
14569
+ function amd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, isEntryFacade, isModuleFacade, namedExportsMode, log, outro, snippets }, { amd, esModule, externalLiveBindings, freeze, interop, namespaceToStringTag, strict }) {
14570
+ warnOnBuiltins(log, dependencies);
14547
14571
  const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
14548
14572
  const parameters = dependencies.map(m => m.name);
14549
14573
  const { n, getNonArrowFunctionIntro, _ } = snippets;
@@ -14768,19 +14792,19 @@ function trimEmptyImports(dependencies) {
14768
14792
  return [];
14769
14793
  }
14770
14794
 
14771
- function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
14795
+ function iife(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, indent: t, intro, namedExportsMode, log, outro, snippets }, { compact, esModule, extend, freeze, externalLiveBindings, globals, interop, name, namespaceToStringTag, strict }) {
14772
14796
  const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
14773
14797
  const isNamespaced = name && name.includes('.');
14774
14798
  const useVariableAssignment = !extend && !isNamespaced;
14775
14799
  if (name && useVariableAssignment && !isLegal(name)) {
14776
- return error(errorIllegalIdentifierAsName(name));
14800
+ return error(logIllegalIdentifierAsName(name));
14777
14801
  }
14778
- warnOnBuiltins(onwarn, dependencies);
14802
+ warnOnBuiltins(log, dependencies);
14779
14803
  const external = trimEmptyImports(dependencies);
14780
14804
  const deps = external.map(dep => dep.globalName || 'null');
14781
14805
  const parameters = external.map(m => m.name);
14782
14806
  if (hasExports && !name) {
14783
- onwarn(errorMissingNameOptionForIifeExport());
14807
+ log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
14784
14808
  }
14785
14809
  if (namedExportsMode && hasExports) {
14786
14810
  if (extend) {
@@ -14972,14 +14996,14 @@ function safeAccess(name, globalVariable, { _, getPropertyAccess }) {
14972
14996
  .map(part => (propertyPath += getPropertyAccess(part)))
14973
14997
  .join(`${_}&&${_}`);
14974
14998
  }
14975
- function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, outro, snippets, onwarn }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
14999
+ function umd(magicString, { accessedGlobals, dependencies, exports, hasDefaultExport, hasExports, id, indent: t, intro, namedExportsMode, log, outro, snippets }, { amd, compact, esModule, extend, externalLiveBindings, freeze, interop, name, namespaceToStringTag, globals, noConflict, strict }) {
14976
15000
  const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
14977
15001
  const factoryVariable = compact ? 'f' : 'factory';
14978
15002
  const globalVariable = compact ? 'g' : 'global';
14979
15003
  if (hasExports && !name) {
14980
- return error(errorMissingNameOptionForUmdExport());
15004
+ return error(logMissingNameOptionForUmdExport());
14981
15005
  }
14982
- warnOnBuiltins(onwarn, dependencies);
15006
+ warnOnBuiltins(log, dependencies);
14983
15007
  const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
14984
15008
  const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
14985
15009
  const trimmedImports = trimEmptyImports(dependencies);
@@ -15089,7 +15113,7 @@ async function createAddons(options, outputPluginDriver, chunk) {
15089
15113
  return { banner, footer, intro, outro };
15090
15114
  }
15091
15115
  catch (error_) {
15092
- return error(errorAddonNotGenerated(error_.message, error_.hook, error_.plugin));
15116
+ return error(logAddonNotGenerated(error_.message, error_.hook, error_.plugin));
15093
15117
  }
15094
15118
  }
15095
15119
 
@@ -15242,15 +15266,15 @@ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
15242
15266
  }
15243
15267
  }
15244
15268
 
15245
- function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, warn) {
15269
+ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
15246
15270
  const exportKeys = chunk.getExportNames();
15247
15271
  if (exportMode === 'default') {
15248
15272
  if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
15249
- return error(errorIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
15273
+ return error(logIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
15250
15274
  }
15251
15275
  }
15252
15276
  else if (exportMode === 'none' && exportKeys.length > 0) {
15253
- return error(errorIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
15277
+ return error(logIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
15254
15278
  }
15255
15279
  if (exportMode === 'auto') {
15256
15280
  if (exportKeys.length === 0) {
@@ -15261,7 +15285,7 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
15261
15285
  }
15262
15286
  else {
15263
15287
  if (format !== 'es' && format !== 'system' && exportKeys.includes('default')) {
15264
- warn(errorMixedExport(facadeModuleId, name));
15288
+ log(LOGLEVEL_WARN, logMixedExport(facadeModuleId, name));
15265
15289
  }
15266
15290
  exportMode = 'named';
15267
15291
  }
@@ -15338,7 +15362,8 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
15338
15362
  }
15339
15363
  }
15340
15364
 
15341
- // Four random characters from the private use area to minimize risk of conflicts
15365
+ // Four random characters from the private use area to minimize risk of
15366
+ // conflicts
15342
15367
  const hashPlaceholderLeft = '!~{';
15343
15368
  const hashPlaceholderRight = '}~';
15344
15369
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
@@ -15349,11 +15374,11 @@ const getHashPlaceholderGenerator = () => {
15349
15374
  let nextIndex = 0;
15350
15375
  return (optionName, hashSize = defaultHashSize) => {
15351
15376
  if (hashSize > maxHashSize) {
15352
- return error(errorFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
15377
+ return error(logFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
15353
15378
  }
15354
15379
  const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
15355
15380
  if (placeholder.length > hashSize) {
15356
- return error(errorFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
15381
+ return error(logFailedValidation(`To generate hashes for this number of chunks (currently ${nextIndex}), you need a minimum hash size of ${placeholder.length}, received ${hashSize}. Check the "${optionName}" option.`));
15357
15382
  }
15358
15383
  return placeholder;
15359
15384
  };
@@ -15420,14 +15445,14 @@ const removeUnreferencedAssets = (outputBundle) => {
15420
15445
 
15421
15446
  function renderNamePattern(pattern, patternName, replacements) {
15422
15447
  if (isPathFragment(pattern))
15423
- return error(errorFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
15448
+ return error(logFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
15424
15449
  return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
15425
15450
  if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
15426
- return error(errorFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
15451
+ return error(logFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
15427
15452
  }
15428
15453
  const replacement = replacements[type](size && Number.parseInt(size.slice(1)));
15429
15454
  if (isPathFragment(replacement))
15430
- return error(errorFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
15455
+ return error(logFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
15431
15456
  return replacement;
15432
15457
  });
15433
15458
  }
@@ -15452,13 +15477,13 @@ const NON_ASSET_EXTENSIONS = new Set([
15452
15477
  '.cjs',
15453
15478
  '.cts'
15454
15479
  ]);
15455
- function getGlobalName(chunk, globals, hasExports, warn) {
15480
+ function getGlobalName(chunk, globals, hasExports, log) {
15456
15481
  const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
15457
15482
  if (globalName) {
15458
15483
  return globalName;
15459
15484
  }
15460
15485
  if (hasExports) {
15461
- warn(errorMissingGlobalName(chunk.id, chunk.variableName));
15486
+ log(LOGLEVEL_WARN, logMissingGlobalName(chunk.id, chunk.variableName));
15462
15487
  return chunk.variableName;
15463
15488
  }
15464
15489
  }
@@ -15617,7 +15642,7 @@ class Chunk {
15617
15642
  assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
15618
15643
  }
15619
15644
  if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
15620
- this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
15645
+ this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onLog);
15621
15646
  }
15622
15647
  generateFacades() {
15623
15648
  const facades = [];
@@ -15765,7 +15790,7 @@ class Chunk {
15765
15790
  }
15766
15791
  }
15767
15792
  async render() {
15768
- const { dependencies, exportMode, facadeModule, inputOptions: { onwarn }, outputOptions, pluginDriver, snippets } = this;
15793
+ const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
15769
15794
  const { format, hoistTransitiveImports, preserveModules } = outputOptions;
15770
15795
  // for static and dynamic entry points, add transitive dependencies to this
15771
15796
  // chunk's dependencies to avoid loading latency
@@ -15815,8 +15840,8 @@ class Chunk {
15815
15840
  intro,
15816
15841
  isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry),
15817
15842
  isModuleFacade: facadeModule !== null,
15843
+ log: onLog,
15818
15844
  namedExportsMode: exportMode !== 'default',
15819
- onwarn,
15820
15845
  outro,
15821
15846
  snippets,
15822
15847
  usesTopLevelAwait
@@ -15871,7 +15896,7 @@ class Chunk {
15871
15896
  if (alternativeReexportModule) {
15872
15897
  const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
15873
15898
  if (exportingChunk !== exportChunk) {
15874
- this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
15899
+ this.inputOptions.onLog(LOGLEVEL_WARN, logCyclicCrossChunkReexport(
15875
15900
  // Namespaces do not have an export name
15876
15901
  variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, importingModule.id, this.outputOptions.preserveModules));
15877
15902
  }
@@ -16059,7 +16084,7 @@ class Chunk {
16059
16084
  dependency = this.externalChunkByModule.get(module);
16060
16085
  imported = variable.name;
16061
16086
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
16062
- return error(errorUnexpectedNamedImport(module.id, imported, false));
16087
+ return error(logUnexpectedNamedImport(module.id, imported, false));
16063
16088
  }
16064
16089
  }
16065
16090
  else {
@@ -16149,7 +16174,7 @@ class Chunk {
16149
16174
  if (exportName[0] === '*') {
16150
16175
  const id = exportName.slice(1);
16151
16176
  if (interop(id) === 'defaultOnly') {
16152
- this.inputOptions.onwarn(errorUnexpectedNamespaceReexport(id));
16177
+ this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id));
16153
16178
  }
16154
16179
  needsLiveBinding = externalLiveBindings;
16155
16180
  dependency = this.externalChunkByModule.get(this.modulesById.get(id));
@@ -16171,7 +16196,7 @@ class Chunk {
16171
16196
  dependency = this.externalChunkByModule.get(module);
16172
16197
  imported = variable.name;
16173
16198
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
16174
- return error(errorUnexpectedNamedImport(module.id, imported, true));
16199
+ return error(logUnexpectedNamedImport(module.id, imported, true));
16175
16200
  }
16176
16201
  needsLiveBinding =
16177
16202
  externalLiveBindings &&
@@ -16216,7 +16241,7 @@ class Chunk {
16216
16241
  defaultVariableName: dep.defaultVariableName,
16217
16242
  globalName: dep instanceof ExternalChunk &&
16218
16243
  (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
16219
- getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onwarn),
16244
+ getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onLog),
16220
16245
  importPath,
16221
16246
  imports,
16222
16247
  isChunk: dep instanceof Chunk,
@@ -16240,7 +16265,7 @@ class Chunk {
16240
16265
  }
16241
16266
  // This method changes properties on the AST before rendering and must not be async
16242
16267
  renderModules(fileName) {
16243
- const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onwarn }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
16268
+ const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onLog }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
16244
16269
  const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag } = outputOptions;
16245
16270
  const { _, cnst, n } = snippets;
16246
16271
  this.setDynamicImportResolutions(fileName);
@@ -16313,7 +16338,7 @@ class Chunk {
16313
16338
  }
16314
16339
  const renderedSource = compact ? magicString : magicString.trim();
16315
16340
  if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
16316
- onwarn(errorEmptyChunk(this.getChunkName()));
16341
+ onLog(LOGLEVEL_WARN, logEmptyChunk(this.getChunkName()));
16317
16342
  }
16318
16343
  return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
16319
16344
  }
@@ -16602,7 +16627,7 @@ function* concatLazy(iterables) {
16602
16627
  * those chunks that are already loaded for that dynamic entry and create
16603
16628
  * another round of chunks.
16604
16629
  */
16605
- function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16630
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
16606
16631
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
16607
16632
  const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
16608
16633
  // Each chunk is identified by its position in this array
@@ -16610,7 +16635,7 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16610
16635
  // This mutates initialChunks but also clears
16611
16636
  // dynamicallyDependentEntriesByDynamicEntry as side effect
16612
16637
  removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
16613
- chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize).map(({ modules }) => ({
16638
+ chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize, log).map(({ modules }) => ({
16614
16639
  alias: null,
16615
16640
  modules
16616
16641
  })));
@@ -16866,7 +16891,7 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
16866
16891
  * following the rule (a), starting with the smallest chunks to look for
16867
16892
  * possible merge targets.
16868
16893
  */
16869
- function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize) {
16894
+ function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize, log) {
16870
16895
  timeStart('optimize chunks', 3);
16871
16896
  const chunkPartition = getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize);
16872
16897
  if (!chunkPartition) {
@@ -16874,10 +16899,10 @@ function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize) {
16874
16899
  return initialChunks; // the actual modules
16875
16900
  }
16876
16901
  minChunkSize > 1 &&
16877
- console.log('Before eliminating small chunks, there were\n', initialChunks.length, 'chunks, of which\n', chunkPartition.small.size, 'were below minChunkSize.');
16902
+ log('info', logOptimizeChunkStatus(initialChunks.length, chunkPartition.small.size, 'Initially'));
16878
16903
  mergeChunks(chunkPartition, minChunkSize);
16879
16904
  minChunkSize > 1 &&
16880
- console.log('After merging chunks,\n', chunkPartition.small.size + chunkPartition.big.size, 'chunks remain, of which\n', chunkPartition.small.size, 'are below minChunkSize.');
16905
+ log('info', logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
16881
16906
  timeEnd('optimize chunks', 3);
16882
16907
  return [...chunkPartition.small, ...chunkPartition.big];
16883
16908
  }
@@ -17288,7 +17313,7 @@ class Link {
17288
17313
  sourcesContent[sourceIndex] = content;
17289
17314
  }
17290
17315
  else if (content != null && sourcesContent[sourceIndex] !== content) {
17291
- return error(errorConflictingSourcemapSources(filename));
17316
+ return error(logConflictingSourcemapSources(filename));
17292
17317
  }
17293
17318
  const tracedSegment = [segment[0], sourceIndex, line, column];
17294
17319
  if (name) {
@@ -17338,12 +17363,12 @@ class Link {
17338
17363
  return null;
17339
17364
  }
17340
17365
  }
17341
- function getLinkMap(warn) {
17366
+ function getLinkMap(log) {
17342
17367
  return function linkMap(source, map) {
17343
17368
  if (map.mappings) {
17344
17369
  return new Link(map, [source]);
17345
17370
  }
17346
- warn(errorSourcemapBroken(map.plugin));
17371
+ log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin));
17347
17372
  return new Link({
17348
17373
  mappings: [],
17349
17374
  names: []
@@ -17365,8 +17390,8 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
17365
17390
  }
17366
17391
  return sourcemapChain.reduce(linkMap, source);
17367
17392
  }
17368
- function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, warn) {
17369
- const linkMap = getLinkMap(warn);
17393
+ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, log) {
17394
+ const linkMap = getLinkMap(log);
17370
17395
  const moduleSources = modules
17371
17396
  .filter(module => !module.excludeFromSourcemap)
17372
17397
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
@@ -17381,11 +17406,11 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
17381
17406
  sourcesContent = (excludeContent ? null : sourcesContent);
17382
17407
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
17383
17408
  }
17384
- function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn) {
17409
+ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
17385
17410
  if (sourcemapChain.length === 0) {
17386
17411
  return originalSourcemap;
17387
17412
  }
17388
- const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(warn));
17413
+ const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
17389
17414
  const map = source.traceMappings();
17390
17415
  return { version: 3, ...map };
17391
17416
  }
@@ -17410,14 +17435,14 @@ function decodedSourcemap(map) {
17410
17435
  return { ...map, mappings };
17411
17436
  }
17412
17437
 
17413
- async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
17438
+ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
17414
17439
  timeStart('render chunks', 2);
17415
17440
  reserveEntryChunksInBundle(chunks);
17416
17441
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
17417
17442
  timeEnd('render chunks', 2);
17418
17443
  timeStart('transform chunks', 2);
17419
17444
  const chunkGraph = getChunkGraph(chunks);
17420
- const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
17445
+ const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
17421
17446
  const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
17422
17447
  addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
17423
17448
  timeEnd('transform chunks', 2);
@@ -17436,7 +17461,7 @@ function getChunkGraph(chunks) {
17436
17461
  return [renderedChunkInfo.fileName, renderedChunkInfo];
17437
17462
  }));
17438
17463
  }
17439
- async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, onwarn) {
17464
+ async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, log) {
17440
17465
  let map = null;
17441
17466
  const sourcemapChain = [];
17442
17467
  let code = await outputPluginDriver.hookReduceArg0('renderChunk', [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], (code, result, plugin) => {
@@ -17467,13 +17492,13 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17467
17492
  else
17468
17493
  resultingFile = resolve(fileName);
17469
17494
  const decodedMap = magicString.generateDecodedMap({});
17470
- map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, onwarn);
17495
+ map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, log);
17471
17496
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
17472
17497
  let sourcePath = map.sources[sourcesIndex];
17473
17498
  const sourcemapPath = `${resultingFile}.map`;
17474
17499
  const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17475
17500
  if (typeof ignoreList !== 'boolean') {
17476
- error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17501
+ error(logFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17477
17502
  }
17478
17503
  if (ignoreList) {
17479
17504
  if (map.x_google_ignoreList === undefined) {
@@ -17486,7 +17511,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17486
17511
  if (sourcemapPathTransform) {
17487
17512
  sourcePath = sourcemapPathTransform(sourcePath, sourcemapPath);
17488
17513
  if (typeof sourcePath !== 'string') {
17489
- error(errorFailedValidation(`sourcemapPathTransform function must return a string.`));
17514
+ error(logFailedValidation(`sourcemapPathTransform function must return a string.`));
17490
17515
  }
17491
17516
  }
17492
17517
  map.sources[sourcesIndex] = normalize(sourcePath);
@@ -17498,7 +17523,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17498
17523
  map
17499
17524
  };
17500
17525
  }
17501
- async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn) {
17526
+ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log) {
17502
17527
  const nonHashedChunksWithPlaceholders = [];
17503
17528
  const renderedChunksByPlaceholder = new Map();
17504
17529
  const hashDependenciesByPlaceholder = new Map();
@@ -17511,7 +17536,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
17511
17536
  const transformedChunk = {
17512
17537
  chunk,
17513
17538
  fileName,
17514
- ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, onwarn))
17539
+ ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
17515
17540
  };
17516
17541
  const { code } = transformedChunk;
17517
17542
  if (hashPlaceholder) {
@@ -17628,14 +17653,14 @@ class Bundle {
17628
17653
  const getHashPlaceholder = getHashPlaceholderGenerator();
17629
17654
  const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
17630
17655
  if (chunks.length > 1) {
17631
- validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
17656
+ validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onLog);
17632
17657
  }
17633
17658
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
17634
17659
  for (const chunk of chunks) {
17635
17660
  chunk.generateExports();
17636
17661
  }
17637
17662
  timeEnd('generate chunks', 2);
17638
- await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
17663
+ await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
17639
17664
  }
17640
17665
  catch (error_) {
17641
17666
  await this.pluginDriver.hookParallel('renderError', [error_]);
@@ -17698,7 +17723,7 @@ class Bundle {
17698
17723
  });
17699
17724
  }
17700
17725
  catch (error_) {
17701
- this.inputOptions.onwarn(errorChunkInvalid(file, error_));
17726
+ this.inputOptions.onLog(LOGLEVEL_WARN, logChunkInvalid(file, error_));
17702
17727
  }
17703
17728
  }
17704
17729
  }
@@ -17720,7 +17745,7 @@ class Bundle {
17720
17745
  ? [{ alias: null, modules: includedModules }]
17721
17746
  : preserveModules
17722
17747
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
17723
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
17748
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, this.inputOptions.onLog)) {
17724
17749
  sortByExecutionOrder(modules);
17725
17750
  const chunk = new Chunk(modules, this.inputOptions, this.outputOptions, this.unsetOptions, this.pluginDriver, this.graph.modulesById, chunkByModule, externalChunkByModule, this.facadeChunkByModule, this.includedNamespaces, alias, getHashPlaceholder, bundle, inputBase, snippets);
17726
17751
  chunks.push(chunk);
@@ -17735,15 +17760,15 @@ class Bundle {
17735
17760
  return [...chunks, ...facades];
17736
17761
  }
17737
17762
  }
17738
- function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
17763
+ function validateOptionsForMultiChunkOutput(outputOptions, log) {
17739
17764
  if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
17740
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17765
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17741
17766
  if (typeof outputOptions.file === 'string')
17742
- 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'));
17767
+ return error(logInvalidOption('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'));
17743
17768
  if (outputOptions.sourcemapFile)
17744
- return error(errorInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17769
+ return error(logInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17745
17770
  if (!outputOptions.amd.autoId && outputOptions.amd.id)
17746
- 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'));
17771
+ log(LOGLEVEL_WARN, logInvalidOption('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'));
17747
17772
  }
17748
17773
  function getIncludedModules(modulesById) {
17749
17774
  const includedModules = [];
@@ -17776,7 +17801,7 @@ function getExternalChunkByModule(modulesById, outputOptions, inputBase) {
17776
17801
  function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
17777
17802
  const existingAlias = manualChunkAliasByEntry.get(module);
17778
17803
  if (typeof existingAlias === 'string' && existingAlias !== alias) {
17779
- return error(errorCannotAssignModuleToChunk(module.id, alias, existingAlias));
17804
+ return error(logCannotAssignModuleToChunk(module.id, alias, existingAlias));
17780
17805
  }
17781
17806
  manualChunkAliasByEntry.set(module, alias);
17782
17807
  }
@@ -23560,9 +23585,9 @@ const NO_CACHE = {
23560
23585
  function uncacheablePluginError(pluginName) {
23561
23586
  if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
23562
23587
  pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
23563
- return error(errorAnonymousPluginCache());
23588
+ return error(logAnonymousPluginCache());
23564
23589
  }
23565
- return error(errorDuplicatePluginName(pluginName));
23590
+ return error(logDuplicatePluginName(pluginName));
23566
23591
  }
23567
23592
  function getCacheForUncacheablePlugin(pluginName) {
23568
23593
  return {
@@ -23581,7 +23606,154 @@ function getCacheForUncacheablePlugin(pluginName) {
23581
23606
  };
23582
23607
  }
23583
23608
 
23584
- async function transform(source, module, pluginDriver, warn) {
23609
+ async function asyncFlatten(array) {
23610
+ do {
23611
+ array = (await Promise.all(array)).flat(Infinity);
23612
+ } while (array.some((v) => v?.then));
23613
+ return array;
23614
+ }
23615
+
23616
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
23617
+ const { onwarn, onLog } = config;
23618
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
23619
+ if (onLog) {
23620
+ const minimalPriority = logLevelPriority[logLevel];
23621
+ return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
23622
+ if (level === LOGLEVEL_ERROR) {
23623
+ return error(normalizeLog(handledLog));
23624
+ }
23625
+ if (logLevelPriority[level] >= minimalPriority) {
23626
+ defaultOnLog(level, normalizeLog(handledLog));
23627
+ }
23628
+ });
23629
+ }
23630
+ return defaultOnLog;
23631
+ };
23632
+ const getDefaultOnLog = (printLog, onwarn) => onwarn
23633
+ ? (level, log) => {
23634
+ if (level === LOGLEVEL_WARN) {
23635
+ onwarn(addLogToString(log), warning => printLog(LOGLEVEL_WARN, normalizeLog(warning)));
23636
+ }
23637
+ else {
23638
+ printLog(level, log);
23639
+ }
23640
+ }
23641
+ : printLog;
23642
+ const addLogToString = (log) => {
23643
+ Object.defineProperty(log, 'toString', {
23644
+ value: () => getExtendedLogMessage(log),
23645
+ writable: true
23646
+ });
23647
+ return log;
23648
+ };
23649
+ const normalizeLog = (log) => typeof log === 'string'
23650
+ ? { message: log }
23651
+ : typeof log === 'function'
23652
+ ? normalizeLog(log())
23653
+ : log;
23654
+ const getExtendedLogMessage = (log) => {
23655
+ let prefix = '';
23656
+ if (log.plugin) {
23657
+ prefix += `(${log.plugin} plugin) `;
23658
+ }
23659
+ if (log.loc) {
23660
+ prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
23661
+ }
23662
+ return prefix + log.message;
23663
+ };
23664
+ const defaultPrintLog = (level, log) => {
23665
+ const message = getExtendedLogMessage(log);
23666
+ switch (level) {
23667
+ case LOGLEVEL_WARN: {
23668
+ return console.warn(message);
23669
+ }
23670
+ case LOGLEVEL_DEBUG: {
23671
+ return console.debug(message);
23672
+ }
23673
+ default: {
23674
+ return console.info(message);
23675
+ }
23676
+ }
23677
+ };
23678
+ function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
23679
+ const validOptionSet = new Set(validOptions);
23680
+ const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
23681
+ if (unknownOptions.length > 0) {
23682
+ log(LOGLEVEL_WARN, logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
23683
+ }
23684
+ }
23685
+ const treeshakePresets = {
23686
+ recommended: {
23687
+ annotations: true,
23688
+ correctVarValueBeforeDeclaration: false,
23689
+ manualPureFunctions: EMPTY_ARRAY,
23690
+ moduleSideEffects: () => true,
23691
+ propertyReadSideEffects: true,
23692
+ tryCatchDeoptimization: true,
23693
+ unknownGlobalSideEffects: false
23694
+ },
23695
+ safest: {
23696
+ annotations: true,
23697
+ correctVarValueBeforeDeclaration: true,
23698
+ manualPureFunctions: EMPTY_ARRAY,
23699
+ moduleSideEffects: () => true,
23700
+ propertyReadSideEffects: true,
23701
+ tryCatchDeoptimization: true,
23702
+ unknownGlobalSideEffects: true
23703
+ },
23704
+ smallest: {
23705
+ annotations: true,
23706
+ correctVarValueBeforeDeclaration: false,
23707
+ manualPureFunctions: EMPTY_ARRAY,
23708
+ moduleSideEffects: () => false,
23709
+ propertyReadSideEffects: false,
23710
+ tryCatchDeoptimization: false,
23711
+ unknownGlobalSideEffects: false
23712
+ }
23713
+ };
23714
+ const generatedCodePresets = {
23715
+ es2015: {
23716
+ arrowFunctions: true,
23717
+ constBindings: true,
23718
+ objectShorthand: true,
23719
+ reservedNamesAsProps: true,
23720
+ symbols: true
23721
+ },
23722
+ es5: {
23723
+ arrowFunctions: false,
23724
+ constBindings: false,
23725
+ objectShorthand: false,
23726
+ reservedNamesAsProps: true,
23727
+ symbols: false
23728
+ }
23729
+ };
23730
+ const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
23731
+ const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
23732
+ if (typeof value === 'string') {
23733
+ const preset = presets[value];
23734
+ if (preset) {
23735
+ return preset;
23736
+ }
23737
+ error(logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
23738
+ }
23739
+ return objectifyOption(value);
23740
+ };
23741
+ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
23742
+ const presetName = value?.preset;
23743
+ if (presetName) {
23744
+ const preset = presets[presetName];
23745
+ if (preset) {
23746
+ return { ...preset, ...value };
23747
+ }
23748
+ else {
23749
+ error(logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
23750
+ }
23751
+ }
23752
+ return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
23753
+ };
23754
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
23755
+
23756
+ async function transform(source, module, pluginDriver, log) {
23585
23757
  const id = module.id;
23586
23758
  const sourcemapChain = [];
23587
23759
  let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
@@ -23603,7 +23775,7 @@ async function transform(source, module, pluginDriver, warn) {
23603
23775
  module.updateOptions(result);
23604
23776
  if (result.code == null) {
23605
23777
  if (result.map || result.ast) {
23606
- warn(errorNoTransformMapOrAstWithoutCode(plugin.name));
23778
+ log(LOGLEVEL_WARN, logNoTransformMapOrAstWithoutCode(plugin.name));
23607
23779
  }
23608
23780
  return previousCode;
23609
23781
  }
@@ -23622,6 +23794,14 @@ async function transform(source, module, pluginDriver, warn) {
23622
23794
  }
23623
23795
  return code;
23624
23796
  }
23797
+ const getLogHandler = (handler) => (log, pos) => {
23798
+ log = normalizeLog(log);
23799
+ if (pos)
23800
+ augmentCodeLocation(log, pos, currentSource, id);
23801
+ log.id = id;
23802
+ log.hook = 'transform';
23803
+ handler(log);
23804
+ };
23625
23805
  let code;
23626
23806
  try {
23627
23807
  code = await pluginDriver.hookReduceArg0('transform', [currentSource, id], transformReducer, (pluginContext, plugin) => {
@@ -23635,6 +23815,7 @@ async function transform(source, module, pluginDriver, warn) {
23635
23815
  cache: customTransformCache
23636
23816
  ? pluginContext.cache
23637
23817
  : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
23818
+ debug: getLogHandler(pluginContext.debug),
23638
23819
  emitFile(emittedFile) {
23639
23820
  emittedFiles.push(emittedFile);
23640
23821
  return pluginDriver.emitFile(emittedFile);
@@ -23649,7 +23830,7 @@ async function transform(source, module, pluginDriver, warn) {
23649
23830
  return pluginContext.error(error_);
23650
23831
  },
23651
23832
  getCombinedSourcemap() {
23652
- const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
23833
+ const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log);
23653
23834
  if (!combinedMap) {
23654
23835
  const magicString = new MagicString(originalCode);
23655
23836
  return magicString.generateMap({ hires: true, includeContent: true, source: id });
@@ -23664,23 +23845,16 @@ async function transform(source, module, pluginDriver, warn) {
23664
23845
  sourcesContent: combinedMap.sourcesContent
23665
23846
  });
23666
23847
  },
23848
+ info: getLogHandler(pluginContext.info),
23667
23849
  setAssetSource() {
23668
- return this.error(errorInvalidSetAssetSourceCall());
23850
+ return this.error(logInvalidSetAssetSourceCall());
23669
23851
  },
23670
- warn(warning, pos) {
23671
- if (typeof warning === 'string')
23672
- warning = { message: warning };
23673
- if (pos)
23674
- augmentCodeLocation(warning, pos, currentSource, id);
23675
- warning.id = id;
23676
- warning.hook = 'transform';
23677
- pluginContext.warn(warning);
23678
- }
23852
+ warn: getLogHandler(pluginContext.warn)
23679
23853
  };
23680
23854
  });
23681
23855
  }
23682
23856
  catch (error_) {
23683
- return error(errorPluginError(error_, pluginName, { hook: 'transform', id }));
23857
+ return error(logPluginError(error_, pluginName, { hook: 'transform', id }));
23684
23858
  }
23685
23859
  if (!customTransformCache && // files emitted by a transform hook need to be emitted again if the hook is skipped
23686
23860
  emittedFiles.length > 0)
@@ -23806,7 +23980,7 @@ class ModuleLoader {
23806
23980
  ? { code: source }
23807
23981
  : source != null && typeof source === 'object' && typeof source.code === 'string'
23808
23982
  ? source
23809
- : error(errorBadLoader(id));
23983
+ : error(logBadLoader(id));
23810
23984
  const cachedModule = this.graph.cachedModules.get(id);
23811
23985
  if (cachedModule &&
23812
23986
  !cachedModule.customTransformCache &&
@@ -23830,7 +24004,7 @@ class ModuleLoader {
23830
24004
  }
23831
24005
  else {
23832
24006
  module.updateOptions(sourceDescription);
23833
- module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onwarn));
24007
+ module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onLog));
23834
24008
  }
23835
24009
  }
23836
24010
  async awaitLoadModulesPromise() {
@@ -23876,7 +24050,7 @@ class ModuleLoader {
23876
24050
  const existingModule = this.modulesById.get(id);
23877
24051
  if (existingModule instanceof Module) {
23878
24052
  if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
23879
- this.options.onwarn(errorInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
24053
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
23880
24054
  }
23881
24055
  await this.handleExistingModule(existingModule, isEntry, isPreload);
23882
24056
  return existingModule;
@@ -23925,10 +24099,10 @@ class ModuleLoader {
23925
24099
  this.modulesById.set(id, externalModule);
23926
24100
  }
23927
24101
  else if (!(externalModule instanceof ExternalModule)) {
23928
- return error(errorInternalIdCannotBeExternal(source, importer));
24102
+ return error(logInternalIdCannotBeExternal(source, importer));
23929
24103
  }
23930
24104
  else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
23931
- this.options.onwarn(errorInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
24105
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
23932
24106
  }
23933
24107
  return Promise.resolve(externalModule);
23934
24108
  }
@@ -24038,9 +24212,9 @@ class ModuleLoader {
24038
24212
  handleInvalidResolvedId(resolvedId, source, importer, assertions) {
24039
24213
  if (resolvedId === null) {
24040
24214
  if (isRelative(source)) {
24041
- return error(errorUnresolvedImport(source, importer));
24215
+ return error(logUnresolvedImport(source, importer));
24042
24216
  }
24043
- this.options.onwarn(errorUnresolvedImportTreatedAsExternal(source, importer));
24217
+ this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer));
24044
24218
  return {
24045
24219
  assertions,
24046
24220
  external: true,
@@ -24052,7 +24226,7 @@ class ModuleLoader {
24052
24226
  };
24053
24227
  }
24054
24228
  else if (resolvedId.external && resolvedId.syntheticNamedExports) {
24055
- this.options.onwarn(errorExternalSyntheticExports(source, importer));
24229
+ this.options.onLog(LOGLEVEL_WARN, logExternalSyntheticExports(source, importer));
24056
24230
  }
24057
24231
  return resolvedId;
24058
24232
  }
@@ -24060,14 +24234,14 @@ class ModuleLoader {
24060
24234
  const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
24061
24235
  if (resolveIdResult == null) {
24062
24236
  return error(implicitlyLoadedBefore === null
24063
- ? errorUnresolvedEntry(unresolvedId)
24064
- : errorUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
24237
+ ? logUnresolvedEntry(unresolvedId)
24238
+ : logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
24065
24239
  }
24066
24240
  if (resolveIdResult === false ||
24067
24241
  (typeof resolveIdResult === 'object' && resolveIdResult.external)) {
24068
24242
  return error(implicitlyLoadedBefore === null
24069
- ? errorEntryCannotBeExternal(unresolvedId)
24070
- : errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
24243
+ ? logEntryCannotBeExternal(unresolvedId)
24244
+ : logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
24071
24245
  }
24072
24246
  return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
24073
24247
  ? resolveIdResult
@@ -24092,7 +24266,7 @@ class ModuleLoader {
24092
24266
  const existingResolution = module.resolvedIds[specifier];
24093
24267
  if (existingResolution) {
24094
24268
  if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
24095
- this.options.onwarn(errorInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
24269
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
24096
24270
  }
24097
24271
  return existingResolution;
24098
24272
  }
@@ -24160,9 +24334,9 @@ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle)
24160
24334
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
24161
24335
  }), bundle);
24162
24336
  }
24163
- function reserveFileNameInBundle(fileName, { bundle }, warn) {
24337
+ function reserveFileNameInBundle(fileName, { bundle }, log) {
24164
24338
  if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
24165
- warn(errorFileNameConflict(fileName));
24339
+ log(LOGLEVEL_WARN, logFileNameConflict(fileName));
24166
24340
  }
24167
24341
  else {
24168
24342
  bundle[fileName] = FILE_PLACEHOLDER;
@@ -24180,13 +24354,13 @@ function hasValidName(emittedFile) {
24180
24354
  function getValidSource(source, emittedFile, fileReferenceId) {
24181
24355
  if (!(typeof source === 'string' || source instanceof Uint8Array)) {
24182
24356
  const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
24183
- return error(errorFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
24357
+ return error(logFailedValidation(`Could not set source for ${typeof assetName === 'string' ? `asset "${assetName}"` : 'unnamed asset'}, asset source needs to be a string, Uint8Array or Buffer.`));
24184
24358
  }
24185
24359
  return source;
24186
24360
  }
24187
24361
  function getAssetFileName(file, referenceId) {
24188
24362
  if (typeof file.fileName !== 'string') {
24189
- return error(errorAssetNotFinalisedForFileName(file.name || referenceId));
24363
+ return error(logAssetNotFinalisedForFileName(file.name || referenceId));
24190
24364
  }
24191
24365
  return file.fileName;
24192
24366
  }
@@ -24197,7 +24371,7 @@ function getChunkFileName(file, facadeChunkByModule) {
24197
24371
  if (facadeChunkByModule) {
24198
24372
  return facadeChunkByModule.get(file.module).getFileName();
24199
24373
  }
24200
- return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
24374
+ return error(logChunkNotGeneratedForFileName(file.fileName || file.name));
24201
24375
  }
24202
24376
  class FileEmitter {
24203
24377
  constructor(graph, options, baseFileEmitter) {
@@ -24209,13 +24383,13 @@ class FileEmitter {
24209
24383
  this.outputFileEmitters = [];
24210
24384
  this.emitFile = (emittedFile) => {
24211
24385
  if (!hasValidType(emittedFile)) {
24212
- return error(errorFailedValidation(`Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${emittedFile && emittedFile.type}".`));
24386
+ return error(logFailedValidation(`Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${emittedFile && emittedFile.type}".`));
24213
24387
  }
24214
24388
  if (emittedFile.type === 'prebuilt-chunk') {
24215
24389
  return this.emitPrebuiltChunk(emittedFile);
24216
24390
  }
24217
24391
  if (!hasValidName(emittedFile)) {
24218
- return error(errorFailedValidation(`The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
24392
+ return error(logFailedValidation(`The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "${emittedFile.fileName || emittedFile.name}".`));
24219
24393
  }
24220
24394
  if (emittedFile.type === 'chunk') {
24221
24395
  return this.emitChunk(emittedFile);
@@ -24225,13 +24399,13 @@ class FileEmitter {
24225
24399
  this.finaliseAssets = () => {
24226
24400
  for (const [referenceId, emittedFile] of this.filesByReferenceId) {
24227
24401
  if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
24228
- return error(errorNoAssetSourceSet(emittedFile.name || referenceId));
24402
+ return error(logNoAssetSourceSet(emittedFile.name || referenceId));
24229
24403
  }
24230
24404
  };
24231
24405
  this.getFileName = (fileReferenceId) => {
24232
24406
  const emittedFile = this.filesByReferenceId.get(fileReferenceId);
24233
24407
  if (!emittedFile)
24234
- return error(errorFileReferenceIdNotFoundForFilename(fileReferenceId));
24408
+ return error(logFileReferenceIdNotFoundForFilename(fileReferenceId));
24235
24409
  if (emittedFile.type === 'chunk') {
24236
24410
  return getChunkFileName(emittedFile, this.facadeChunkByModule);
24237
24411
  }
@@ -24243,12 +24417,12 @@ class FileEmitter {
24243
24417
  this.setAssetSource = (referenceId, requestedSource) => {
24244
24418
  const consumedFile = this.filesByReferenceId.get(referenceId);
24245
24419
  if (!consumedFile)
24246
- return error(errorAssetReferenceIdNotFoundForSetSource(referenceId));
24420
+ return error(logAssetReferenceIdNotFoundForSetSource(referenceId));
24247
24421
  if (consumedFile.type !== 'asset') {
24248
- return error(errorFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
24422
+ return error(logFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
24249
24423
  }
24250
24424
  if (consumedFile.source !== undefined) {
24251
- return error(errorAssetSourceAlreadySet(consumedFile.name || referenceId));
24425
+ return error(logAssetSourceAlreadySet(consumedFile.name || referenceId));
24252
24426
  }
24253
24427
  const source = getValidSource(requestedSource, consumedFile, referenceId);
24254
24428
  if (this.output) {
@@ -24272,7 +24446,7 @@ class FileEmitter {
24272
24446
  });
24273
24447
  for (const emittedFile of this.filesByReferenceId.values()) {
24274
24448
  if (emittedFile.fileName) {
24275
- reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
24449
+ reserveFileNameInBundle(emittedFile.fileName, output, this.options.onLog);
24276
24450
  }
24277
24451
  }
24278
24452
  const consumedAssetsByHash = new Map();
@@ -24362,7 +24536,7 @@ class FileEmitter {
24362
24536
  emitAssetWithReferenceId(consumedAsset, output) {
24363
24537
  const { fileName, source } = consumedAsset;
24364
24538
  if (fileName) {
24365
- reserveFileNameInBundle(fileName, output, this.options.onwarn);
24539
+ reserveFileNameInBundle(fileName, output, this.options.onLog);
24366
24540
  }
24367
24541
  if (source !== undefined) {
24368
24542
  this.finalizeAdditionalAsset(consumedAsset, source, output);
@@ -24370,10 +24544,10 @@ class FileEmitter {
24370
24544
  }
24371
24545
  emitChunk(emittedChunk) {
24372
24546
  if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
24373
- return error(errorInvalidRollupPhaseForChunkEmission());
24547
+ return error(logInvalidRollupPhaseForChunkEmission());
24374
24548
  }
24375
24549
  if (typeof emittedChunk.id !== 'string') {
24376
- return error(errorFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
24550
+ return error(logFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
24377
24551
  }
24378
24552
  const consumedChunk = {
24379
24553
  fileName: emittedChunk.fileName,
@@ -24393,11 +24567,11 @@ class FileEmitter {
24393
24567
  }
24394
24568
  emitPrebuiltChunk(emitPrebuiltChunk) {
24395
24569
  if (typeof emitPrebuiltChunk.code !== 'string') {
24396
- return error(errorFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`));
24570
+ return error(logFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`));
24397
24571
  }
24398
24572
  if (typeof emitPrebuiltChunk.fileName !== 'string' ||
24399
24573
  isPathFragment(emitPrebuiltChunk.fileName)) {
24400
- return error(errorFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`));
24574
+ return error(logFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`));
24401
24575
  }
24402
24576
  const consumedPrebuiltChunk = {
24403
24577
  code: emitPrebuiltChunk.code,
@@ -24472,7 +24646,26 @@ class FileEmitter {
24472
24646
  }
24473
24647
  }
24474
24648
 
24649
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
24650
+ if (logLevelPriority[level] < logLevelPriority[logLevel]) {
24651
+ return doNothing;
24652
+ }
24653
+ return (log, pos) => {
24654
+ if (pos != null) {
24655
+ logger(LOGLEVEL_WARN, logInvalidLogPosition(pluginName));
24656
+ }
24657
+ log = normalizeLog(log);
24658
+ if (log.code && !log.pluginCode) {
24659
+ log.pluginCode = log.code;
24660
+ }
24661
+ log.code = code;
24662
+ log.plugin = pluginName;
24663
+ logger(level, log);
24664
+ };
24665
+ }
24666
+
24475
24667
  function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
24668
+ const { logLevel, onLog } = options;
24476
24669
  let cacheable = true;
24477
24670
  if (typeof plugin.cacheKey !== 'string') {
24478
24671
  if (plugin.name.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
@@ -24498,19 +24691,21 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
24498
24691
  return {
24499
24692
  addWatchFile(id) {
24500
24693
  if (graph.phase >= BuildPhase.GENERATE) {
24501
- return this.error(errorInvalidRollupPhaseForAddWatchFile());
24694
+ return this.error(logInvalidRollupPhaseForAddWatchFile());
24502
24695
  }
24503
24696
  graph.watchFiles[id] = true;
24504
24697
  },
24505
24698
  cache: cacheInstance,
24699
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
24506
24700
  emitFile: fileEmitter.emitFile.bind(fileEmitter),
24507
24701
  error(error_) {
24508
- return error(errorPluginError(error_, plugin.name));
24702
+ return error(logPluginError(normalizeLog(error_), plugin.name));
24509
24703
  },
24510
24704
  getFileName: fileEmitter.getFileName,
24511
24705
  getModuleIds: () => graph.modulesById.keys(),
24512
24706
  getModuleInfo: graph.getModuleInfo,
24513
24707
  getWatchFiles: () => Object.keys(graph.watchFiles),
24708
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
24514
24709
  load(resolvedId) {
24515
24710
  return graph.moduleLoader.preloadModule(resolvedId);
24516
24711
  },
@@ -24532,15 +24727,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
24532
24727
  return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
24533
24728
  },
24534
24729
  setAssetSource: fileEmitter.setAssetSource,
24535
- warn(warning) {
24536
- if (typeof warning === 'string')
24537
- warning = { message: warning };
24538
- if (warning.code)
24539
- warning.pluginCode = warning.code;
24540
- warning.code = 'PLUGIN_WARNING';
24541
- warning.plugin = plugin.name;
24542
- options.onwarn(warning);
24543
- }
24730
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
24544
24731
  };
24545
24732
  }
24546
24733
 
@@ -24552,6 +24739,7 @@ const inputHookNames = {
24552
24739
  closeWatcher: 1,
24553
24740
  load: 1,
24554
24741
  moduleParsed: 1,
24742
+ onLog: 1,
24555
24743
  options: 1,
24556
24744
  resolveDynamicImport: 1,
24557
24745
  resolveId: 1,
@@ -24583,7 +24771,7 @@ class PluginDriver {
24583
24771
  for (const plugin of userPlugins) {
24584
24772
  for (const hook of inputHooks) {
24585
24773
  if (hook in plugin) {
24586
- options.onwarn(errorInputHookInOutputPlugin(plugin.name, hook));
24774
+ options.onLog(LOGLEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
24587
24775
  }
24588
24776
  }
24589
24777
  }
@@ -24730,7 +24918,7 @@ class PluginDriver {
24730
24918
  // action considered to be fulfilled since error being handled
24731
24919
  this.unfulfilledActions.delete(action);
24732
24920
  }
24733
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24921
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24734
24922
  });
24735
24923
  }
24736
24924
  /**
@@ -24752,7 +24940,7 @@ class PluginDriver {
24752
24940
  return handler.apply(context, parameters);
24753
24941
  }
24754
24942
  catch (error_) {
24755
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24943
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24756
24944
  }
24757
24945
  }
24758
24946
  }
@@ -24784,12 +24972,12 @@ function getSortedValidatedPlugins(hookName, plugins, validateHandler = validate
24784
24972
  }
24785
24973
  function validateFunctionPluginHandler(handler, hookName, plugin) {
24786
24974
  if (typeof handler !== 'function') {
24787
- error(errorInvalidFunctionPluginHook(hookName, plugin.name));
24975
+ error(logInvalidFunctionPluginHook(hookName, plugin.name));
24788
24976
  }
24789
24977
  }
24790
24978
  function validateAddonPluginHandler(handler, hookName, plugin) {
24791
24979
  if (typeof handler !== 'string' && typeof handler !== 'function') {
24792
- return error(errorInvalidAddonPluginHook(hookName, plugin.name));
24980
+ return error(logInvalidAddonPluginHook(hookName, plugin.name));
24793
24981
  }
24794
24982
  }
24795
24983
  function noReturn() { }
@@ -25001,7 +25189,7 @@ class Graph {
25001
25189
  for (const module of this.implicitEntryModules) {
25002
25190
  for (const dependant of module.implicitlyLoadedAfter) {
25003
25191
  if (!(dependant.info.isEntry || dependant.isIncluded())) {
25004
- error(errorImplicitDependantIsNotIncluded(dependant));
25192
+ error(logImplicitDependantIsNotIncluded(dependant));
25005
25193
  }
25006
25194
  }
25007
25195
  }
@@ -25009,7 +25197,7 @@ class Graph {
25009
25197
  sortModules() {
25010
25198
  const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
25011
25199
  for (const cyclePath of cyclePaths) {
25012
- this.options.onwarn(errorCircularDependency(cyclePath));
25200
+ this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath));
25013
25201
  }
25014
25202
  this.modules = orderedModules;
25015
25203
  for (const module of this.modules) {
@@ -25022,7 +25210,7 @@ class Graph {
25022
25210
  for (const importDescription of module.importDescriptions.values()) {
25023
25211
  if (importDescription.name !== '*' &&
25024
25212
  !importDescription.module.getVariableForExportName(importDescription.name)[0]) {
25025
- module.warn(errorMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
25213
+ module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
25026
25214
  }
25027
25215
  }
25028
25216
  }
@@ -25081,6 +25269,40 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
25081
25269
  }
25082
25270
  }
25083
25271
 
25272
+ function getLogger(plugins, onLog, watchMode, logLevel) {
25273
+ plugins = getSortedValidatedPlugins('onLog', plugins);
25274
+ const minimalPriority = logLevelPriority[logLevel];
25275
+ const logger = (level, log, skipped = EMPTY_SET) => {
25276
+ const logPriority = logLevelPriority[level];
25277
+ if (logPriority < minimalPriority) {
25278
+ return;
25279
+ }
25280
+ for (const plugin of plugins) {
25281
+ if (skipped.has(plugin))
25282
+ continue;
25283
+ const { onLog: pluginOnLog } = plugin;
25284
+ const getLogHandler = (level) => {
25285
+ if (logLevelPriority[level] < minimalPriority) {
25286
+ return doNothing;
25287
+ }
25288
+ return log => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
25289
+ };
25290
+ const handler = 'handler' in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
25291
+ if (handler.call({
25292
+ debug: getLogHandler(LOGLEVEL_DEBUG),
25293
+ error: (log) => error(normalizeLog(log)),
25294
+ info: getLogHandler(LOGLEVEL_INFO),
25295
+ meta: { rollupVersion: version$1, watchMode },
25296
+ warn: getLogHandler(LOGLEVEL_WARN)
25297
+ }, level, log) === false) {
25298
+ return;
25299
+ }
25300
+ }
25301
+ onLog(level, log);
25302
+ };
25303
+ return logger;
25304
+ }
25305
+
25084
25306
  const leftCurlyBrace = "{".charCodeAt(0);
25085
25307
  const space = " ".charCodeAt(0);
25086
25308
 
@@ -25332,100 +25554,16 @@ function ensureArray(items) {
25332
25554
  return [];
25333
25555
  }
25334
25556
 
25335
- async function asyncFlatten(array) {
25336
- do {
25337
- array = (await Promise.all(array)).flat(Infinity);
25338
- } while (array.some((v) => v?.then));
25339
- return array;
25340
- }
25341
-
25342
- const defaultOnWarn = warning => console.warn(warning.message || warning);
25343
- function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
25344
- const validOptionSet = new Set(validOptions);
25345
- const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
25346
- if (unknownOptions.length > 0) {
25347
- warn(errorUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
25348
- }
25349
- }
25350
- const treeshakePresets = {
25351
- recommended: {
25352
- annotations: true,
25353
- correctVarValueBeforeDeclaration: false,
25354
- manualPureFunctions: EMPTY_ARRAY,
25355
- moduleSideEffects: () => true,
25356
- propertyReadSideEffects: true,
25357
- tryCatchDeoptimization: true,
25358
- unknownGlobalSideEffects: false
25359
- },
25360
- safest: {
25361
- annotations: true,
25362
- correctVarValueBeforeDeclaration: true,
25363
- manualPureFunctions: EMPTY_ARRAY,
25364
- moduleSideEffects: () => true,
25365
- propertyReadSideEffects: true,
25366
- tryCatchDeoptimization: true,
25367
- unknownGlobalSideEffects: true
25368
- },
25369
- smallest: {
25370
- annotations: true,
25371
- correctVarValueBeforeDeclaration: false,
25372
- manualPureFunctions: EMPTY_ARRAY,
25373
- moduleSideEffects: () => false,
25374
- propertyReadSideEffects: false,
25375
- tryCatchDeoptimization: false,
25376
- unknownGlobalSideEffects: false
25377
- }
25378
- };
25379
- const generatedCodePresets = {
25380
- es2015: {
25381
- arrowFunctions: true,
25382
- constBindings: true,
25383
- objectShorthand: true,
25384
- reservedNamesAsProps: true,
25385
- symbols: true
25386
- },
25387
- es5: {
25388
- arrowFunctions: false,
25389
- constBindings: false,
25390
- objectShorthand: false,
25391
- reservedNamesAsProps: true,
25392
- symbols: false
25393
- }
25394
- };
25395
- const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
25396
- const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
25397
- if (typeof value === 'string') {
25398
- const preset = presets[value];
25399
- if (preset) {
25400
- return preset;
25401
- }
25402
- error(errorInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
25403
- }
25404
- return objectifyOption(value);
25405
- };
25406
- const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
25407
- const presetName = value?.preset;
25408
- if (presetName) {
25409
- const preset = presets[presetName];
25410
- if (preset) {
25411
- return { ...preset, ...value };
25412
- }
25413
- else {
25414
- error(errorInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
25415
- }
25416
- }
25417
- return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
25418
- };
25419
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
25420
-
25421
- async function normalizeInputOptions(config) {
25557
+ async function normalizeInputOptions(config, watchMode) {
25422
25558
  // These are options that may trigger special warnings or behaviour later
25423
25559
  // if the user did not select an explicit value
25424
25560
  const unsetOptions = new Set();
25425
25561
  const context = config.context ?? 'undefined';
25426
- const onwarn = getOnwarn(config);
25562
+ const plugins = await normalizePluginOption(config.plugins);
25563
+ const logLevel = config.logLevel || LOGLEVEL_INFO;
25564
+ const onLog = getLogger(plugins, getOnLog(config, logLevel), watchMode, logLevel);
25427
25565
  const strictDeprecations = config.strictDeprecations || false;
25428
- const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
25566
+ const maxParallelFileOps = getMaxParallelFileOps(config, onLog, strictDeprecations);
25429
25567
  const options = {
25430
25568
  acorn: getAcorn(config),
25431
25569
  acornInjectPlugins: getAcornInjectPlugins(config),
@@ -25434,43 +25572,28 @@ async function normalizeInputOptions(config) {
25434
25572
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
25435
25573
  experimentalLogSideEffects: config.experimentalLogSideEffects || false,
25436
25574
  external: getIdMatcher(config.external),
25437
- inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
25575
+ inlineDynamicImports: getInlineDynamicImports$1(config, onLog, strictDeprecations),
25438
25576
  input: getInput(config),
25577
+ logLevel,
25439
25578
  makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
25440
- manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
25579
+ manualChunks: getManualChunks$1(config, onLog, strictDeprecations),
25441
25580
  maxParallelFileOps,
25442
25581
  maxParallelFileReads: maxParallelFileOps,
25443
25582
  moduleContext: getModuleContext(config, context),
25444
- onwarn,
25583
+ onLog,
25584
+ onwarn: warning => onLog(LOGLEVEL_WARN, warning),
25445
25585
  perf: config.perf || false,
25446
- plugins: await normalizePluginOption(config.plugins),
25586
+ plugins,
25447
25587
  preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
25448
- preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
25588
+ preserveModules: getPreserveModules$1(config, onLog, strictDeprecations),
25449
25589
  preserveSymlinks: config.preserveSymlinks || false,
25450
25590
  shimMissingExports: config.shimMissingExports || false,
25451
25591
  strictDeprecations,
25452
25592
  treeshake: getTreeshake(config)
25453
25593
  };
25454
- warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', options.onwarn, /^(output)$/);
25594
+ warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', onLog, /^(output)$/);
25455
25595
  return { options, unsetOptions };
25456
25596
  }
25457
- const getOnwarn = (config) => {
25458
- const { onwarn } = config;
25459
- return onwarn
25460
- ? warning => {
25461
- warning.toString = () => {
25462
- let warningString = '';
25463
- if (warning.plugin)
25464
- warningString += `(${warning.plugin} plugin) `;
25465
- if (warning.loc)
25466
- warningString += `${relativeId(warning.loc.file)} (${warning.loc.line}:${warning.loc.column}) `;
25467
- warningString += warning.message;
25468
- return warningString;
25469
- };
25470
- onwarn(warning, defaultOnWarn);
25471
- }
25472
- : defaultOnWarn;
25473
- };
25474
25597
  const getAcorn = (config) => ({
25475
25598
  ecmaVersion: 'latest',
25476
25599
  sourceType: 'module',
@@ -25505,10 +25628,10 @@ const getIdMatcher = (option) => {
25505
25628
  }
25506
25629
  return () => false;
25507
25630
  };
25508
- const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
25631
+ const getInlineDynamicImports$1 = (config, log, strictDeprecations) => {
25509
25632
  const configInlineDynamicImports = config.inlineDynamicImports;
25510
25633
  if (configInlineDynamicImports) {
25511
- warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, warn, strictDeprecations);
25634
+ warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, log, strictDeprecations);
25512
25635
  }
25513
25636
  return configInlineDynamicImports;
25514
25637
  };
@@ -25516,17 +25639,17 @@ const getInput = (config) => {
25516
25639
  const configInput = config.input;
25517
25640
  return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput;
25518
25641
  };
25519
- const getManualChunks$1 = (config, warn, strictDeprecations) => {
25642
+ const getManualChunks$1 = (config, log, strictDeprecations) => {
25520
25643
  const configManualChunks = config.manualChunks;
25521
25644
  if (configManualChunks) {
25522
- warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, warn, strictDeprecations);
25645
+ warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, log, strictDeprecations);
25523
25646
  }
25524
25647
  return configManualChunks;
25525
25648
  };
25526
- const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
25649
+ const getMaxParallelFileOps = (config, log, strictDeprecations) => {
25527
25650
  const maxParallelFileReads = config.maxParallelFileReads;
25528
25651
  if (typeof maxParallelFileReads === 'number') {
25529
- warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, warn, strictDeprecations);
25652
+ warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, log, strictDeprecations);
25530
25653
  }
25531
25654
  const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
25532
25655
  if (typeof maxParallelFileOps === 'number') {
@@ -25550,10 +25673,10 @@ const getModuleContext = (config, context) => {
25550
25673
  }
25551
25674
  return () => context;
25552
25675
  };
25553
- const getPreserveModules$1 = (config, warn, strictDeprecations) => {
25676
+ const getPreserveModules$1 = (config, log, strictDeprecations) => {
25554
25677
  const configPreserveModules = config.preserveModules;
25555
25678
  if (configPreserveModules) {
25556
- warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, warn, strictDeprecations);
25679
+ warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, log, strictDeprecations);
25557
25680
  }
25558
25681
  return configPreserveModules;
25559
25682
  };
@@ -25590,7 +25713,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption) => {
25590
25713
  return id => ids.has(id);
25591
25714
  }
25592
25715
  if (moduleSideEffectsOption) {
25593
- error(errorInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
25716
+ error(logInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
25594
25717
  }
25595
25718
  return () => true;
25596
25719
  };
@@ -25676,17 +25799,17 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
25676
25799
  systemNullSetters: config.systemNullSetters ?? true,
25677
25800
  validate: config.validate || false
25678
25801
  };
25679
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
25802
+ warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onLog);
25680
25803
  return { options: outputOptions, unsetOptions };
25681
25804
  }
25682
25805
  const getFile = (config, preserveModules, inputOptions) => {
25683
25806
  const { file } = config;
25684
25807
  if (typeof file === 'string') {
25685
25808
  if (preserveModules) {
25686
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25809
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25687
25810
  }
25688
25811
  if (!Array.isArray(inputOptions.input))
25689
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25812
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25690
25813
  }
25691
25814
  return file;
25692
25815
  };
@@ -25713,7 +25836,7 @@ const getFormat = (config) => {
25713
25836
  return configFormat;
25714
25837
  }
25715
25838
  default: {
25716
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25839
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25717
25840
  }
25718
25841
  }
25719
25842
  };
@@ -25721,7 +25844,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
25721
25844
  const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
25722
25845
  const { input } = inputOptions;
25723
25846
  if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
25724
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25847
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25725
25848
  }
25726
25849
  return inlineDynamicImports;
25727
25850
  };
@@ -25729,10 +25852,10 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
25729
25852
  const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
25730
25853
  if (preserveModules) {
25731
25854
  if (inlineDynamicImports) {
25732
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25855
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25733
25856
  }
25734
25857
  if (inputOptions.preserveEntrySignatures === false) {
25735
- return error(errorInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25858
+ return error(logInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25736
25859
  }
25737
25860
  }
25738
25861
  return preserveModules;
@@ -25760,10 +25883,10 @@ const getAmd = (config) => {
25760
25883
  ...config.amd
25761
25884
  };
25762
25885
  if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
25763
- return error(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25886
+ return error(logInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25764
25887
  }
25765
25888
  if (mergedOption.basePath && !mergedOption.autoId) {
25766
- return error(errorInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25889
+ return error(logInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25767
25890
  }
25768
25891
  return mergedOption.autoId
25769
25892
  ? {
@@ -25790,7 +25913,7 @@ const getAddon = (config, name) => {
25790
25913
  const getDir = (config, file) => {
25791
25914
  const { dir } = config;
25792
25915
  if (typeof dir === 'string' && typeof file === 'string') {
25793
- 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'));
25916
+ return error(logInvalidOption('output.dir', URL_OUTPUT_DIR, 'you must set either "output.file" for a single-file build or "output.dir" when generating multiple chunks'));
25794
25917
  }
25795
25918
  return dir;
25796
25919
  };
@@ -25799,7 +25922,7 @@ const getDynamicImportFunction = (config, inputOptions, format) => {
25799
25922
  if (configDynamicImportFunction) {
25800
25923
  warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, URL_RENDERDYNAMICIMPORT, true, inputOptions);
25801
25924
  if (format !== 'es') {
25802
- inputOptions.onwarn(errorInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25925
+ inputOptions.onLog(LOGLEVEL_WARN, logInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25803
25926
  }
25804
25927
  }
25805
25928
  return configDynamicImportFunction;
@@ -25824,7 +25947,7 @@ function getExports(config, unsetOptions) {
25824
25947
  unsetOptions.add('exports');
25825
25948
  }
25826
25949
  else if (!['default', 'named', 'none', 'auto'].includes(configExports)) {
25827
- return error(errorInvalidExportOptionValue(configExports));
25950
+ return error(logInvalidExportOptionValue(configExports));
25828
25951
  }
25829
25952
  return configExports || 'auto';
25830
25953
  }
@@ -25867,7 +25990,7 @@ const getInterop = (config) => {
25867
25990
  };
25868
25991
  const validateInterop = (interop) => {
25869
25992
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
25870
- return error(errorInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25993
+ return error(logInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25871
25994
  // eslint-disable-next-line unicorn/prefer-spread
25872
25995
  `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
25873
25996
  }
@@ -25877,10 +26000,10 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
25877
26000
  const configManualChunks = config.manualChunks || inputOptions.manualChunks;
25878
26001
  if (configManualChunks) {
25879
26002
  if (inlineDynamicImports) {
25880
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
26003
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
25881
26004
  }
25882
26005
  if (preserveModules) {
25883
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
26006
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
25884
26007
  }
25885
26008
  }
25886
26009
  return configManualChunks || {};
@@ -25900,7 +26023,7 @@ const getSourcemapBaseUrl = (config) => {
25900
26023
  if (isValidUrl(sourcemapBaseUrl)) {
25901
26024
  return addTrailingSlashIfMissed(sourcemapBaseUrl);
25902
26025
  }
25903
- return error(errorInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
26026
+ return error(logInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
25904
26027
  }
25905
26028
  };
25906
26029
 
@@ -25948,13 +26071,13 @@ async function rollupInternal(rawInputOptions, watcher) {
25948
26071
  closed: false,
25949
26072
  async generate(rawOutputOptions) {
25950
26073
  if (result.closed)
25951
- return error(errorAlreadyClosed());
26074
+ return error(logAlreadyClosed());
25952
26075
  return handleGenerateWrite(false, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25953
26076
  },
25954
26077
  watchFiles: Object.keys(graph.watchFiles),
25955
26078
  async write(rawOutputOptions) {
25956
26079
  if (result.closed)
25957
- return error(errorAlreadyClosed());
26080
+ return error(logAlreadyClosed());
25958
26081
  return handleGenerateWrite(true, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25959
26082
  }
25960
26083
  };
@@ -25962,21 +26085,34 @@ async function rollupInternal(rawInputOptions, watcher) {
25962
26085
  result.getTimings = getTimings;
25963
26086
  return result;
25964
26087
  }
25965
- async function getInputOptions(rawInputOptions, watchMode) {
25966
- if (!rawInputOptions) {
26088
+ async function getInputOptions(initialInputOptions, watchMode) {
26089
+ if (!initialInputOptions) {
25967
26090
  throw new Error('You must supply an options object to rollup');
25968
26091
  }
25969
- const rawPlugins = getSortedValidatedPlugins('options', await normalizePluginOption(rawInputOptions.plugins));
25970
- const { options, unsetOptions } = await normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
26092
+ const processedInputOptions = await getProcessedInputOptions(initialInputOptions, watchMode);
26093
+ const { options, unsetOptions } = await normalizeInputOptions(processedInputOptions, watchMode);
25971
26094
  normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
25972
26095
  return { options, unsetOptions };
25973
26096
  }
25974
- function applyOptionHook(watchMode) {
25975
- return async (inputOptions, plugin) => {
25976
- const handler = 'handler' in plugin.options ? plugin.options.handler : plugin.options;
25977
- return ((await handler.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) ||
25978
- inputOptions);
25979
- };
26097
+ async function getProcessedInputOptions(inputOptions, watchMode) {
26098
+ const plugins = getSortedValidatedPlugins('options', await normalizePluginOption(inputOptions.plugins));
26099
+ const logLevel = inputOptions.logLevel || LOGLEVEL_INFO;
26100
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), watchMode, logLevel);
26101
+ for (const plugin of plugins) {
26102
+ const { name, options } = plugin;
26103
+ const handler = 'handler' in options ? options.handler : options;
26104
+ const processedOptions = await handler.call({
26105
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel),
26106
+ error: (error_) => error(logPluginError(normalizeLog(error_), name, { hook: 'onLog' })),
26107
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel),
26108
+ meta: { rollupVersion: version$1, watchMode },
26109
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel)
26110
+ }, inputOptions);
26111
+ if (processedOptions) {
26112
+ inputOptions = processedOptions;
26113
+ }
26114
+ }
26115
+ return inputOptions;
25980
26116
  }
25981
26117
  function normalizePlugins(plugins, anonymousPrefix) {
25982
26118
  for (const [index, plugin] of plugins.entries()) {
@@ -25993,7 +26129,7 @@ async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, raw
25993
26129
  if (isWrite) {
25994
26130
  timeStart('WRITE', 1);
25995
26131
  if (!outputOptions.dir && !outputOptions.file) {
25996
- return error(errorMissingFileOrDirOption());
26132
+ return error(logMissingFileOrDirOption());
25997
26133
  }
25998
26134
  await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
25999
26135
  await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
@@ -26016,7 +26152,7 @@ async function getOutputOptionsAndPluginDriver(rawOutputOptions, inputPluginDriv
26016
26152
  }
26017
26153
  function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, outputPluginDriver) {
26018
26154
  return normalizeOutputOptions(outputPluginDriver.hookReduceArg0Sync('outputOptions', [rawOutputOptions], (outputOptions, result) => result || outputOptions, pluginContext => {
26019
- const emitError = () => pluginContext.error(errorCannotEmitFromOptionsHook());
26155
+ const emitError = () => pluginContext.error(logCannotEmitFromOptionsHook());
26020
26156
  return {
26021
26157
  ...pluginContext,
26022
26158
  emitFile: emitError,
@@ -26052,7 +26188,8 @@ async function writeOutputFile(outputFile, outputOptions) {
26052
26188
  }
26053
26189
  /**
26054
26190
  * Auxiliary function for defining rollup configuration
26055
- * Mainly to facilitate IDE code prompts, after all, export default does not prompt, even if you add @type annotations, it is not accurate
26191
+ * Mainly to facilitate IDE code prompts, after all, export default does not
26192
+ * prompt, even if you add @type annotations, it is not accurate
26056
26193
  * @param options
26057
26194
  */
26058
26195
  function defineConfig(options) {
@@ -26217,17 +26354,20 @@ const commandAliases = {
26217
26354
  w: 'watch'
26218
26355
  };
26219
26356
  const EMPTY_COMMAND_OPTIONS = { external: [], globals: undefined };
26220
- async function mergeOptions(config, rawCommandOptions = EMPTY_COMMAND_OPTIONS, defaultOnWarnHandler = defaultOnWarn) {
26357
+ async function mergeOptions(config, watchMode, rawCommandOptions = EMPTY_COMMAND_OPTIONS, printLog) {
26221
26358
  const command = getCommandOptions(rawCommandOptions);
26222
- const inputOptions = await mergeInputOptions(config, command, defaultOnWarnHandler);
26223
- const warn = inputOptions.onwarn;
26359
+ const plugins = await normalizePluginOption(config.plugins);
26360
+ const logLevel = config.logLevel || LOGLEVEL_INFO;
26361
+ const onLog = getOnLog(config, logLevel, printLog);
26362
+ const log = getLogger(plugins, onLog, watchMode, logLevel);
26363
+ const inputOptions = await mergeInputOptions(config, command, plugins, log, onLog);
26224
26364
  if (command.output) {
26225
26365
  Object.assign(command, command.output);
26226
26366
  }
26227
26367
  const outputOptionsArray = ensureArray(config.output);
26228
26368
  if (outputOptionsArray.length === 0)
26229
26369
  outputOptionsArray.push({});
26230
- const outputOptions = await Promise.all(outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn)));
26370
+ const outputOptions = await Promise.all(outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, log)));
26231
26371
  warnUnknownOptions(command, [
26232
26372
  ...Object.keys(inputOptions),
26233
26373
  ...Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapIgnoreList' && option !== 'sourcemapPathTransform'),
@@ -26241,7 +26381,7 @@ async function mergeOptions(config, rawCommandOptions = EMPTY_COMMAND_OPTIONS, d
26241
26381
  'stdin',
26242
26382
  'waitForBundleInput',
26243
26383
  'configPlugin'
26244
- ], 'CLI flags', warn, /^_$|output$|config/);
26384
+ ], 'CLI flags', log, /^_$|output$|config/);
26245
26385
  inputOptions.output = outputOptions;
26246
26386
  return inputOptions;
26247
26387
  }
@@ -26264,7 +26404,7 @@ function getCommandOptions(rawCommandOptions) {
26264
26404
  : undefined
26265
26405
  };
26266
26406
  }
26267
- async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26407
+ function mergeInputOptions(config, overrides, plugins, log, onLog) {
26268
26408
  const getOption = (name) => overrides[name] ?? config[name];
26269
26409
  const inputOptions = {
26270
26410
  acorn: getOption('acorn'),
@@ -26276,14 +26416,16 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26276
26416
  external: getExternal(config, overrides),
26277
26417
  inlineDynamicImports: getOption('inlineDynamicImports'),
26278
26418
  input: getOption('input') || [],
26419
+ logLevel: getOption('logLevel'),
26279
26420
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
26280
26421
  manualChunks: getOption('manualChunks'),
26281
26422
  maxParallelFileOps: getOption('maxParallelFileOps'),
26282
26423
  maxParallelFileReads: getOption('maxParallelFileReads'),
26283
26424
  moduleContext: getOption('moduleContext'),
26284
- onwarn: getOnWarn(config, defaultOnWarnHandler),
26425
+ onLog,
26426
+ onwarn: undefined,
26285
26427
  perf: getOption('perf'),
26286
- plugins: await normalizePluginOption(config.plugins),
26428
+ plugins,
26287
26429
  preserveEntrySignatures: getOption('preserveEntrySignatures'),
26288
26430
  preserveModules: getOption('preserveModules'),
26289
26431
  preserveSymlinks: getOption('preserveSymlinks'),
@@ -26292,7 +26434,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26292
26434
  treeshake: getObjectOption(config, overrides, 'treeshake', objectifyOptionWithPresets(treeshakePresets, 'treeshake', URL_TREESHAKE, 'false, true, ')),
26293
26435
  watch: getWatch(config, overrides)
26294
26436
  };
26295
- warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
26437
+ warnUnknownOptions(config, Object.keys(inputOptions), 'input options', log, /^output$/);
26296
26438
  return inputOptions;
26297
26439
  }
26298
26440
  const getExternal = (config, overrides) => {
@@ -26301,7 +26443,6 @@ const getExternal = (config, overrides) => {
26301
26443
  ? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.includes(source)
26302
26444
  : [...ensureArray(configExternal), ...overrides.external];
26303
26445
  };
26304
- const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn ? warning => config.onwarn(warning, defaultOnWarnHandler) : defaultOnWarnHandler;
26305
26446
  const getObjectOption = (config, overrides, name, objectifyValue = objectifyOption) => {
26306
26447
  const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue);
26307
26448
  const configOption = normalizeObjectOptionValue(config[name], objectifyValue);
@@ -26320,7 +26461,7 @@ const normalizeObjectOptionValue = (optionValue, objectifyValue) => {
26320
26461
  }
26321
26462
  return objectifyValue(optionValue);
26322
26463
  };
26323
- async function mergeOutputOptions(config, overrides, warn) {
26464
+ async function mergeOutputOptions(config, overrides, log) {
26324
26465
  const getOption = (name) => overrides[name] ?? config[name];
26325
26466
  const outputOptions = {
26326
26467
  amd: getObjectOption(config, overrides, 'amd'),
@@ -26372,7 +26513,7 @@ async function mergeOutputOptions(config, overrides, warn) {
26372
26513
  systemNullSetters: getOption('systemNullSetters'),
26373
26514
  validate: getOption('validate')
26374
26515
  };
26375
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
26516
+ warnUnknownOptions(config, Object.keys(outputOptions), 'output options', log);
26376
26517
  return outputOptions;
26377
26518
  }
26378
26519
 
@@ -26460,10 +26601,10 @@ function watch(configs) {
26460
26601
  return emitter;
26461
26602
  }
26462
26603
  async function watchInternal(configs, emitter) {
26463
- const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config)));
26604
+ const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config, true)));
26464
26605
  const watchOptionsList = optionsList.filter(config => config.watch !== false);
26465
26606
  if (watchOptionsList.length === 0) {
26466
- return error(errorInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
26607
+ return error(logInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
26467
26608
  }
26468
26609
  await loadFsEvents();
26469
26610
  const { Watcher } = await import('./watch.js');