rollup 3.24.1 → 3.25.1

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.1
4
- Sat, 10 Jun 2023 04:40:07 GMT - commit be39a579ac40a1f97d1b8e491aade0cd8717d22b
3
+ Rollup.js v3.25.1
4
+ Mon, 12 Jun 2023 04:38:12 GMT - commit b1341bf9cd719670a670905e0308418b37621d70
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.1";
18
+ var version$1 = "3.25.1";
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,94 +2759,23 @@ 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);
2677
- }
2678
- }
2679
-
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;
2777
+ log(LOGLEVEL_WARN, warning);
2739
2778
  }
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
2779
  }
2750
2780
 
2751
2781
  class ExternalModule {
@@ -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) {
@@ -8701,6 +8731,9 @@ class FunctionBase extends NodeBase {
8701
8731
  if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
8702
8732
  return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
8703
8733
  }
8734
+ if (this.annotationNoSideEffects) {
8735
+ return false;
8736
+ }
8704
8737
  if (this.async) {
8705
8738
  const { propertyReadSideEffects } = this.context.options
8706
8739
  .treeshake;
@@ -8764,12 +8797,13 @@ class ArrowFunctionExpression extends FunctionBase {
8764
8797
  return false;
8765
8798
  }
8766
8799
  hasEffectsOnInteractionAtPath(path, interaction, context) {
8767
- if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
8800
+ if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
8768
8801
  return true;
8802
+ }
8803
+ if (this.annotationNoSideEffects) {
8804
+ return false;
8805
+ }
8769
8806
  if (interaction.type === INTERACTION_CALLED) {
8770
- if (this.annotationNoSideEffects) {
8771
- return false;
8772
- }
8773
8807
  const { ignore, brokenFlow } = context;
8774
8808
  context.ignore = {
8775
8809
  breaks: false,
@@ -9580,7 +9614,7 @@ class MemberExpression extends NodeBase {
9580
9614
  if (this.variable) {
9581
9615
  this.context.includeVariableInModule(this.variable);
9582
9616
  }
9583
- this.context.warn(errorIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9617
+ this.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.context.module.id), this.start);
9584
9618
  }
9585
9619
  }
9586
9620
  }
@@ -9626,7 +9660,7 @@ function resolveNamespaceVariables(baseVariable, path, astContext) {
9626
9660
  if (!variable) {
9627
9661
  if (path.length === 1) {
9628
9662
  const fileName = baseVariable.context.fileName;
9629
- astContext.warn(errorMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9663
+ astContext.log(LOGLEVEL_WARN, logMissingExport(exportName, astContext.module.id, fileName), path[0].pos);
9630
9664
  return 'undefined';
9631
9665
  }
9632
9666
  return null;
@@ -9733,10 +9767,10 @@ class CallExpression extends CallExpressionBase {
9733
9767
  if (this.callee instanceof Identifier) {
9734
9768
  const variable = this.scope.findVariable(this.callee.name);
9735
9769
  if (variable.isNamespace) {
9736
- this.context.warn(errorCannotCallNamespace(this.callee.name), this.start);
9770
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(this.callee.name), this.start);
9737
9771
  }
9738
9772
  if (this.callee.name === 'eval') {
9739
- this.context.warn(errorEval(this.context.module.id), this.start);
9773
+ this.context.log(LOGLEVEL_WARN, logEval(this.context.module.id), this.start);
9740
9774
  }
9741
9775
  }
9742
9776
  this.interaction = {
@@ -11849,29 +11883,6 @@ class ObjectExpression extends NodeBase {
11849
11883
  class PrivateIdentifier extends NodeBase {
11850
11884
  }
11851
11885
 
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
11886
  class Program extends NodeBase {
11876
11887
  constructor() {
11877
11888
  super(...arguments);
@@ -11891,19 +11902,8 @@ class Program extends NodeBase {
11891
11902
  if (node.hasEffects(context)) {
11892
11903
  if (this.context.options.experimentalLogSideEffects && !this.hasLoggedEffect) {
11893
11904
  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();
11905
+ const { code, log, module } = this.context;
11906
+ log(LOGLEVEL_INFO, logFirstSideEffect(code, module.id, locate(code, node.start, { offsetLine: 1 })), node.start);
11907
11907
  }
11908
11908
  return (this.hasCachedEffect = true);
11909
11909
  }
@@ -12264,7 +12264,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
12264
12264
  const name = this.tag.name;
12265
12265
  const variable = this.scope.findVariable(name);
12266
12266
  if (variable.isNamespace) {
12267
- this.context.warn(errorCannotCallNamespace(name), this.start);
12267
+ this.context.log(LOGLEVEL_WARN, logCannotCallNamespace(name), this.start);
12268
12268
  }
12269
12269
  }
12270
12270
  }
@@ -12511,7 +12511,7 @@ class ThisExpression extends NodeBase {
12511
12511
  this.alias =
12512
12512
  this.scope.findLexicalBoundary() instanceof ModuleScope ? this.context.moduleContext : null;
12513
12513
  if (this.alias === 'undefined') {
12514
- this.context.warn(errorThisIsUndefined(), this.start);
12514
+ this.context.log(LOGLEVEL_WARN, logThisIsUndefined(), this.start);
12515
12515
  }
12516
12516
  }
12517
12517
  render(code) {
@@ -13154,6 +13154,29 @@ function getId(m) {
13154
13154
  return m.id;
13155
13155
  }
13156
13156
 
13157
+ function getOriginalLocation(sourcemapChain, location) {
13158
+ const filteredSourcemapChain = sourcemapChain.filter((sourcemap) => !!sourcemap.mappings);
13159
+ traceSourcemap: while (filteredSourcemapChain.length > 0) {
13160
+ const sourcemap = filteredSourcemapChain.pop();
13161
+ const line = sourcemap.mappings[location.line - 1];
13162
+ if (line) {
13163
+ const filteredLine = line.filter((segment) => segment.length > 1);
13164
+ const lastSegment = filteredLine[filteredLine.length - 1];
13165
+ for (const segment of filteredLine) {
13166
+ if (segment[0] >= location.column || segment === lastSegment) {
13167
+ location = {
13168
+ column: segment[3],
13169
+ line: segment[2] + 1
13170
+ };
13171
+ continue traceSourcemap;
13172
+ }
13173
+ }
13174
+ }
13175
+ throw new Error("Can't resolve original location of error.");
13176
+ }
13177
+ return location;
13178
+ }
13179
+
13157
13180
  function getAssertionsFromImportExpression(node) {
13158
13181
  const assertProperty = node.arguments?.[0]?.properties.find((property) => getPropertyKey(property) === 'assert')?.value;
13159
13182
  if (!assertProperty) {
@@ -13330,7 +13353,7 @@ function getVariableForExportNameRecursive(target, name, importerForSideEffects,
13330
13353
  const searchedModules = searchedNamesAndModules.get(name);
13331
13354
  if (searchedModules) {
13332
13355
  if (searchedModules.has(target)) {
13333
- return isExportAllSearch ? [null] : error(errorCircularReexport(name, target.id));
13356
+ return isExportAllSearch ? [null] : error(logCircularReexport(name, target.id));
13334
13357
  }
13335
13358
  searchedModules.add(target);
13336
13359
  }
@@ -13656,7 +13679,7 @@ class Module {
13656
13679
  : 'default', { onlyExplicit: true });
13657
13680
  }
13658
13681
  if (!this.syntheticNamespace) {
13659
- return error(errorSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13682
+ return error(logSyntheticNamedExportsNeedNamespaceExport(this.id, this.info.syntheticNamedExports));
13660
13683
  }
13661
13684
  return this.syntheticNamespace;
13662
13685
  }
@@ -13675,7 +13698,7 @@ class Module {
13675
13698
  if (reexportDeclaration) {
13676
13699
  const [variable] = getVariableForExportNameRecursive(reexportDeclaration.module, reexportDeclaration.localName, importerForSideEffects, false, searchedNamesAndModules);
13677
13700
  if (!variable) {
13678
- return this.error(errorMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13701
+ return this.error(logMissingExport(reexportDeclaration.localName, this.id, reexportDeclaration.module.id), reexportDeclaration.start);
13679
13702
  }
13680
13703
  if (importerForSideEffects) {
13681
13704
  setAlternativeExporterIfCyclic(variable, importerForSideEffects, this);
@@ -13812,13 +13835,17 @@ class Module {
13812
13835
  }
13813
13836
  this.exportAllModules.push(...externalExportAllModules);
13814
13837
  }
13838
+ log(level, properties, pos) {
13839
+ this.addLocationToLogProps(properties, pos);
13840
+ this.options.onLog(level, properties);
13841
+ }
13815
13842
  render(options) {
13816
13843
  const source = this.magicString.clone();
13817
13844
  this.ast.render(source, options);
13818
13845
  source.trim();
13819
13846
  const { usesTopLevelAwait } = this.astContext;
13820
13847
  if (usesTopLevelAwait && options.format !== 'es' && options.format !== 'system') {
13821
- return error(errorInvalidFormatForTopLevelAwait(this.id, options.format));
13848
+ return error(logInvalidFormatForTopLevelAwait(this.id, options.format));
13822
13849
  }
13823
13850
  return { source, usesTopLevelAwait };
13824
13851
  }
@@ -13863,6 +13890,7 @@ class Module {
13863
13890
  includeAllExports: () => this.includeAllExports(true),
13864
13891
  includeDynamicImport: this.includeDynamicImport.bind(this),
13865
13892
  includeVariableInModule: this.includeVariableInModule.bind(this),
13893
+ log: this.log.bind(this),
13866
13894
  magicString: this.magicString,
13867
13895
  manualPureFunctions: this.graph.pureFunctions,
13868
13896
  module: this,
@@ -13871,8 +13899,7 @@ class Module {
13871
13899
  requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
13872
13900
  traceExport: (name) => this.getVariableForExportName(name)[0],
13873
13901
  traceVariable: this.traceVariable.bind(this),
13874
- usesTopLevelAwait: false,
13875
- warn: this.warn.bind(this)
13902
+ usesTopLevelAwait: false
13876
13903
  };
13877
13904
  this.scope = new ModuleScope(this.graph.scope, this.astContext);
13878
13905
  this.namespace = new NamespaceVariable(this.astContext);
@@ -13932,7 +13959,7 @@ class Module {
13932
13959
  }
13933
13960
  const [declaration] = getVariableForExportNameRecursive(otherModule, importDescription.name, importerForSideEffects || this, isExportAllSearch, searchedNamesAndModules);
13934
13961
  if (!declaration) {
13935
- return this.error(errorMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13962
+ return this.error(logMissingExport(importDescription.name, this.id, otherModule.id), importDescription.start);
13936
13963
  }
13937
13964
  return declaration;
13938
13965
  }
@@ -13949,10 +13976,6 @@ class Module {
13949
13976
  Object.assign(this.info.meta, meta);
13950
13977
  }
13951
13978
  }
13952
- warn(properties, pos) {
13953
- this.addLocationToLogProps(properties, pos);
13954
- this.options.onwarn(properties);
13955
- }
13956
13979
  addDynamicImport(node) {
13957
13980
  let argument = node.source;
13958
13981
  if (argument instanceof TemplateLiteral) {
@@ -14066,7 +14089,7 @@ class Module {
14066
14089
  code = this.originalCode;
14067
14090
  }
14068
14091
  catch (error_) {
14069
- this.options.onwarn(errorInvalidSourcemapForError(error_, this.id, column, line, pos));
14092
+ this.options.onLog(LOGLEVEL_WARN, logInvalidSourcemapForError(error_, this.id, column, line, pos));
14070
14093
  }
14071
14094
  augmentCodeLocation(properties, { column, line }, code, this.id);
14072
14095
  }
@@ -14107,7 +14130,7 @@ class Module {
14107
14130
  const existingAssertions = this.sourcesWithAssertions.get(source);
14108
14131
  if (existingAssertions) {
14109
14132
  if (doAssertionsDiffer(existingAssertions, parsedAssertions)) {
14110
- this.warn(errorInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
14133
+ this.log(LOGLEVEL_WARN, logInconsistentImportAssertions(existingAssertions, parsedAssertions, source, this.id), declaration.start);
14111
14134
  }
14112
14135
  }
14113
14136
  else {
@@ -14145,7 +14168,7 @@ class Module {
14145
14168
  if (foundDeclarationList.length === 1) {
14146
14169
  return [usedDeclaration];
14147
14170
  }
14148
- this.options.onwarn(errorNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
14171
+ this.options.onLog(LOGLEVEL_WARN, logNamespaceConflict(name, this.id, foundDeclarationList.map(([, module]) => module.id)));
14149
14172
  // TODO we are pretending it was not found while it should behave like "undefined"
14150
14173
  return [null];
14151
14174
  }
@@ -14153,7 +14176,7 @@ class Module {
14153
14176
  const foundDeclarationList = [...foundExternalDeclarations];
14154
14177
  const usedDeclaration = foundDeclarationList[0];
14155
14178
  if (foundDeclarationList.length > 1) {
14156
- this.options.onwarn(errorAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
14179
+ this.options.onLog(LOGLEVEL_WARN, logAmbiguousExternalNamespaces(name, this.id, usedDeclaration.module.id, foundDeclarationList.map(declaration => declaration.module.id)));
14157
14180
  }
14158
14181
  return [usedDeclaration, true];
14159
14182
  }
@@ -14229,7 +14252,7 @@ class Module {
14229
14252
  }
14230
14253
  }
14231
14254
  shimMissingExport(name) {
14232
- this.options.onwarn(errorShimmedExport(this.id, name));
14255
+ this.options.onLog(LOGLEVEL_WARN, logShimmedExport(this.id, name));
14233
14256
  this.exports.set(name, MISSING_EXPORT_SHIM_DESCRIPTION);
14234
14257
  }
14235
14258
  tryParse() {
@@ -14237,7 +14260,7 @@ class Module {
14237
14260
  return this.graph.contextParse(this.info.code);
14238
14261
  }
14239
14262
  catch (error_) {
14240
- return this.error(errorParseError(error_, this.id), error_.pos);
14263
+ return this.error(logParseError(error_, this.id), error_.pos);
14241
14264
  }
14242
14265
  }
14243
14266
  }
@@ -14538,17 +14561,17 @@ const nodeBuiltins = new Set([
14538
14561
  'timers/promises',
14539
14562
  'util/types'
14540
14563
  ]);
14541
- function warnOnBuiltins(warn, dependencies) {
14564
+ function warnOnBuiltins(log, dependencies) {
14542
14565
  const externalBuiltins = dependencies
14543
14566
  .map(({ importPath }) => importPath)
14544
14567
  .filter(importPath => nodeBuiltins.has(importPath) || importPath.startsWith('node:'));
14545
14568
  if (externalBuiltins.length === 0)
14546
14569
  return;
14547
- warn(errorMissingNodeBuiltins(externalBuiltins));
14570
+ log(LOGLEVEL_WARN, logMissingNodeBuiltins(externalBuiltins));
14548
14571
  }
14549
14572
 
14550
- 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 }) {
14551
- warnOnBuiltins(onwarn, dependencies);
14573
+ 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 }) {
14574
+ warnOnBuiltins(log, dependencies);
14552
14575
  const deps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
14553
14576
  const parameters = dependencies.map(m => m.name);
14554
14577
  const { n, getNonArrowFunctionIntro, _ } = snippets;
@@ -14773,19 +14796,19 @@ function trimEmptyImports(dependencies) {
14773
14796
  return [];
14774
14797
  }
14775
14798
 
14776
- 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 }) {
14799
+ 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 }) {
14777
14800
  const { _, getNonArrowFunctionIntro, getPropertyAccess, n } = snippets;
14778
14801
  const isNamespaced = name && name.includes('.');
14779
14802
  const useVariableAssignment = !extend && !isNamespaced;
14780
14803
  if (name && useVariableAssignment && !isLegal(name)) {
14781
- return error(errorIllegalIdentifierAsName(name));
14804
+ return error(logIllegalIdentifierAsName(name));
14782
14805
  }
14783
- warnOnBuiltins(onwarn, dependencies);
14806
+ warnOnBuiltins(log, dependencies);
14784
14807
  const external = trimEmptyImports(dependencies);
14785
14808
  const deps = external.map(dep => dep.globalName || 'null');
14786
14809
  const parameters = external.map(m => m.name);
14787
14810
  if (hasExports && !name) {
14788
- onwarn(errorMissingNameOptionForIifeExport());
14811
+ log(LOGLEVEL_WARN, logMissingNameOptionForIifeExport());
14789
14812
  }
14790
14813
  if (namedExportsMode && hasExports) {
14791
14814
  if (extend) {
@@ -14977,14 +15000,14 @@ function safeAccess(name, globalVariable, { _, getPropertyAccess }) {
14977
15000
  .map(part => (propertyPath += getPropertyAccess(part)))
14978
15001
  .join(`${_}&&${_}`);
14979
15002
  }
14980
- 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 }) {
15003
+ 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 }) {
14981
15004
  const { _, cnst, getFunctionIntro, getNonArrowFunctionIntro, getPropertyAccess, n, s } = snippets;
14982
15005
  const factoryVariable = compact ? 'f' : 'factory';
14983
15006
  const globalVariable = compact ? 'g' : 'global';
14984
15007
  if (hasExports && !name) {
14985
- return error(errorMissingNameOptionForUmdExport());
15008
+ return error(logMissingNameOptionForUmdExport());
14986
15009
  }
14987
- warnOnBuiltins(onwarn, dependencies);
15010
+ warnOnBuiltins(log, dependencies);
14988
15011
  const amdDeps = dependencies.map(m => `'${updateExtensionForRelativeAmdId(m.importPath, amd.forceJsExtensionForImports)}'`);
14989
15012
  const cjsDeps = dependencies.map(m => `require('${m.importPath}')`);
14990
15013
  const trimmedImports = trimEmptyImports(dependencies);
@@ -15094,7 +15117,7 @@ async function createAddons(options, outputPluginDriver, chunk) {
15094
15117
  return { banner, footer, intro, outro };
15095
15118
  }
15096
15119
  catch (error_) {
15097
- return error(errorAddonNotGenerated(error_.message, error_.hook, error_.plugin));
15120
+ return error(logAddonNotGenerated(error_.message, error_.hook, error_.plugin));
15098
15121
  }
15099
15122
  }
15100
15123
 
@@ -15247,15 +15270,15 @@ function assignExportsToNames(exports, exportsByName, exportNamesByVariable) {
15247
15270
  }
15248
15271
  }
15249
15272
 
15250
- function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, warn) {
15273
+ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModuleId, log) {
15251
15274
  const exportKeys = chunk.getExportNames();
15252
15275
  if (exportMode === 'default') {
15253
15276
  if (exportKeys.length !== 1 || exportKeys[0] !== 'default') {
15254
- return error(errorIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
15277
+ return error(logIncompatibleExportOptionValue('default', exportKeys, facadeModuleId));
15255
15278
  }
15256
15279
  }
15257
15280
  else if (exportMode === 'none' && exportKeys.length > 0) {
15258
- return error(errorIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
15281
+ return error(logIncompatibleExportOptionValue('none', exportKeys, facadeModuleId));
15259
15282
  }
15260
15283
  if (exportMode === 'auto') {
15261
15284
  if (exportKeys.length === 0) {
@@ -15266,7 +15289,7 @@ function getExportMode(chunk, { exports: exportMode, name, format }, facadeModul
15266
15289
  }
15267
15290
  else {
15268
15291
  if (format !== 'es' && format !== 'system' && exportKeys.includes('default')) {
15269
- warn(errorMixedExport(facadeModuleId, name));
15292
+ log(LOGLEVEL_WARN, logMixedExport(facadeModuleId, name));
15270
15293
  }
15271
15294
  exportMode = 'named';
15272
15295
  }
@@ -15343,7 +15366,8 @@ function addStaticDependencies(module, staticDependencies, handledModules, chunk
15343
15366
  }
15344
15367
  }
15345
15368
 
15346
- // Four random characters from the private use area to minimize risk of conflicts
15369
+ // Four random characters from the private use area to minimize risk of
15370
+ // conflicts
15347
15371
  const hashPlaceholderLeft = '!~{';
15348
15372
  const hashPlaceholderRight = '}~';
15349
15373
  const hashPlaceholderOverhead = hashPlaceholderLeft.length + hashPlaceholderRight.length;
@@ -15354,11 +15378,11 @@ const getHashPlaceholderGenerator = () => {
15354
15378
  let nextIndex = 0;
15355
15379
  return (optionName, hashSize = defaultHashSize) => {
15356
15380
  if (hashSize > maxHashSize) {
15357
- return error(errorFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
15381
+ return error(logFailedValidation(`Hashes cannot be longer than ${maxHashSize} characters, received ${hashSize}. Check the "${optionName}" option.`));
15358
15382
  }
15359
15383
  const placeholder = `${hashPlaceholderLeft}${toBase64(++nextIndex).padStart(hashSize - hashPlaceholderOverhead, '0')}${hashPlaceholderRight}`;
15360
15384
  if (placeholder.length > hashSize) {
15361
- 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.`));
15385
+ 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.`));
15362
15386
  }
15363
15387
  return placeholder;
15364
15388
  };
@@ -15425,14 +15449,14 @@ const removeUnreferencedAssets = (outputBundle) => {
15425
15449
 
15426
15450
  function renderNamePattern(pattern, patternName, replacements) {
15427
15451
  if (isPathFragment(pattern))
15428
- 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.`));
15452
+ 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.`));
15429
15453
  return pattern.replace(/\[(\w+)(:\d+)?]/g, (_match, type, size) => {
15430
15454
  if (!replacements.hasOwnProperty(type) || (size && type !== 'hash')) {
15431
- return error(errorFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
15455
+ return error(logFailedValidation(`"[${type}${size || ''}]" is not a valid placeholder in the "${patternName}" pattern.`));
15432
15456
  }
15433
15457
  const replacement = replacements[type](size && Number.parseInt(size.slice(1)));
15434
15458
  if (isPathFragment(replacement))
15435
- return error(errorFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
15459
+ return error(logFailedValidation(`Invalid substitution "${replacement}" for placeholder "[${type}]" in "${patternName}" pattern, can be neither absolute nor relative path.`));
15436
15460
  return replacement;
15437
15461
  });
15438
15462
  }
@@ -15457,13 +15481,13 @@ const NON_ASSET_EXTENSIONS = new Set([
15457
15481
  '.cjs',
15458
15482
  '.cts'
15459
15483
  ]);
15460
- function getGlobalName(chunk, globals, hasExports, warn) {
15484
+ function getGlobalName(chunk, globals, hasExports, log) {
15461
15485
  const globalName = typeof globals === 'function' ? globals(chunk.id) : globals[chunk.id];
15462
15486
  if (globalName) {
15463
15487
  return globalName;
15464
15488
  }
15465
15489
  if (hasExports) {
15466
- warn(errorMissingGlobalName(chunk.id, chunk.variableName));
15490
+ log(LOGLEVEL_WARN, logMissingGlobalName(chunk.id, chunk.variableName));
15467
15491
  return chunk.variableName;
15468
15492
  }
15469
15493
  }
@@ -15622,7 +15646,7 @@ class Chunk {
15622
15646
  assignExportsToNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
15623
15647
  }
15624
15648
  if (this.outputOptions.preserveModules || (this.facadeModule && this.facadeModule.info.isEntry))
15625
- this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onwarn);
15649
+ this.exportMode = getExportMode(this, this.outputOptions, this.facadeModule.id, this.inputOptions.onLog);
15626
15650
  }
15627
15651
  generateFacades() {
15628
15652
  const facades = [];
@@ -15770,7 +15794,7 @@ class Chunk {
15770
15794
  }
15771
15795
  }
15772
15796
  async render() {
15773
- const { dependencies, exportMode, facadeModule, inputOptions: { onwarn }, outputOptions, pluginDriver, snippets } = this;
15797
+ const { dependencies, exportMode, facadeModule, inputOptions: { onLog }, outputOptions, pluginDriver, snippets } = this;
15774
15798
  const { format, hoistTransitiveImports, preserveModules } = outputOptions;
15775
15799
  // for static and dynamic entry points, add transitive dependencies to this
15776
15800
  // chunk's dependencies to avoid loading latency
@@ -15820,8 +15844,8 @@ class Chunk {
15820
15844
  intro,
15821
15845
  isEntryFacade: preserveModules || (facadeModule !== null && facadeModule.info.isEntry),
15822
15846
  isModuleFacade: facadeModule !== null,
15847
+ log: onLog,
15823
15848
  namedExportsMode: exportMode !== 'default',
15824
- onwarn,
15825
15849
  outro,
15826
15850
  snippets,
15827
15851
  usesTopLevelAwait
@@ -15876,7 +15900,7 @@ class Chunk {
15876
15900
  if (alternativeReexportModule) {
15877
15901
  const exportingChunk = this.chunkByModule.get(alternativeReexportModule);
15878
15902
  if (exportingChunk !== exportChunk) {
15879
- this.inputOptions.onwarn(errorCyclicCrossChunkReexport(
15903
+ this.inputOptions.onLog(LOGLEVEL_WARN, logCyclicCrossChunkReexport(
15880
15904
  // Namespaces do not have an export name
15881
15905
  variableModule.getExportNamesByVariable().get(variable)?.[0] || '*', variableModule.id, alternativeReexportModule.id, importingModule.id, this.outputOptions.preserveModules));
15882
15906
  }
@@ -16064,7 +16088,7 @@ class Chunk {
16064
16088
  dependency = this.externalChunkByModule.get(module);
16065
16089
  imported = variable.name;
16066
16090
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
16067
- return error(errorUnexpectedNamedImport(module.id, imported, false));
16091
+ return error(logUnexpectedNamedImport(module.id, imported, false));
16068
16092
  }
16069
16093
  }
16070
16094
  else {
@@ -16154,7 +16178,7 @@ class Chunk {
16154
16178
  if (exportName[0] === '*') {
16155
16179
  const id = exportName.slice(1);
16156
16180
  if (interop(id) === 'defaultOnly') {
16157
- this.inputOptions.onwarn(errorUnexpectedNamespaceReexport(id));
16181
+ this.inputOptions.onLog(LOGLEVEL_WARN, logUnexpectedNamespaceReexport(id));
16158
16182
  }
16159
16183
  needsLiveBinding = externalLiveBindings;
16160
16184
  dependency = this.externalChunkByModule.get(this.modulesById.get(id));
@@ -16176,7 +16200,7 @@ class Chunk {
16176
16200
  dependency = this.externalChunkByModule.get(module);
16177
16201
  imported = variable.name;
16178
16202
  if (imported !== 'default' && imported !== '*' && interop(module.id) === 'defaultOnly') {
16179
- return error(errorUnexpectedNamedImport(module.id, imported, true));
16203
+ return error(logUnexpectedNamedImport(module.id, imported, true));
16180
16204
  }
16181
16205
  needsLiveBinding =
16182
16206
  externalLiveBindings &&
@@ -16221,7 +16245,7 @@ class Chunk {
16221
16245
  defaultVariableName: dep.defaultVariableName,
16222
16246
  globalName: dep instanceof ExternalChunk &&
16223
16247
  (this.outputOptions.format === 'umd' || this.outputOptions.format === 'iife') &&
16224
- getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onwarn),
16248
+ getGlobalName(dep, this.outputOptions.globals, (imports || reexports) !== null, this.inputOptions.onLog),
16225
16249
  importPath,
16226
16250
  imports,
16227
16251
  isChunk: dep instanceof Chunk,
@@ -16245,7 +16269,7 @@ class Chunk {
16245
16269
  }
16246
16270
  // This method changes properties on the AST before rendering and must not be async
16247
16271
  renderModules(fileName) {
16248
- const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onwarn }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
16272
+ const { accessedGlobalsByScope, dependencies, exportNamesByVariable, includedNamespaces, inputOptions: { onLog }, isEmpty, orderedModules, outputOptions, pluginDriver, renderedModules, snippets } = this;
16249
16273
  const { compact, dynamicImportFunction, format, freeze, namespaceToStringTag } = outputOptions;
16250
16274
  const { _, cnst, n } = snippets;
16251
16275
  this.setDynamicImportResolutions(fileName);
@@ -16318,7 +16342,7 @@ class Chunk {
16318
16342
  }
16319
16343
  const renderedSource = compact ? magicString : magicString.trim();
16320
16344
  if (isEmpty && this.getExportNames().length === 0 && dependencies.size === 0) {
16321
- onwarn(errorEmptyChunk(this.getChunkName()));
16345
+ onLog(LOGLEVEL_WARN, logEmptyChunk(this.getChunkName()));
16322
16346
  }
16323
16347
  return { accessedGlobals, indent, magicString, renderedSource, usedModules, usesTopLevelAwait };
16324
16348
  }
@@ -16607,7 +16631,7 @@ function* concatLazy(iterables) {
16607
16631
  * those chunks that are already loaded for that dynamic entry and create
16608
16632
  * another round of chunks.
16609
16633
  */
16610
- function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16634
+ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize, log) {
16611
16635
  const { chunkDefinitions, modulesInManualChunks } = getChunkDefinitionsFromManualChunks(manualChunkAliasByEntry);
16612
16636
  const { allEntries, dependentEntriesByModule, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry } = analyzeModuleGraph(entries);
16613
16637
  // Each chunk is identified by its position in this array
@@ -16615,7 +16639,7 @@ function getChunkAssignments(entries, manualChunkAliasByEntry, minChunkSize) {
16615
16639
  // This mutates initialChunks but also clears
16616
16640
  // dynamicallyDependentEntriesByDynamicEntry as side effect
16617
16641
  removeUnnecessaryDependentEntries(initialChunks, dynamicallyDependentEntriesByDynamicEntry, dynamicImportsByEntry, allEntries);
16618
- chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize).map(({ modules }) => ({
16642
+ chunkDefinitions.push(...getOptimizedChunks(getChunksFromDependentEntries(initialChunks), allEntries.length, minChunkSize, log).map(({ modules }) => ({
16619
16643
  alias: null,
16620
16644
  modules
16621
16645
  })));
@@ -16871,7 +16895,7 @@ function removeUnnecessaryDependentEntries(chunks, dynamicallyDependentEntriesBy
16871
16895
  * following the rule (a), starting with the smallest chunks to look for
16872
16896
  * possible merge targets.
16873
16897
  */
16874
- function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize) {
16898
+ function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize, log) {
16875
16899
  timeStart('optimize chunks', 3);
16876
16900
  const chunkPartition = getPartitionedChunks(initialChunks, numberOfEntries, minChunkSize);
16877
16901
  if (!chunkPartition) {
@@ -16879,10 +16903,10 @@ function getOptimizedChunks(initialChunks, numberOfEntries, minChunkSize) {
16879
16903
  return initialChunks; // the actual modules
16880
16904
  }
16881
16905
  minChunkSize > 1 &&
16882
- console.log('Before eliminating small chunks, there were\n', initialChunks.length, 'chunks, of which\n', chunkPartition.small.size, 'were below minChunkSize.');
16906
+ log('info', logOptimizeChunkStatus(initialChunks.length, chunkPartition.small.size, 'Initially'));
16883
16907
  mergeChunks(chunkPartition, minChunkSize);
16884
16908
  minChunkSize > 1 &&
16885
- console.log('After merging chunks,\n', chunkPartition.small.size + chunkPartition.big.size, 'chunks remain, of which\n', chunkPartition.small.size, 'are below minChunkSize.');
16909
+ log('info', logOptimizeChunkStatus(chunkPartition.small.size + chunkPartition.big.size, chunkPartition.small.size, 'After merging chunks'));
16886
16910
  timeEnd('optimize chunks', 3);
16887
16911
  return [...chunkPartition.small, ...chunkPartition.big];
16888
16912
  }
@@ -17293,7 +17317,7 @@ class Link {
17293
17317
  sourcesContent[sourceIndex] = content;
17294
17318
  }
17295
17319
  else if (content != null && sourcesContent[sourceIndex] !== content) {
17296
- return error(errorConflictingSourcemapSources(filename));
17320
+ return error(logConflictingSourcemapSources(filename));
17297
17321
  }
17298
17322
  const tracedSegment = [segment[0], sourceIndex, line, column];
17299
17323
  if (name) {
@@ -17343,12 +17367,12 @@ class Link {
17343
17367
  return null;
17344
17368
  }
17345
17369
  }
17346
- function getLinkMap(warn) {
17370
+ function getLinkMap(log) {
17347
17371
  return function linkMap(source, map) {
17348
17372
  if (map.mappings) {
17349
17373
  return new Link(map, [source]);
17350
17374
  }
17351
- warn(errorSourcemapBroken(map.plugin));
17375
+ log(LOGLEVEL_WARN, logSourcemapBroken(map.plugin));
17352
17376
  return new Link({
17353
17377
  mappings: [],
17354
17378
  names: []
@@ -17370,8 +17394,8 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
17370
17394
  }
17371
17395
  return sourcemapChain.reduce(linkMap, source);
17372
17396
  }
17373
- function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, warn) {
17374
- const linkMap = getLinkMap(warn);
17397
+ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeContent, log) {
17398
+ const linkMap = getLinkMap(log);
17375
17399
  const moduleSources = modules
17376
17400
  .filter(module => !module.excludeFromSourcemap)
17377
17401
  .map(module => getCollapsedSourcemap(module.id, module.originalCode, module.originalSourcemap, module.sourcemapChain, linkMap));
@@ -17386,11 +17410,11 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
17386
17410
  sourcesContent = (excludeContent ? null : sourcesContent);
17387
17411
  return new SourceMap({ file, mappings, names, sources, sourcesContent });
17388
17412
  }
17389
- function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn) {
17413
+ function collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log) {
17390
17414
  if (sourcemapChain.length === 0) {
17391
17415
  return originalSourcemap;
17392
17416
  }
17393
- const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(warn));
17417
+ const source = getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapChain, getLinkMap(log));
17394
17418
  const map = source.traceMappings();
17395
17419
  return { version: 3, ...map };
17396
17420
  }
@@ -17415,14 +17439,14 @@ function decodedSourcemap(map) {
17415
17439
  return { ...map, mappings };
17416
17440
  }
17417
17441
 
17418
- async function renderChunks(chunks, bundle, pluginDriver, outputOptions, onwarn) {
17442
+ async function renderChunks(chunks, bundle, pluginDriver, outputOptions, log) {
17419
17443
  timeStart('render chunks', 2);
17420
17444
  reserveEntryChunksInBundle(chunks);
17421
17445
  const renderedChunks = await Promise.all(chunks.map(chunk => chunk.render()));
17422
17446
  timeEnd('render chunks', 2);
17423
17447
  timeStart('transform chunks', 2);
17424
17448
  const chunkGraph = getChunkGraph(chunks);
17425
- const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn);
17449
+ const { nonHashedChunksWithPlaceholders, renderedChunksByPlaceholder, hashDependenciesByPlaceholder } = await transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log);
17426
17450
  const hashesByPlaceholder = generateFinalHashes(renderedChunksByPlaceholder, hashDependenciesByPlaceholder, bundle);
17427
17451
  addChunksToBundle(renderedChunksByPlaceholder, hashesByPlaceholder, bundle, nonHashedChunksWithPlaceholders, pluginDriver, outputOptions);
17428
17452
  timeEnd('transform chunks', 2);
@@ -17441,7 +17465,7 @@ function getChunkGraph(chunks) {
17441
17465
  return [renderedChunkInfo.fileName, renderedChunkInfo];
17442
17466
  }));
17443
17467
  }
17444
- async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, onwarn) {
17468
+ async function transformChunk(magicString, fileName, usedModules, chunkGraph, options, outputPluginDriver, log) {
17445
17469
  let map = null;
17446
17470
  const sourcemapChain = [];
17447
17471
  let code = await outputPluginDriver.hookReduceArg0('renderChunk', [magicString.toString(), chunkGraph[fileName], options, { chunks: chunkGraph }], (code, result, plugin) => {
@@ -17472,13 +17496,13 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17472
17496
  else
17473
17497
  resultingFile = resolve(fileName);
17474
17498
  const decodedMap = magicString.generateDecodedMap({});
17475
- map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, onwarn);
17499
+ map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, log);
17476
17500
  for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
17477
17501
  let sourcePath = map.sources[sourcesIndex];
17478
17502
  const sourcemapPath = `${resultingFile}.map`;
17479
17503
  const ignoreList = sourcemapIgnoreList(sourcePath, sourcemapPath);
17480
17504
  if (typeof ignoreList !== 'boolean') {
17481
- error(errorFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17505
+ error(logFailedValidation('sourcemapIgnoreList function must return a boolean.'));
17482
17506
  }
17483
17507
  if (ignoreList) {
17484
17508
  if (map.x_google_ignoreList === undefined) {
@@ -17491,7 +17515,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17491
17515
  if (sourcemapPathTransform) {
17492
17516
  sourcePath = sourcemapPathTransform(sourcePath, sourcemapPath);
17493
17517
  if (typeof sourcePath !== 'string') {
17494
- error(errorFailedValidation(`sourcemapPathTransform function must return a string.`));
17518
+ error(logFailedValidation(`sourcemapPathTransform function must return a string.`));
17495
17519
  }
17496
17520
  }
17497
17521
  map.sources[sourcesIndex] = normalize(sourcePath);
@@ -17503,7 +17527,7 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
17503
17527
  map
17504
17528
  };
17505
17529
  }
17506
- async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, onwarn) {
17530
+ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGraph, outputOptions, pluginDriver, log) {
17507
17531
  const nonHashedChunksWithPlaceholders = [];
17508
17532
  const renderedChunksByPlaceholder = new Map();
17509
17533
  const hashDependenciesByPlaceholder = new Map();
@@ -17516,7 +17540,7 @@ async function transformChunksAndGenerateContentHashes(renderedChunks, chunkGrap
17516
17540
  const transformedChunk = {
17517
17541
  chunk,
17518
17542
  fileName,
17519
- ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, onwarn))
17543
+ ...(await transformChunk(magicString, fileName, usedModules, chunkGraph, outputOptions, pluginDriver, log))
17520
17544
  };
17521
17545
  const { code } = transformedChunk;
17522
17546
  if (hashPlaceholder) {
@@ -17633,14 +17657,14 @@ class Bundle {
17633
17657
  const getHashPlaceholder = getHashPlaceholderGenerator();
17634
17658
  const chunks = await this.generateChunks(outputBundle, getHashPlaceholder);
17635
17659
  if (chunks.length > 1) {
17636
- validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onwarn);
17660
+ validateOptionsForMultiChunkOutput(this.outputOptions, this.inputOptions.onLog);
17637
17661
  }
17638
17662
  this.pluginDriver.setChunkInformation(this.facadeChunkByModule);
17639
17663
  for (const chunk of chunks) {
17640
17664
  chunk.generateExports();
17641
17665
  }
17642
17666
  timeEnd('generate chunks', 2);
17643
- await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onwarn);
17667
+ await renderChunks(chunks, outputBundle, this.pluginDriver, this.outputOptions, this.inputOptions.onLog);
17644
17668
  }
17645
17669
  catch (error_) {
17646
17670
  await this.pluginDriver.hookParallel('renderError', [error_]);
@@ -17703,7 +17727,7 @@ class Bundle {
17703
17727
  });
17704
17728
  }
17705
17729
  catch (error_) {
17706
- this.inputOptions.onwarn(errorChunkInvalid(file, error_));
17730
+ this.inputOptions.onLog(LOGLEVEL_WARN, logChunkInvalid(file, error_));
17707
17731
  }
17708
17732
  }
17709
17733
  }
@@ -17725,7 +17749,7 @@ class Bundle {
17725
17749
  ? [{ alias: null, modules: includedModules }]
17726
17750
  : preserveModules
17727
17751
  ? includedModules.map(module => ({ alias: null, modules: [module] }))
17728
- : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize)) {
17752
+ : getChunkAssignments(this.graph.entryModules, manualChunkAliasByEntry, experimentalMinChunkSize, this.inputOptions.onLog)) {
17729
17753
  sortByExecutionOrder(modules);
17730
17754
  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);
17731
17755
  chunks.push(chunk);
@@ -17740,15 +17764,15 @@ class Bundle {
17740
17764
  return [...chunks, ...facades];
17741
17765
  }
17742
17766
  }
17743
- function validateOptionsForMultiChunkOutput(outputOptions, onWarn) {
17767
+ function validateOptionsForMultiChunkOutput(outputOptions, log) {
17744
17768
  if (outputOptions.format === 'umd' || outputOptions.format === 'iife')
17745
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17769
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, 'UMD and IIFE output formats are not supported for code-splitting builds', outputOptions.format));
17746
17770
  if (typeof outputOptions.file === 'string')
17747
- 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'));
17771
+ 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'));
17748
17772
  if (outputOptions.sourcemapFile)
17749
- return error(errorInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17773
+ return error(logInvalidOption('output.sourcemapFile', URL_OUTPUT_SOURCEMAPFILE, '"output.sourcemapFile" is only supported for single-file builds'));
17750
17774
  if (!outputOptions.amd.autoId && outputOptions.amd.id)
17751
- 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'));
17775
+ 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'));
17752
17776
  }
17753
17777
  function getIncludedModules(modulesById) {
17754
17778
  const includedModules = [];
@@ -17781,7 +17805,7 @@ function getExternalChunkByModule(modulesById, outputOptions, inputBase) {
17781
17805
  function addModuleToManualChunk(alias, module, manualChunkAliasByEntry) {
17782
17806
  const existingAlias = manualChunkAliasByEntry.get(module);
17783
17807
  if (typeof existingAlias === 'string' && existingAlias !== alias) {
17784
- return error(errorCannotAssignModuleToChunk(module.id, alias, existingAlias));
17808
+ return error(logCannotAssignModuleToChunk(module.id, alias, existingAlias));
17785
17809
  }
17786
17810
  manualChunkAliasByEntry.set(module, alias);
17787
17811
  }
@@ -23565,9 +23589,9 @@ const NO_CACHE = {
23565
23589
  function uncacheablePluginError(pluginName) {
23566
23590
  if (pluginName.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
23567
23591
  pluginName.startsWith(ANONYMOUS_OUTPUT_PLUGIN_PREFIX)) {
23568
- return error(errorAnonymousPluginCache());
23592
+ return error(logAnonymousPluginCache());
23569
23593
  }
23570
- return error(errorDuplicatePluginName(pluginName));
23594
+ return error(logDuplicatePluginName(pluginName));
23571
23595
  }
23572
23596
  function getCacheForUncacheablePlugin(pluginName) {
23573
23597
  return {
@@ -23586,7 +23610,154 @@ function getCacheForUncacheablePlugin(pluginName) {
23586
23610
  };
23587
23611
  }
23588
23612
 
23589
- async function transform(source, module, pluginDriver, warn) {
23613
+ async function asyncFlatten(array) {
23614
+ do {
23615
+ array = (await Promise.all(array)).flat(Infinity);
23616
+ } while (array.some((v) => v?.then));
23617
+ return array;
23618
+ }
23619
+
23620
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
23621
+ const { onwarn, onLog } = config;
23622
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
23623
+ if (onLog) {
23624
+ const minimalPriority = logLevelPriority[logLevel];
23625
+ return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
23626
+ if (level === LOGLEVEL_ERROR) {
23627
+ return error(normalizeLog(handledLog));
23628
+ }
23629
+ if (logLevelPriority[level] >= minimalPriority) {
23630
+ defaultOnLog(level, normalizeLog(handledLog));
23631
+ }
23632
+ });
23633
+ }
23634
+ return defaultOnLog;
23635
+ };
23636
+ const getDefaultOnLog = (printLog, onwarn) => onwarn
23637
+ ? (level, log) => {
23638
+ if (level === LOGLEVEL_WARN) {
23639
+ onwarn(addLogToString(log), warning => printLog(LOGLEVEL_WARN, normalizeLog(warning)));
23640
+ }
23641
+ else {
23642
+ printLog(level, log);
23643
+ }
23644
+ }
23645
+ : printLog;
23646
+ const addLogToString = (log) => {
23647
+ Object.defineProperty(log, 'toString', {
23648
+ value: () => getExtendedLogMessage(log),
23649
+ writable: true
23650
+ });
23651
+ return log;
23652
+ };
23653
+ const normalizeLog = (log) => typeof log === 'string'
23654
+ ? { message: log }
23655
+ : typeof log === 'function'
23656
+ ? normalizeLog(log())
23657
+ : log;
23658
+ const getExtendedLogMessage = (log) => {
23659
+ let prefix = '';
23660
+ if (log.plugin) {
23661
+ prefix += `(${log.plugin} plugin) `;
23662
+ }
23663
+ if (log.loc) {
23664
+ prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
23665
+ }
23666
+ return prefix + log.message;
23667
+ };
23668
+ const defaultPrintLog = (level, log) => {
23669
+ const message = getExtendedLogMessage(log);
23670
+ switch (level) {
23671
+ case LOGLEVEL_WARN: {
23672
+ return console.warn(message);
23673
+ }
23674
+ case LOGLEVEL_DEBUG: {
23675
+ return console.debug(message);
23676
+ }
23677
+ default: {
23678
+ return console.info(message);
23679
+ }
23680
+ }
23681
+ };
23682
+ function warnUnknownOptions(passedOptions, validOptions, optionType, log, ignoredKeys = /$./) {
23683
+ const validOptionSet = new Set(validOptions);
23684
+ const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
23685
+ if (unknownOptions.length > 0) {
23686
+ log(LOGLEVEL_WARN, logUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
23687
+ }
23688
+ }
23689
+ const treeshakePresets = {
23690
+ recommended: {
23691
+ annotations: true,
23692
+ correctVarValueBeforeDeclaration: false,
23693
+ manualPureFunctions: EMPTY_ARRAY,
23694
+ moduleSideEffects: () => true,
23695
+ propertyReadSideEffects: true,
23696
+ tryCatchDeoptimization: true,
23697
+ unknownGlobalSideEffects: false
23698
+ },
23699
+ safest: {
23700
+ annotations: true,
23701
+ correctVarValueBeforeDeclaration: true,
23702
+ manualPureFunctions: EMPTY_ARRAY,
23703
+ moduleSideEffects: () => true,
23704
+ propertyReadSideEffects: true,
23705
+ tryCatchDeoptimization: true,
23706
+ unknownGlobalSideEffects: true
23707
+ },
23708
+ smallest: {
23709
+ annotations: true,
23710
+ correctVarValueBeforeDeclaration: false,
23711
+ manualPureFunctions: EMPTY_ARRAY,
23712
+ moduleSideEffects: () => false,
23713
+ propertyReadSideEffects: false,
23714
+ tryCatchDeoptimization: false,
23715
+ unknownGlobalSideEffects: false
23716
+ }
23717
+ };
23718
+ const generatedCodePresets = {
23719
+ es2015: {
23720
+ arrowFunctions: true,
23721
+ constBindings: true,
23722
+ objectShorthand: true,
23723
+ reservedNamesAsProps: true,
23724
+ symbols: true
23725
+ },
23726
+ es5: {
23727
+ arrowFunctions: false,
23728
+ constBindings: false,
23729
+ objectShorthand: false,
23730
+ reservedNamesAsProps: true,
23731
+ symbols: false
23732
+ }
23733
+ };
23734
+ const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
23735
+ const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
23736
+ if (typeof value === 'string') {
23737
+ const preset = presets[value];
23738
+ if (preset) {
23739
+ return preset;
23740
+ }
23741
+ error(logInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
23742
+ }
23743
+ return objectifyOption(value);
23744
+ };
23745
+ const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
23746
+ const presetName = value?.preset;
23747
+ if (presetName) {
23748
+ const preset = presets[presetName];
23749
+ if (preset) {
23750
+ return { ...preset, ...value };
23751
+ }
23752
+ else {
23753
+ error(logInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
23754
+ }
23755
+ }
23756
+ return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
23757
+ };
23758
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
23759
+
23760
+ async function transform(source, module, pluginDriver, log) {
23590
23761
  const id = module.id;
23591
23762
  const sourcemapChain = [];
23592
23763
  let originalSourcemap = source.map === null ? null : decodedSourcemap(source.map);
@@ -23608,7 +23779,7 @@ async function transform(source, module, pluginDriver, warn) {
23608
23779
  module.updateOptions(result);
23609
23780
  if (result.code == null) {
23610
23781
  if (result.map || result.ast) {
23611
- warn(errorNoTransformMapOrAstWithoutCode(plugin.name));
23782
+ log(LOGLEVEL_WARN, logNoTransformMapOrAstWithoutCode(plugin.name));
23612
23783
  }
23613
23784
  return previousCode;
23614
23785
  }
@@ -23627,6 +23798,14 @@ async function transform(source, module, pluginDriver, warn) {
23627
23798
  }
23628
23799
  return code;
23629
23800
  }
23801
+ const getLogHandler = (handler) => (log, pos) => {
23802
+ log = normalizeLog(log);
23803
+ if (pos)
23804
+ augmentCodeLocation(log, pos, currentSource, id);
23805
+ log.id = id;
23806
+ log.hook = 'transform';
23807
+ handler(log);
23808
+ };
23630
23809
  let code;
23631
23810
  try {
23632
23811
  code = await pluginDriver.hookReduceArg0('transform', [currentSource, id], transformReducer, (pluginContext, plugin) => {
@@ -23640,6 +23819,7 @@ async function transform(source, module, pluginDriver, warn) {
23640
23819
  cache: customTransformCache
23641
23820
  ? pluginContext.cache
23642
23821
  : getTrackedPluginCache(pluginContext.cache, useCustomTransformCache),
23822
+ debug: getLogHandler(pluginContext.debug),
23643
23823
  emitFile(emittedFile) {
23644
23824
  emittedFiles.push(emittedFile);
23645
23825
  return pluginDriver.emitFile(emittedFile);
@@ -23654,7 +23834,7 @@ async function transform(source, module, pluginDriver, warn) {
23654
23834
  return pluginContext.error(error_);
23655
23835
  },
23656
23836
  getCombinedSourcemap() {
23657
- const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, warn);
23837
+ const combinedMap = collapseSourcemap(id, originalCode, originalSourcemap, sourcemapChain, log);
23658
23838
  if (!combinedMap) {
23659
23839
  const magicString = new MagicString(originalCode);
23660
23840
  return magicString.generateMap({ hires: true, includeContent: true, source: id });
@@ -23669,23 +23849,16 @@ async function transform(source, module, pluginDriver, warn) {
23669
23849
  sourcesContent: combinedMap.sourcesContent
23670
23850
  });
23671
23851
  },
23852
+ info: getLogHandler(pluginContext.info),
23672
23853
  setAssetSource() {
23673
- return this.error(errorInvalidSetAssetSourceCall());
23854
+ return this.error(logInvalidSetAssetSourceCall());
23674
23855
  },
23675
- warn(warning, pos) {
23676
- if (typeof warning === 'string')
23677
- warning = { message: warning };
23678
- if (pos)
23679
- augmentCodeLocation(warning, pos, currentSource, id);
23680
- warning.id = id;
23681
- warning.hook = 'transform';
23682
- pluginContext.warn(warning);
23683
- }
23856
+ warn: getLogHandler(pluginContext.warn)
23684
23857
  };
23685
23858
  });
23686
23859
  }
23687
23860
  catch (error_) {
23688
- return error(errorPluginError(error_, pluginName, { hook: 'transform', id }));
23861
+ return error(logPluginError(error_, pluginName, { hook: 'transform', id }));
23689
23862
  }
23690
23863
  if (!customTransformCache && // files emitted by a transform hook need to be emitted again if the hook is skipped
23691
23864
  emittedFiles.length > 0)
@@ -23811,7 +23984,7 @@ class ModuleLoader {
23811
23984
  ? { code: source }
23812
23985
  : source != null && typeof source === 'object' && typeof source.code === 'string'
23813
23986
  ? source
23814
- : error(errorBadLoader(id));
23987
+ : error(logBadLoader(id));
23815
23988
  const cachedModule = this.graph.cachedModules.get(id);
23816
23989
  if (cachedModule &&
23817
23990
  !cachedModule.customTransformCache &&
@@ -23835,7 +24008,7 @@ class ModuleLoader {
23835
24008
  }
23836
24009
  else {
23837
24010
  module.updateOptions(sourceDescription);
23838
- module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onwarn));
24011
+ module.setSource(await transform(sourceDescription, module, this.pluginDriver, this.options.onLog));
23839
24012
  }
23840
24013
  }
23841
24014
  async awaitLoadModulesPromise() {
@@ -23881,7 +24054,7 @@ class ModuleLoader {
23881
24054
  const existingModule = this.modulesById.get(id);
23882
24055
  if (existingModule instanceof Module) {
23883
24056
  if (importer && doAssertionsDiffer(assertions, existingModule.info.assertions)) {
23884
- this.options.onwarn(errorInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
24057
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingModule.info.assertions, assertions, id, importer));
23885
24058
  }
23886
24059
  await this.handleExistingModule(existingModule, isEntry, isPreload);
23887
24060
  return existingModule;
@@ -23930,10 +24103,10 @@ class ModuleLoader {
23930
24103
  this.modulesById.set(id, externalModule);
23931
24104
  }
23932
24105
  else if (!(externalModule instanceof ExternalModule)) {
23933
- return error(errorInternalIdCannotBeExternal(source, importer));
24106
+ return error(logInternalIdCannotBeExternal(source, importer));
23934
24107
  }
23935
24108
  else if (doAssertionsDiffer(externalModule.info.assertions, assertions)) {
23936
- this.options.onwarn(errorInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
24109
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(externalModule.info.assertions, assertions, source, importer));
23937
24110
  }
23938
24111
  return Promise.resolve(externalModule);
23939
24112
  }
@@ -24043,9 +24216,9 @@ class ModuleLoader {
24043
24216
  handleInvalidResolvedId(resolvedId, source, importer, assertions) {
24044
24217
  if (resolvedId === null) {
24045
24218
  if (isRelative(source)) {
24046
- return error(errorUnresolvedImport(source, importer));
24219
+ return error(logUnresolvedImport(source, importer));
24047
24220
  }
24048
- this.options.onwarn(errorUnresolvedImportTreatedAsExternal(source, importer));
24221
+ this.options.onLog(LOGLEVEL_WARN, logUnresolvedImportTreatedAsExternal(source, importer));
24049
24222
  return {
24050
24223
  assertions,
24051
24224
  external: true,
@@ -24057,7 +24230,7 @@ class ModuleLoader {
24057
24230
  };
24058
24231
  }
24059
24232
  else if (resolvedId.external && resolvedId.syntheticNamedExports) {
24060
- this.options.onwarn(errorExternalSyntheticExports(source, importer));
24233
+ this.options.onLog(LOGLEVEL_WARN, logExternalSyntheticExports(source, importer));
24061
24234
  }
24062
24235
  return resolvedId;
24063
24236
  }
@@ -24065,14 +24238,14 @@ class ModuleLoader {
24065
24238
  const resolveIdResult = await resolveId(unresolvedId, importer, this.options.preserveSymlinks, this.pluginDriver, this.resolveId, null, EMPTY_OBJECT, true, EMPTY_OBJECT);
24066
24239
  if (resolveIdResult == null) {
24067
24240
  return error(implicitlyLoadedBefore === null
24068
- ? errorUnresolvedEntry(unresolvedId)
24069
- : errorUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
24241
+ ? logUnresolvedEntry(unresolvedId)
24242
+ : logUnresolvedImplicitDependant(unresolvedId, implicitlyLoadedBefore));
24070
24243
  }
24071
24244
  if (resolveIdResult === false ||
24072
24245
  (typeof resolveIdResult === 'object' && resolveIdResult.external)) {
24073
24246
  return error(implicitlyLoadedBefore === null
24074
- ? errorEntryCannotBeExternal(unresolvedId)
24075
- : errorImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
24247
+ ? logEntryCannotBeExternal(unresolvedId)
24248
+ : logImplicitDependantCannotBeExternal(unresolvedId, implicitlyLoadedBefore));
24076
24249
  }
24077
24250
  return this.fetchModule(this.getResolvedIdWithDefaults(typeof resolveIdResult === 'object'
24078
24251
  ? resolveIdResult
@@ -24097,7 +24270,7 @@ class ModuleLoader {
24097
24270
  const existingResolution = module.resolvedIds[specifier];
24098
24271
  if (existingResolution) {
24099
24272
  if (doAssertionsDiffer(existingResolution.assertions, assertions)) {
24100
- this.options.onwarn(errorInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
24273
+ this.options.onLog(LOGLEVEL_WARN, logInconsistentImportAssertions(existingResolution.assertions, assertions, specifier, importer));
24101
24274
  }
24102
24275
  return existingResolution;
24103
24276
  }
@@ -24165,9 +24338,9 @@ function generateAssetFileName(name, source, sourceHash, outputOptions, bundle)
24165
24338
  name: () => emittedName.slice(0, Math.max(0, emittedName.length - extname(emittedName).length))
24166
24339
  }), bundle);
24167
24340
  }
24168
- function reserveFileNameInBundle(fileName, { bundle }, warn) {
24341
+ function reserveFileNameInBundle(fileName, { bundle }, log) {
24169
24342
  if (bundle[lowercaseBundleKeys].has(fileName.toLowerCase())) {
24170
- warn(errorFileNameConflict(fileName));
24343
+ log(LOGLEVEL_WARN, logFileNameConflict(fileName));
24171
24344
  }
24172
24345
  else {
24173
24346
  bundle[fileName] = FILE_PLACEHOLDER;
@@ -24185,13 +24358,13 @@ function hasValidName(emittedFile) {
24185
24358
  function getValidSource(source, emittedFile, fileReferenceId) {
24186
24359
  if (!(typeof source === 'string' || source instanceof Uint8Array)) {
24187
24360
  const assetName = emittedFile.fileName || emittedFile.name || fileReferenceId;
24188
- 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.`));
24361
+ 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.`));
24189
24362
  }
24190
24363
  return source;
24191
24364
  }
24192
24365
  function getAssetFileName(file, referenceId) {
24193
24366
  if (typeof file.fileName !== 'string') {
24194
- return error(errorAssetNotFinalisedForFileName(file.name || referenceId));
24367
+ return error(logAssetNotFinalisedForFileName(file.name || referenceId));
24195
24368
  }
24196
24369
  return file.fileName;
24197
24370
  }
@@ -24202,7 +24375,7 @@ function getChunkFileName(file, facadeChunkByModule) {
24202
24375
  if (facadeChunkByModule) {
24203
24376
  return facadeChunkByModule.get(file.module).getFileName();
24204
24377
  }
24205
- return error(errorChunkNotGeneratedForFileName(file.fileName || file.name));
24378
+ return error(logChunkNotGeneratedForFileName(file.fileName || file.name));
24206
24379
  }
24207
24380
  class FileEmitter {
24208
24381
  constructor(graph, options, baseFileEmitter) {
@@ -24214,13 +24387,13 @@ class FileEmitter {
24214
24387
  this.outputFileEmitters = [];
24215
24388
  this.emitFile = (emittedFile) => {
24216
24389
  if (!hasValidType(emittedFile)) {
24217
- return error(errorFailedValidation(`Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${emittedFile && emittedFile.type}".`));
24390
+ return error(logFailedValidation(`Emitted files must be of type "asset", "chunk" or "prebuilt-chunk", received "${emittedFile && emittedFile.type}".`));
24218
24391
  }
24219
24392
  if (emittedFile.type === 'prebuilt-chunk') {
24220
24393
  return this.emitPrebuiltChunk(emittedFile);
24221
24394
  }
24222
24395
  if (!hasValidName(emittedFile)) {
24223
- 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}".`));
24396
+ 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}".`));
24224
24397
  }
24225
24398
  if (emittedFile.type === 'chunk') {
24226
24399
  return this.emitChunk(emittedFile);
@@ -24230,13 +24403,13 @@ class FileEmitter {
24230
24403
  this.finaliseAssets = () => {
24231
24404
  for (const [referenceId, emittedFile] of this.filesByReferenceId) {
24232
24405
  if (emittedFile.type === 'asset' && typeof emittedFile.fileName !== 'string')
24233
- return error(errorNoAssetSourceSet(emittedFile.name || referenceId));
24406
+ return error(logNoAssetSourceSet(emittedFile.name || referenceId));
24234
24407
  }
24235
24408
  };
24236
24409
  this.getFileName = (fileReferenceId) => {
24237
24410
  const emittedFile = this.filesByReferenceId.get(fileReferenceId);
24238
24411
  if (!emittedFile)
24239
- return error(errorFileReferenceIdNotFoundForFilename(fileReferenceId));
24412
+ return error(logFileReferenceIdNotFoundForFilename(fileReferenceId));
24240
24413
  if (emittedFile.type === 'chunk') {
24241
24414
  return getChunkFileName(emittedFile, this.facadeChunkByModule);
24242
24415
  }
@@ -24248,12 +24421,12 @@ class FileEmitter {
24248
24421
  this.setAssetSource = (referenceId, requestedSource) => {
24249
24422
  const consumedFile = this.filesByReferenceId.get(referenceId);
24250
24423
  if (!consumedFile)
24251
- return error(errorAssetReferenceIdNotFoundForSetSource(referenceId));
24424
+ return error(logAssetReferenceIdNotFoundForSetSource(referenceId));
24252
24425
  if (consumedFile.type !== 'asset') {
24253
- return error(errorFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
24426
+ return error(logFailedValidation(`Asset sources can only be set for emitted assets but "${referenceId}" is an emitted chunk.`));
24254
24427
  }
24255
24428
  if (consumedFile.source !== undefined) {
24256
- return error(errorAssetSourceAlreadySet(consumedFile.name || referenceId));
24429
+ return error(logAssetSourceAlreadySet(consumedFile.name || referenceId));
24257
24430
  }
24258
24431
  const source = getValidSource(requestedSource, consumedFile, referenceId);
24259
24432
  if (this.output) {
@@ -24277,7 +24450,7 @@ class FileEmitter {
24277
24450
  });
24278
24451
  for (const emittedFile of this.filesByReferenceId.values()) {
24279
24452
  if (emittedFile.fileName) {
24280
- reserveFileNameInBundle(emittedFile.fileName, output, this.options.onwarn);
24453
+ reserveFileNameInBundle(emittedFile.fileName, output, this.options.onLog);
24281
24454
  }
24282
24455
  }
24283
24456
  const consumedAssetsByHash = new Map();
@@ -24367,7 +24540,7 @@ class FileEmitter {
24367
24540
  emitAssetWithReferenceId(consumedAsset, output) {
24368
24541
  const { fileName, source } = consumedAsset;
24369
24542
  if (fileName) {
24370
- reserveFileNameInBundle(fileName, output, this.options.onwarn);
24543
+ reserveFileNameInBundle(fileName, output, this.options.onLog);
24371
24544
  }
24372
24545
  if (source !== undefined) {
24373
24546
  this.finalizeAdditionalAsset(consumedAsset, source, output);
@@ -24375,10 +24548,10 @@ class FileEmitter {
24375
24548
  }
24376
24549
  emitChunk(emittedChunk) {
24377
24550
  if (this.graph.phase > BuildPhase.LOAD_AND_PARSE) {
24378
- return error(errorInvalidRollupPhaseForChunkEmission());
24551
+ return error(logInvalidRollupPhaseForChunkEmission());
24379
24552
  }
24380
24553
  if (typeof emittedChunk.id !== 'string') {
24381
- return error(errorFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
24554
+ return error(logFailedValidation(`Emitted chunks need to have a valid string id, received "${emittedChunk.id}"`));
24382
24555
  }
24383
24556
  const consumedChunk = {
24384
24557
  fileName: emittedChunk.fileName,
@@ -24398,11 +24571,11 @@ class FileEmitter {
24398
24571
  }
24399
24572
  emitPrebuiltChunk(emitPrebuiltChunk) {
24400
24573
  if (typeof emitPrebuiltChunk.code !== 'string') {
24401
- return error(errorFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`));
24574
+ return error(logFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${emitPrebuiltChunk.code}".`));
24402
24575
  }
24403
24576
  if (typeof emitPrebuiltChunk.fileName !== 'string' ||
24404
24577
  isPathFragment(emitPrebuiltChunk.fileName)) {
24405
- return error(errorFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`));
24578
+ return error(logFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${emitPrebuiltChunk.fileName}".`));
24406
24579
  }
24407
24580
  const consumedPrebuiltChunk = {
24408
24581
  code: emitPrebuiltChunk.code,
@@ -24477,7 +24650,26 @@ class FileEmitter {
24477
24650
  }
24478
24651
  }
24479
24652
 
24653
+ function getLogHandler(level, code, logger, pluginName, logLevel) {
24654
+ if (logLevelPriority[level] < logLevelPriority[logLevel]) {
24655
+ return doNothing;
24656
+ }
24657
+ return (log, pos) => {
24658
+ if (pos != null) {
24659
+ logger(LOGLEVEL_WARN, logInvalidLogPosition(pluginName));
24660
+ }
24661
+ log = normalizeLog(log);
24662
+ if (log.code && !log.pluginCode) {
24663
+ log.pluginCode = log.code;
24664
+ }
24665
+ log.code = code;
24666
+ log.plugin = pluginName;
24667
+ logger(level, log);
24668
+ };
24669
+ }
24670
+
24480
24671
  function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, existingPluginNames) {
24672
+ const { logLevel, onLog } = options;
24481
24673
  let cacheable = true;
24482
24674
  if (typeof plugin.cacheKey !== 'string') {
24483
24675
  if (plugin.name.startsWith(ANONYMOUS_PLUGIN_PREFIX) ||
@@ -24503,19 +24695,21 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
24503
24695
  return {
24504
24696
  addWatchFile(id) {
24505
24697
  if (graph.phase >= BuildPhase.GENERATE) {
24506
- return this.error(errorInvalidRollupPhaseForAddWatchFile());
24698
+ return this.error(logInvalidRollupPhaseForAddWatchFile());
24507
24699
  }
24508
24700
  graph.watchFiles[id] = true;
24509
24701
  },
24510
24702
  cache: cacheInstance,
24703
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
24511
24704
  emitFile: fileEmitter.emitFile.bind(fileEmitter),
24512
24705
  error(error_) {
24513
- return error(errorPluginError(error_, plugin.name));
24706
+ return error(logPluginError(normalizeLog(error_), plugin.name));
24514
24707
  },
24515
24708
  getFileName: fileEmitter.getFileName,
24516
24709
  getModuleIds: () => graph.modulesById.keys(),
24517
24710
  getModuleInfo: graph.getModuleInfo,
24518
24711
  getWatchFiles: () => Object.keys(graph.watchFiles),
24712
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', onLog, plugin.name, logLevel),
24519
24713
  load(resolvedId) {
24520
24714
  return graph.moduleLoader.preloadModule(resolvedId);
24521
24715
  },
@@ -24537,15 +24731,7 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
24537
24731
  return graph.moduleLoader.resolveId(source, importer, custom, isEntry, assertions || EMPTY_OBJECT, skipSelf ? [{ importer, plugin, source }] : null);
24538
24732
  },
24539
24733
  setAssetSource: fileEmitter.setAssetSource,
24540
- warn(warning) {
24541
- if (typeof warning === 'string')
24542
- warning = { message: warning };
24543
- if (warning.code)
24544
- warning.pluginCode = warning.code;
24545
- warning.code = 'PLUGIN_WARNING';
24546
- warning.plugin = plugin.name;
24547
- options.onwarn(warning);
24548
- }
24734
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', onLog, plugin.name, logLevel)
24549
24735
  };
24550
24736
  }
24551
24737
 
@@ -24557,6 +24743,7 @@ const inputHookNames = {
24557
24743
  closeWatcher: 1,
24558
24744
  load: 1,
24559
24745
  moduleParsed: 1,
24746
+ onLog: 1,
24560
24747
  options: 1,
24561
24748
  resolveDynamicImport: 1,
24562
24749
  resolveId: 1,
@@ -24588,7 +24775,7 @@ class PluginDriver {
24588
24775
  for (const plugin of userPlugins) {
24589
24776
  for (const hook of inputHooks) {
24590
24777
  if (hook in plugin) {
24591
- options.onwarn(errorInputHookInOutputPlugin(plugin.name, hook));
24778
+ options.onLog(LOGLEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
24592
24779
  }
24593
24780
  }
24594
24781
  }
@@ -24735,7 +24922,7 @@ class PluginDriver {
24735
24922
  // action considered to be fulfilled since error being handled
24736
24923
  this.unfulfilledActions.delete(action);
24737
24924
  }
24738
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24925
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24739
24926
  });
24740
24927
  }
24741
24928
  /**
@@ -24757,7 +24944,7 @@ class PluginDriver {
24757
24944
  return handler.apply(context, parameters);
24758
24945
  }
24759
24946
  catch (error_) {
24760
- return error(errorPluginError(error_, plugin.name, { hook: hookName }));
24947
+ return error(logPluginError(error_, plugin.name, { hook: hookName }));
24761
24948
  }
24762
24949
  }
24763
24950
  }
@@ -24789,12 +24976,12 @@ function getSortedValidatedPlugins(hookName, plugins, validateHandler = validate
24789
24976
  }
24790
24977
  function validateFunctionPluginHandler(handler, hookName, plugin) {
24791
24978
  if (typeof handler !== 'function') {
24792
- error(errorInvalidFunctionPluginHook(hookName, plugin.name));
24979
+ error(logInvalidFunctionPluginHook(hookName, plugin.name));
24793
24980
  }
24794
24981
  }
24795
24982
  function validateAddonPluginHandler(handler, hookName, plugin) {
24796
24983
  if (typeof handler !== 'string' && typeof handler !== 'function') {
24797
- return error(errorInvalidAddonPluginHook(hookName, plugin.name));
24984
+ return error(logInvalidAddonPluginHook(hookName, plugin.name));
24798
24985
  }
24799
24986
  }
24800
24987
  function noReturn() { }
@@ -25006,7 +25193,7 @@ class Graph {
25006
25193
  for (const module of this.implicitEntryModules) {
25007
25194
  for (const dependant of module.implicitlyLoadedAfter) {
25008
25195
  if (!(dependant.info.isEntry || dependant.isIncluded())) {
25009
- error(errorImplicitDependantIsNotIncluded(dependant));
25196
+ error(logImplicitDependantIsNotIncluded(dependant));
25010
25197
  }
25011
25198
  }
25012
25199
  }
@@ -25014,7 +25201,7 @@ class Graph {
25014
25201
  sortModules() {
25015
25202
  const { orderedModules, cyclePaths } = analyseModuleExecution(this.entryModules);
25016
25203
  for (const cyclePath of cyclePaths) {
25017
- this.options.onwarn(errorCircularDependency(cyclePath));
25204
+ this.options.onLog(LOGLEVEL_WARN, logCircularDependency(cyclePath));
25018
25205
  }
25019
25206
  this.modules = orderedModules;
25020
25207
  for (const module of this.modules) {
@@ -25027,7 +25214,7 @@ class Graph {
25027
25214
  for (const importDescription of module.importDescriptions.values()) {
25028
25215
  if (importDescription.name !== '*' &&
25029
25216
  !importDescription.module.getVariableForExportName(importDescription.name)[0]) {
25030
- module.warn(errorMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
25217
+ module.log(LOGLEVEL_WARN, logMissingExport(importDescription.name, module.id, importDescription.module.id), importDescription.start);
25031
25218
  }
25032
25219
  }
25033
25220
  }
@@ -25086,6 +25273,40 @@ async function catchUnfinishedHookActions(pluginDriver, callback) {
25086
25273
  }
25087
25274
  }
25088
25275
 
25276
+ function getLogger(plugins, onLog, watchMode, logLevel) {
25277
+ plugins = getSortedValidatedPlugins('onLog', plugins);
25278
+ const minimalPriority = logLevelPriority[logLevel];
25279
+ const logger = (level, log, skipped = EMPTY_SET) => {
25280
+ const logPriority = logLevelPriority[level];
25281
+ if (logPriority < minimalPriority) {
25282
+ return;
25283
+ }
25284
+ for (const plugin of plugins) {
25285
+ if (skipped.has(plugin))
25286
+ continue;
25287
+ const { onLog: pluginOnLog } = plugin;
25288
+ const getLogHandler = (level) => {
25289
+ if (logLevelPriority[level] < minimalPriority) {
25290
+ return doNothing;
25291
+ }
25292
+ return log => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
25293
+ };
25294
+ const handler = 'handler' in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
25295
+ if (handler.call({
25296
+ debug: getLogHandler(LOGLEVEL_DEBUG),
25297
+ error: (log) => error(normalizeLog(log)),
25298
+ info: getLogHandler(LOGLEVEL_INFO),
25299
+ meta: { rollupVersion: version$1, watchMode },
25300
+ warn: getLogHandler(LOGLEVEL_WARN)
25301
+ }, level, log) === false) {
25302
+ return;
25303
+ }
25304
+ }
25305
+ onLog(level, log);
25306
+ };
25307
+ return logger;
25308
+ }
25309
+
25089
25310
  const leftCurlyBrace = "{".charCodeAt(0);
25090
25311
  const space = " ".charCodeAt(0);
25091
25312
 
@@ -25337,100 +25558,16 @@ function ensureArray(items) {
25337
25558
  return [];
25338
25559
  }
25339
25560
 
25340
- async function asyncFlatten(array) {
25341
- do {
25342
- array = (await Promise.all(array)).flat(Infinity);
25343
- } while (array.some((v) => v?.then));
25344
- return array;
25345
- }
25346
-
25347
- const defaultOnWarn = warning => console.warn(warning.message || warning);
25348
- function warnUnknownOptions(passedOptions, validOptions, optionType, warn, ignoredKeys = /$./) {
25349
- const validOptionSet = new Set(validOptions);
25350
- const unknownOptions = Object.keys(passedOptions).filter(key => !(validOptionSet.has(key) || ignoredKeys.test(key)));
25351
- if (unknownOptions.length > 0) {
25352
- warn(errorUnknownOption(optionType, unknownOptions, [...validOptionSet].sort()));
25353
- }
25354
- }
25355
- const treeshakePresets = {
25356
- recommended: {
25357
- annotations: true,
25358
- correctVarValueBeforeDeclaration: false,
25359
- manualPureFunctions: EMPTY_ARRAY,
25360
- moduleSideEffects: () => true,
25361
- propertyReadSideEffects: true,
25362
- tryCatchDeoptimization: true,
25363
- unknownGlobalSideEffects: false
25364
- },
25365
- safest: {
25366
- annotations: true,
25367
- correctVarValueBeforeDeclaration: true,
25368
- manualPureFunctions: EMPTY_ARRAY,
25369
- moduleSideEffects: () => true,
25370
- propertyReadSideEffects: true,
25371
- tryCatchDeoptimization: true,
25372
- unknownGlobalSideEffects: true
25373
- },
25374
- smallest: {
25375
- annotations: true,
25376
- correctVarValueBeforeDeclaration: false,
25377
- manualPureFunctions: EMPTY_ARRAY,
25378
- moduleSideEffects: () => false,
25379
- propertyReadSideEffects: false,
25380
- tryCatchDeoptimization: false,
25381
- unknownGlobalSideEffects: false
25382
- }
25383
- };
25384
- const generatedCodePresets = {
25385
- es2015: {
25386
- arrowFunctions: true,
25387
- constBindings: true,
25388
- objectShorthand: true,
25389
- reservedNamesAsProps: true,
25390
- symbols: true
25391
- },
25392
- es5: {
25393
- arrowFunctions: false,
25394
- constBindings: false,
25395
- objectShorthand: false,
25396
- reservedNamesAsProps: true,
25397
- symbols: false
25398
- }
25399
- };
25400
- const objectifyOption = (value) => value && typeof value === 'object' ? value : {};
25401
- const objectifyOptionWithPresets = (presets, optionName, urlSnippet, additionalValues) => (value) => {
25402
- if (typeof value === 'string') {
25403
- const preset = presets[value];
25404
- if (preset) {
25405
- return preset;
25406
- }
25407
- error(errorInvalidOption(optionName, urlSnippet, `valid values are ${additionalValues}${printQuotedStringList(Object.keys(presets))}. You can also supply an object for more fine-grained control`, value));
25408
- }
25409
- return objectifyOption(value);
25410
- };
25411
- const getOptionWithPreset = (value, presets, optionName, urlSnippet, additionalValues) => {
25412
- const presetName = value?.preset;
25413
- if (presetName) {
25414
- const preset = presets[presetName];
25415
- if (preset) {
25416
- return { ...preset, ...value };
25417
- }
25418
- else {
25419
- error(errorInvalidOption(`${optionName}.preset`, urlSnippet, `valid values are ${printQuotedStringList(Object.keys(presets))}`, presetName));
25420
- }
25421
- }
25422
- return objectifyOptionWithPresets(presets, optionName, urlSnippet, additionalValues)(value);
25423
- };
25424
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
25425
-
25426
- async function normalizeInputOptions(config) {
25561
+ async function normalizeInputOptions(config, watchMode) {
25427
25562
  // These are options that may trigger special warnings or behaviour later
25428
25563
  // if the user did not select an explicit value
25429
25564
  const unsetOptions = new Set();
25430
25565
  const context = config.context ?? 'undefined';
25431
- const onwarn = getOnwarn(config);
25566
+ const plugins = await normalizePluginOption(config.plugins);
25567
+ const logLevel = config.logLevel || LOGLEVEL_INFO;
25568
+ const onLog = getLogger(plugins, getOnLog(config, logLevel), watchMode, logLevel);
25432
25569
  const strictDeprecations = config.strictDeprecations || false;
25433
- const maxParallelFileOps = getmaxParallelFileOps(config, onwarn, strictDeprecations);
25570
+ const maxParallelFileOps = getMaxParallelFileOps(config, onLog, strictDeprecations);
25434
25571
  const options = {
25435
25572
  acorn: getAcorn(config),
25436
25573
  acornInjectPlugins: getAcornInjectPlugins(config),
@@ -25439,43 +25576,28 @@ async function normalizeInputOptions(config) {
25439
25576
  experimentalCacheExpiry: config.experimentalCacheExpiry ?? 10,
25440
25577
  experimentalLogSideEffects: config.experimentalLogSideEffects || false,
25441
25578
  external: getIdMatcher(config.external),
25442
- inlineDynamicImports: getInlineDynamicImports$1(config, onwarn, strictDeprecations),
25579
+ inlineDynamicImports: getInlineDynamicImports$1(config, onLog, strictDeprecations),
25443
25580
  input: getInput(config),
25581
+ logLevel,
25444
25582
  makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
25445
- manualChunks: getManualChunks$1(config, onwarn, strictDeprecations),
25583
+ manualChunks: getManualChunks$1(config, onLog, strictDeprecations),
25446
25584
  maxParallelFileOps,
25447
25585
  maxParallelFileReads: maxParallelFileOps,
25448
25586
  moduleContext: getModuleContext(config, context),
25449
- onwarn,
25587
+ onLog,
25588
+ onwarn: warning => onLog(LOGLEVEL_WARN, warning),
25450
25589
  perf: config.perf || false,
25451
- plugins: await normalizePluginOption(config.plugins),
25590
+ plugins,
25452
25591
  preserveEntrySignatures: config.preserveEntrySignatures ?? 'exports-only',
25453
- preserveModules: getPreserveModules$1(config, onwarn, strictDeprecations),
25592
+ preserveModules: getPreserveModules$1(config, onLog, strictDeprecations),
25454
25593
  preserveSymlinks: config.preserveSymlinks || false,
25455
25594
  shimMissingExports: config.shimMissingExports || false,
25456
25595
  strictDeprecations,
25457
25596
  treeshake: getTreeshake(config)
25458
25597
  };
25459
- warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', options.onwarn, /^(output)$/);
25598
+ warnUnknownOptions(config, [...Object.keys(options), 'watch'], 'input options', onLog, /^(output)$/);
25460
25599
  return { options, unsetOptions };
25461
25600
  }
25462
- const getOnwarn = (config) => {
25463
- const { onwarn } = config;
25464
- return onwarn
25465
- ? warning => {
25466
- warning.toString = () => {
25467
- let warningString = '';
25468
- if (warning.plugin)
25469
- warningString += `(${warning.plugin} plugin) `;
25470
- if (warning.loc)
25471
- warningString += `${relativeId(warning.loc.file)} (${warning.loc.line}:${warning.loc.column}) `;
25472
- warningString += warning.message;
25473
- return warningString;
25474
- };
25475
- onwarn(warning, defaultOnWarn);
25476
- }
25477
- : defaultOnWarn;
25478
- };
25479
25601
  const getAcorn = (config) => ({
25480
25602
  ecmaVersion: 'latest',
25481
25603
  sourceType: 'module',
@@ -25510,10 +25632,10 @@ const getIdMatcher = (option) => {
25510
25632
  }
25511
25633
  return () => false;
25512
25634
  };
25513
- const getInlineDynamicImports$1 = (config, warn, strictDeprecations) => {
25635
+ const getInlineDynamicImports$1 = (config, log, strictDeprecations) => {
25514
25636
  const configInlineDynamicImports = config.inlineDynamicImports;
25515
25637
  if (configInlineDynamicImports) {
25516
- warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, warn, strictDeprecations);
25638
+ warnDeprecationWithOptions('The "inlineDynamicImports" option is deprecated. Use the "output.inlineDynamicImports" option instead.', URL_OUTPUT_INLINEDYNAMICIMPORTS, true, log, strictDeprecations);
25517
25639
  }
25518
25640
  return configInlineDynamicImports;
25519
25641
  };
@@ -25521,17 +25643,17 @@ const getInput = (config) => {
25521
25643
  const configInput = config.input;
25522
25644
  return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput;
25523
25645
  };
25524
- const getManualChunks$1 = (config, warn, strictDeprecations) => {
25646
+ const getManualChunks$1 = (config, log, strictDeprecations) => {
25525
25647
  const configManualChunks = config.manualChunks;
25526
25648
  if (configManualChunks) {
25527
- warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, warn, strictDeprecations);
25649
+ warnDeprecationWithOptions('The "manualChunks" option is deprecated. Use the "output.manualChunks" option instead.', URL_OUTPUT_MANUALCHUNKS, true, log, strictDeprecations);
25528
25650
  }
25529
25651
  return configManualChunks;
25530
25652
  };
25531
- const getmaxParallelFileOps = (config, warn, strictDeprecations) => {
25653
+ const getMaxParallelFileOps = (config, log, strictDeprecations) => {
25532
25654
  const maxParallelFileReads = config.maxParallelFileReads;
25533
25655
  if (typeof maxParallelFileReads === 'number') {
25534
- warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, warn, strictDeprecations);
25656
+ warnDeprecationWithOptions('The "maxParallelFileReads" option is deprecated. Use the "maxParallelFileOps" option instead.', URL_MAXPARALLELFILEOPS, true, log, strictDeprecations);
25535
25657
  }
25536
25658
  const maxParallelFileOps = config.maxParallelFileOps ?? maxParallelFileReads;
25537
25659
  if (typeof maxParallelFileOps === 'number') {
@@ -25555,10 +25677,10 @@ const getModuleContext = (config, context) => {
25555
25677
  }
25556
25678
  return () => context;
25557
25679
  };
25558
- const getPreserveModules$1 = (config, warn, strictDeprecations) => {
25680
+ const getPreserveModules$1 = (config, log, strictDeprecations) => {
25559
25681
  const configPreserveModules = config.preserveModules;
25560
25682
  if (configPreserveModules) {
25561
- warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, warn, strictDeprecations);
25683
+ warnDeprecationWithOptions('The "preserveModules" option is deprecated. Use the "output.preserveModules" option instead.', URL_OUTPUT_PRESERVEMODULES, true, log, strictDeprecations);
25562
25684
  }
25563
25685
  return configPreserveModules;
25564
25686
  };
@@ -25595,7 +25717,7 @@ const getHasModuleSideEffects = (moduleSideEffectsOption) => {
25595
25717
  return id => ids.has(id);
25596
25718
  }
25597
25719
  if (moduleSideEffectsOption) {
25598
- error(errorInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
25720
+ error(logInvalidOption('treeshake.moduleSideEffects', URL_TREESHAKE_MODULESIDEEFFECTS, 'please use one of false, "no-external", a function or an array'));
25599
25721
  }
25600
25722
  return () => true;
25601
25723
  };
@@ -25681,17 +25803,17 @@ async function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
25681
25803
  systemNullSetters: config.systemNullSetters ?? true,
25682
25804
  validate: config.validate || false
25683
25805
  };
25684
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
25806
+ warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onLog);
25685
25807
  return { options: outputOptions, unsetOptions };
25686
25808
  }
25687
25809
  const getFile = (config, preserveModules, inputOptions) => {
25688
25810
  const { file } = config;
25689
25811
  if (typeof file === 'string') {
25690
25812
  if (preserveModules) {
25691
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25813
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when using the "output.preserveModules" option'));
25692
25814
  }
25693
25815
  if (!Array.isArray(inputOptions.input))
25694
- return error(errorInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25816
+ return error(logInvalidOption('output.file', URL_OUTPUT_DIR, 'you must set "output.dir" instead of "output.file" when providing named inputs'));
25695
25817
  }
25696
25818
  return file;
25697
25819
  };
@@ -25718,7 +25840,7 @@ const getFormat = (config) => {
25718
25840
  return configFormat;
25719
25841
  }
25720
25842
  default: {
25721
- return error(errorInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25843
+ return error(logInvalidOption('output.format', URL_OUTPUT_FORMAT, `Valid values are "amd", "cjs", "system", "es", "iife" or "umd"`, configFormat));
25722
25844
  }
25723
25845
  }
25724
25846
  };
@@ -25726,7 +25848,7 @@ const getInlineDynamicImports = (config, inputOptions) => {
25726
25848
  const inlineDynamicImports = (config.inlineDynamicImports ?? inputOptions.inlineDynamicImports) || false;
25727
25849
  const { input } = inputOptions;
25728
25850
  if (inlineDynamicImports && (Array.isArray(input) ? input : Object.keys(input)).length > 1) {
25729
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25851
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, 'multiple inputs are not supported when "output.inlineDynamicImports" is true'));
25730
25852
  }
25731
25853
  return inlineDynamicImports;
25732
25854
  };
@@ -25734,10 +25856,10 @@ const getPreserveModules = (config, inlineDynamicImports, inputOptions) => {
25734
25856
  const preserveModules = (config.preserveModules ?? inputOptions.preserveModules) || false;
25735
25857
  if (preserveModules) {
25736
25858
  if (inlineDynamicImports) {
25737
- return error(errorInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25859
+ return error(logInvalidOption('output.inlineDynamicImports', URL_OUTPUT_INLINEDYNAMICIMPORTS, `this option is not supported for "output.preserveModules"`));
25738
25860
  }
25739
25861
  if (inputOptions.preserveEntrySignatures === false) {
25740
- return error(errorInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25862
+ return error(logInvalidOption('preserveEntrySignatures', URL_PRESERVEENTRYSIGNATURES, 'setting this option to false is not supported for "output.preserveModules"'));
25741
25863
  }
25742
25864
  }
25743
25865
  return preserveModules;
@@ -25765,10 +25887,10 @@ const getAmd = (config) => {
25765
25887
  ...config.amd
25766
25888
  };
25767
25889
  if ((mergedOption.autoId || mergedOption.basePath) && mergedOption.id) {
25768
- return error(errorInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25890
+ return error(logInvalidOption('output.amd.id', URL_OUTPUT_AMD_ID, 'this option cannot be used together with "output.amd.autoId"/"output.amd.basePath"'));
25769
25891
  }
25770
25892
  if (mergedOption.basePath && !mergedOption.autoId) {
25771
- return error(errorInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25893
+ return error(logInvalidOption('output.amd.basePath', URL_OUTPUT_AMD_BASEPATH, 'this option only works with "output.amd.autoId"'));
25772
25894
  }
25773
25895
  return mergedOption.autoId
25774
25896
  ? {
@@ -25795,7 +25917,7 @@ const getAddon = (config, name) => {
25795
25917
  const getDir = (config, file) => {
25796
25918
  const { dir } = config;
25797
25919
  if (typeof dir === 'string' && typeof file === 'string') {
25798
- 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'));
25920
+ 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'));
25799
25921
  }
25800
25922
  return dir;
25801
25923
  };
@@ -25804,7 +25926,7 @@ const getDynamicImportFunction = (config, inputOptions, format) => {
25804
25926
  if (configDynamicImportFunction) {
25805
25927
  warnDeprecation(`The "output.dynamicImportFunction" option is deprecated. Use the "renderDynamicImport" plugin hook instead.`, URL_RENDERDYNAMICIMPORT, true, inputOptions);
25806
25928
  if (format !== 'es') {
25807
- inputOptions.onwarn(errorInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25929
+ inputOptions.onLog(LOGLEVEL_WARN, logInvalidOption('output.dynamicImportFunction', URL_OUTPUT_DYNAMICIMPORTFUNCTION, 'this option is ignored for formats other than "es"'));
25808
25930
  }
25809
25931
  }
25810
25932
  return configDynamicImportFunction;
@@ -25829,7 +25951,7 @@ function getExports(config, unsetOptions) {
25829
25951
  unsetOptions.add('exports');
25830
25952
  }
25831
25953
  else if (!['default', 'named', 'none', 'auto'].includes(configExports)) {
25832
- return error(errorInvalidExportOptionValue(configExports));
25954
+ return error(logInvalidExportOptionValue(configExports));
25833
25955
  }
25834
25956
  return configExports || 'auto';
25835
25957
  }
@@ -25872,7 +25994,7 @@ const getInterop = (config) => {
25872
25994
  };
25873
25995
  const validateInterop = (interop) => {
25874
25996
  if (!ALLOWED_INTEROP_TYPES.has(interop)) {
25875
- return error(errorInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25997
+ return error(logInvalidOption('output.interop', URL_OUTPUT_INTEROP,
25876
25998
  // eslint-disable-next-line unicorn/prefer-spread
25877
25999
  `use one of ${Array.from(ALLOWED_INTEROP_TYPES, value => JSON.stringify(value)).join(', ')}`, interop));
25878
26000
  }
@@ -25882,10 +26004,10 @@ const getManualChunks = (config, inlineDynamicImports, preserveModules, inputOpt
25882
26004
  const configManualChunks = config.manualChunks || inputOptions.manualChunks;
25883
26005
  if (configManualChunks) {
25884
26006
  if (inlineDynamicImports) {
25885
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
26007
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.inlineDynamicImports"'));
25886
26008
  }
25887
26009
  if (preserveModules) {
25888
- return error(errorInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
26010
+ return error(logInvalidOption('output.manualChunks', URL_OUTPUT_MANUALCHUNKS, 'this option is not supported for "output.preserveModules"'));
25889
26011
  }
25890
26012
  }
25891
26013
  return configManualChunks || {};
@@ -25905,7 +26027,7 @@ const getSourcemapBaseUrl = (config) => {
25905
26027
  if (isValidUrl(sourcemapBaseUrl)) {
25906
26028
  return addTrailingSlashIfMissed(sourcemapBaseUrl);
25907
26029
  }
25908
- return error(errorInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
26030
+ return error(logInvalidOption('output.sourcemapBaseUrl', URL_OUTPUT_SOURCEMAPBASEURL, `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
25909
26031
  }
25910
26032
  };
25911
26033
 
@@ -25953,13 +26075,13 @@ async function rollupInternal(rawInputOptions, watcher) {
25953
26075
  closed: false,
25954
26076
  async generate(rawOutputOptions) {
25955
26077
  if (result.closed)
25956
- return error(errorAlreadyClosed());
26078
+ return error(logAlreadyClosed());
25957
26079
  return handleGenerateWrite(false, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25958
26080
  },
25959
26081
  watchFiles: Object.keys(graph.watchFiles),
25960
26082
  async write(rawOutputOptions) {
25961
26083
  if (result.closed)
25962
- return error(errorAlreadyClosed());
26084
+ return error(logAlreadyClosed());
25963
26085
  return handleGenerateWrite(true, inputOptions, unsetInputOptions, rawOutputOptions, graph);
25964
26086
  }
25965
26087
  };
@@ -25967,21 +26089,34 @@ async function rollupInternal(rawInputOptions, watcher) {
25967
26089
  result.getTimings = getTimings;
25968
26090
  return result;
25969
26091
  }
25970
- async function getInputOptions(rawInputOptions, watchMode) {
25971
- if (!rawInputOptions) {
26092
+ async function getInputOptions(initialInputOptions, watchMode) {
26093
+ if (!initialInputOptions) {
25972
26094
  throw new Error('You must supply an options object to rollup');
25973
26095
  }
25974
- const rawPlugins = getSortedValidatedPlugins('options', await normalizePluginOption(rawInputOptions.plugins));
25975
- const { options, unsetOptions } = await normalizeInputOptions(await rawPlugins.reduce(applyOptionHook(watchMode), Promise.resolve(rawInputOptions)));
26096
+ const processedInputOptions = await getProcessedInputOptions(initialInputOptions, watchMode);
26097
+ const { options, unsetOptions } = await normalizeInputOptions(processedInputOptions, watchMode);
25976
26098
  normalizePlugins(options.plugins, ANONYMOUS_PLUGIN_PREFIX);
25977
26099
  return { options, unsetOptions };
25978
26100
  }
25979
- function applyOptionHook(watchMode) {
25980
- return async (inputOptions, plugin) => {
25981
- const handler = 'handler' in plugin.options ? plugin.options.handler : plugin.options;
25982
- return ((await handler.call({ meta: { rollupVersion: version$1, watchMode } }, await inputOptions)) ||
25983
- inputOptions);
25984
- };
26101
+ async function getProcessedInputOptions(inputOptions, watchMode) {
26102
+ const plugins = getSortedValidatedPlugins('options', await normalizePluginOption(inputOptions.plugins));
26103
+ const logLevel = inputOptions.logLevel || LOGLEVEL_INFO;
26104
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), watchMode, logLevel);
26105
+ for (const plugin of plugins) {
26106
+ const { name, options } = plugin;
26107
+ const handler = 'handler' in options ? options.handler : options;
26108
+ const processedOptions = await handler.call({
26109
+ debug: getLogHandler(LOGLEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel),
26110
+ error: (error_) => error(logPluginError(normalizeLog(error_), name, { hook: 'onLog' })),
26111
+ info: getLogHandler(LOGLEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel),
26112
+ meta: { rollupVersion: version$1, watchMode },
26113
+ warn: getLogHandler(LOGLEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel)
26114
+ }, inputOptions);
26115
+ if (processedOptions) {
26116
+ inputOptions = processedOptions;
26117
+ }
26118
+ }
26119
+ return inputOptions;
25985
26120
  }
25986
26121
  function normalizePlugins(plugins, anonymousPrefix) {
25987
26122
  for (const [index, plugin] of plugins.entries()) {
@@ -25998,7 +26133,7 @@ async function handleGenerateWrite(isWrite, inputOptions, unsetInputOptions, raw
25998
26133
  if (isWrite) {
25999
26134
  timeStart('WRITE', 1);
26000
26135
  if (!outputOptions.dir && !outputOptions.file) {
26001
- return error(errorMissingFileOrDirOption());
26136
+ return error(logMissingFileOrDirOption());
26002
26137
  }
26003
26138
  await Promise.all(Object.values(generated).map(chunk => graph.fileOperationQueue.run(() => writeOutputFile(chunk, outputOptions))));
26004
26139
  await outputPluginDriver.hookParallel('writeBundle', [outputOptions, generated]);
@@ -26021,7 +26156,7 @@ async function getOutputOptionsAndPluginDriver(rawOutputOptions, inputPluginDriv
26021
26156
  }
26022
26157
  function getOutputOptions(inputOptions, unsetInputOptions, rawOutputOptions, outputPluginDriver) {
26023
26158
  return normalizeOutputOptions(outputPluginDriver.hookReduceArg0Sync('outputOptions', [rawOutputOptions], (outputOptions, result) => result || outputOptions, pluginContext => {
26024
- const emitError = () => pluginContext.error(errorCannotEmitFromOptionsHook());
26159
+ const emitError = () => pluginContext.error(logCannotEmitFromOptionsHook());
26025
26160
  return {
26026
26161
  ...pluginContext,
26027
26162
  emitFile: emitError,
@@ -26057,7 +26192,8 @@ async function writeOutputFile(outputFile, outputOptions) {
26057
26192
  }
26058
26193
  /**
26059
26194
  * Auxiliary function for defining rollup configuration
26060
- * Mainly to facilitate IDE code prompts, after all, export default does not prompt, even if you add @type annotations, it is not accurate
26195
+ * Mainly to facilitate IDE code prompts, after all, export default does not
26196
+ * prompt, even if you add @type annotations, it is not accurate
26061
26197
  * @param options
26062
26198
  */
26063
26199
  function defineConfig(options) {
@@ -26222,17 +26358,20 @@ const commandAliases = {
26222
26358
  w: 'watch'
26223
26359
  };
26224
26360
  const EMPTY_COMMAND_OPTIONS = { external: [], globals: undefined };
26225
- async function mergeOptions(config, rawCommandOptions = EMPTY_COMMAND_OPTIONS, defaultOnWarnHandler = defaultOnWarn) {
26361
+ async function mergeOptions(config, watchMode, rawCommandOptions = EMPTY_COMMAND_OPTIONS, printLog) {
26226
26362
  const command = getCommandOptions(rawCommandOptions);
26227
- const inputOptions = await mergeInputOptions(config, command, defaultOnWarnHandler);
26228
- const warn = inputOptions.onwarn;
26363
+ const plugins = await normalizePluginOption(config.plugins);
26364
+ const logLevel = config.logLevel || LOGLEVEL_INFO;
26365
+ const onLog = getOnLog(config, logLevel, printLog);
26366
+ const log = getLogger(plugins, onLog, watchMode, logLevel);
26367
+ const inputOptions = await mergeInputOptions(config, command, plugins, log, onLog);
26229
26368
  if (command.output) {
26230
26369
  Object.assign(command, command.output);
26231
26370
  }
26232
26371
  const outputOptionsArray = ensureArray(config.output);
26233
26372
  if (outputOptionsArray.length === 0)
26234
26373
  outputOptionsArray.push({});
26235
- const outputOptions = await Promise.all(outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, warn)));
26374
+ const outputOptions = await Promise.all(outputOptionsArray.map(singleOutputOptions => mergeOutputOptions(singleOutputOptions, command, log)));
26236
26375
  warnUnknownOptions(command, [
26237
26376
  ...Object.keys(inputOptions),
26238
26377
  ...Object.keys(outputOptions[0]).filter(option => option !== 'sourcemapIgnoreList' && option !== 'sourcemapPathTransform'),
@@ -26246,7 +26385,7 @@ async function mergeOptions(config, rawCommandOptions = EMPTY_COMMAND_OPTIONS, d
26246
26385
  'stdin',
26247
26386
  'waitForBundleInput',
26248
26387
  'configPlugin'
26249
- ], 'CLI flags', warn, /^_$|output$|config/);
26388
+ ], 'CLI flags', log, /^_$|output$|config/);
26250
26389
  inputOptions.output = outputOptions;
26251
26390
  return inputOptions;
26252
26391
  }
@@ -26269,7 +26408,7 @@ function getCommandOptions(rawCommandOptions) {
26269
26408
  : undefined
26270
26409
  };
26271
26410
  }
26272
- async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26411
+ function mergeInputOptions(config, overrides, plugins, log, onLog) {
26273
26412
  const getOption = (name) => overrides[name] ?? config[name];
26274
26413
  const inputOptions = {
26275
26414
  acorn: getOption('acorn'),
@@ -26281,14 +26420,16 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26281
26420
  external: getExternal(config, overrides),
26282
26421
  inlineDynamicImports: getOption('inlineDynamicImports'),
26283
26422
  input: getOption('input') || [],
26423
+ logLevel: getOption('logLevel'),
26284
26424
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
26285
26425
  manualChunks: getOption('manualChunks'),
26286
26426
  maxParallelFileOps: getOption('maxParallelFileOps'),
26287
26427
  maxParallelFileReads: getOption('maxParallelFileReads'),
26288
26428
  moduleContext: getOption('moduleContext'),
26289
- onwarn: getOnWarn(config, defaultOnWarnHandler),
26429
+ onLog,
26430
+ onwarn: undefined,
26290
26431
  perf: getOption('perf'),
26291
- plugins: await normalizePluginOption(config.plugins),
26432
+ plugins,
26292
26433
  preserveEntrySignatures: getOption('preserveEntrySignatures'),
26293
26434
  preserveModules: getOption('preserveModules'),
26294
26435
  preserveSymlinks: getOption('preserveSymlinks'),
@@ -26297,7 +26438,7 @@ async function mergeInputOptions(config, overrides, defaultOnWarnHandler) {
26297
26438
  treeshake: getObjectOption(config, overrides, 'treeshake', objectifyOptionWithPresets(treeshakePresets, 'treeshake', URL_TREESHAKE, 'false, true, ')),
26298
26439
  watch: getWatch(config, overrides)
26299
26440
  };
26300
- warnUnknownOptions(config, Object.keys(inputOptions), 'input options', inputOptions.onwarn, /^output$/);
26441
+ warnUnknownOptions(config, Object.keys(inputOptions), 'input options', log, /^output$/);
26301
26442
  return inputOptions;
26302
26443
  }
26303
26444
  const getExternal = (config, overrides) => {
@@ -26306,7 +26447,6 @@ const getExternal = (config, overrides) => {
26306
26447
  ? (source, importer, isResolved) => configExternal(source, importer, isResolved) || overrides.external.includes(source)
26307
26448
  : [...ensureArray(configExternal), ...overrides.external];
26308
26449
  };
26309
- const getOnWarn = (config, defaultOnWarnHandler) => config.onwarn ? warning => config.onwarn(warning, defaultOnWarnHandler) : defaultOnWarnHandler;
26310
26450
  const getObjectOption = (config, overrides, name, objectifyValue = objectifyOption) => {
26311
26451
  const commandOption = normalizeObjectOptionValue(overrides[name], objectifyValue);
26312
26452
  const configOption = normalizeObjectOptionValue(config[name], objectifyValue);
@@ -26325,7 +26465,7 @@ const normalizeObjectOptionValue = (optionValue, objectifyValue) => {
26325
26465
  }
26326
26466
  return objectifyValue(optionValue);
26327
26467
  };
26328
- async function mergeOutputOptions(config, overrides, warn) {
26468
+ async function mergeOutputOptions(config, overrides, log) {
26329
26469
  const getOption = (name) => overrides[name] ?? config[name];
26330
26470
  const outputOptions = {
26331
26471
  amd: getObjectOption(config, overrides, 'amd'),
@@ -26377,7 +26517,7 @@ async function mergeOutputOptions(config, overrides, warn) {
26377
26517
  systemNullSetters: getOption('systemNullSetters'),
26378
26518
  validate: getOption('validate')
26379
26519
  };
26380
- warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
26520
+ warnUnknownOptions(config, Object.keys(outputOptions), 'output options', log);
26381
26521
  return outputOptions;
26382
26522
  }
26383
26523
 
@@ -26465,10 +26605,10 @@ function watch(configs) {
26465
26605
  return emitter;
26466
26606
  }
26467
26607
  async function watchInternal(configs, emitter) {
26468
- const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config)));
26608
+ const optionsList = await Promise.all(ensureArray(configs).map(config => mergeOptions(config, true)));
26469
26609
  const watchOptionsList = optionsList.filter(config => config.watch !== false);
26470
26610
  if (watchOptionsList.length === 0) {
26471
- return error(errorInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
26611
+ return error(logInvalidOption('watch', URL_WATCH, 'there must be at least one config where "watch" is not set to "false"'));
26472
26612
  }
26473
26613
  await loadFsEvents();
26474
26614
  const { Watcher } = await import('./watch.js');