rolldown 1.0.0-beta.16 → 1.0.0-beta.18

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.
Files changed (42) hide show
  1. package/dist/cli.cjs +6 -6
  2. package/dist/cli.mjs +1042 -1081
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +4 -6
  7. package/dist/experimental-index.cjs +7 -31
  8. package/dist/experimental-index.d.cts +2 -2
  9. package/dist/experimental-index.d.mts +2 -2
  10. package/dist/experimental-index.mjs +4 -22
  11. package/dist/filter-index.d.cts +2 -2
  12. package/dist/filter-index.d.mts +2 -2
  13. package/dist/filter-index.mjs +1 -2
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.d.cts +2 -2
  16. package/dist/index.d.mts +2 -2
  17. package/dist/index.mjs +3 -4
  18. package/dist/parallel-plugin-worker.cjs +3 -4
  19. package/dist/parallel-plugin-worker.mjs +27 -34
  20. package/dist/parallel-plugin.d.cts +2 -2
  21. package/dist/parallel-plugin.d.mts +2 -2
  22. package/dist/parse-ast-index.cjs +1 -1
  23. package/dist/parse-ast-index.d.cts +1 -1
  24. package/dist/parse-ast-index.d.mts +1 -1
  25. package/dist/parse-ast-index.mjs +1 -2
  26. package/dist/shared/{binding--Y47JZSL.d.cts → binding-D__94uwg.d.cts} +13 -462
  27. package/dist/shared/{binding-C_9au5Eg.d.mts → binding-DwMf_OTa.d.mts} +13 -462
  28. package/dist/shared/{define-config-DMWHsgSt.d.mts → define-config-CXjwrGWr.d.cts} +70 -10
  29. package/dist/shared/{define-config-CAyC9-af.d.cts → define-config-pMM2R7Js.d.mts} +70 -10
  30. package/dist/shared/{load-config-BniS-jT_.cjs → load-config-BeHXwv7L.cjs} +1 -1
  31. package/dist/shared/{load-config-BT5Ts430.mjs → load-config-D2fi4c8T.mjs} +14 -19
  32. package/dist/shared/{misc-DGAe2XOW.mjs → misc-BN0nse6C.mjs} +1 -4
  33. package/dist/shared/parse-ast-index-BbUPYP6B.cjs +738 -0
  34. package/dist/shared/parse-ast-index-QIuIuIzO.mjs +616 -0
  35. package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
  36. package/dist/shared/{src-1lPDqeuR.cjs → src-BHe-J6xJ.cjs} +44 -48
  37. package/dist/shared/{src-Cv4_zurW.mjs → src-Bob3e8Hh.mjs} +1136 -1394
  38. package/package.json +21 -21
  39. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  40. package/dist/shared/parse-ast-index-BHkdbivO.mjs +0 -659
  41. package/dist/shared/parse-ast-index-hgMnddyI.cjs +0 -701
  42. package/dist/shared/prompt-CodO769G.mjs +0 -854
@@ -1,6 +1,5 @@
1
- import { __esm, __toESM } from "./chunk--iN_1bjD.mjs";
2
- import { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, require_binding } from "./parse-ast-index-BHkdbivO.mjs";
3
- import { arraify, init_misc, isNullish, noop, unimplemented, unreachable, unsupported } from "./misc-DGAe2XOW.mjs";
1
+ import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-QIuIuIzO.mjs";
2
+ import { arraify, isNullish, noop, unimplemented, unreachable, unsupported } from "./misc-BN0nse6C.mjs";
4
3
  import path from "node:path";
5
4
  import { fileURLToPath } from "node:url";
6
5
  import colors from "ansis";
@@ -9,13 +8,13 @@ import os from "node:os";
9
8
  import { Worker } from "node:worker_threads";
10
9
 
11
10
  //#region package.json
12
- var version = "1.0.0-beta.16";
11
+ var version = "1.0.0-beta.18";
13
12
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
14
13
 
15
14
  //#endregion
16
15
  //#region src/builtin-plugin/utils.ts
17
16
  function makeBuiltinPluginCallable(plugin) {
18
- let callablePlugin = new import_binding$6.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
17
+ let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
19
18
  const wrappedPlugin = plugin;
20
19
  for (const key in callablePlugin) wrappedPlugin[key] = function(...args$1) {
21
20
  return callablePlugin[key](...args$1);
@@ -28,13 +27,15 @@ function bindingifyBuiltInPlugin(plugin) {
28
27
  options: plugin._options
29
28
  };
30
29
  }
31
- var import_binding$6;
32
- var init_utils = __esm({ "src/builtin-plugin/utils.ts"() {
33
- import_binding$6 = __toESM(require_binding());
34
- } });
35
30
 
36
31
  //#endregion
37
32
  //#region src/builtin-plugin/constructors.ts
33
+ var BuiltinPlugin = class {
34
+ constructor(name, _options) {
35
+ this.name = name;
36
+ this._options = _options;
37
+ }
38
+ };
38
39
  function modulePreloadPolyfillPlugin(config) {
39
40
  return new BuiltinPlugin("builtin:module-preload-polyfill", config);
40
41
  }
@@ -104,36 +105,24 @@ function webWorkerPostPlugin() {
104
105
  function oxcRuntimePlugin(config) {
105
106
  return new BuiltinPlugin("builtin:oxc-runtime", config);
106
107
  }
107
- var BuiltinPlugin;
108
- var init_constructors = __esm({ "src/builtin-plugin/constructors.ts"() {
109
- init_utils();
110
- BuiltinPlugin = class {
111
- constructor(name, _options) {
112
- this.name = name;
113
- this._options = _options;
114
- }
115
- };
116
- } });
117
108
 
118
109
  //#endregion
119
110
  //#region src/log/logging.ts
120
- var LOG_LEVEL_SILENT, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, logLevelPriority;
121
- var init_logging = __esm({ "src/log/logging.ts"() {
122
- LOG_LEVEL_SILENT = "silent";
123
- LOG_LEVEL_ERROR = "error";
124
- LOG_LEVEL_WARN = "warn";
125
- LOG_LEVEL_INFO = "info";
126
- LOG_LEVEL_DEBUG = "debug";
127
- logLevelPriority = {
128
- [LOG_LEVEL_DEBUG]: 0,
129
- [LOG_LEVEL_INFO]: 1,
130
- [LOG_LEVEL_WARN]: 2,
131
- [LOG_LEVEL_SILENT]: 3
132
- };
133
- } });
111
+ const LOG_LEVEL_SILENT = "silent";
112
+ const LOG_LEVEL_ERROR = "error";
113
+ const LOG_LEVEL_WARN = "warn";
114
+ const LOG_LEVEL_INFO = "info";
115
+ const LOG_LEVEL_DEBUG = "debug";
116
+ const logLevelPriority = {
117
+ [LOG_LEVEL_DEBUG]: 0,
118
+ [LOG_LEVEL_INFO]: 1,
119
+ [LOG_LEVEL_WARN]: 2,
120
+ [LOG_LEVEL_SILENT]: 3
121
+ };
134
122
 
135
123
  //#endregion
136
124
  //#region src/log/log-handler.ts
125
+ const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
137
126
  function getLogHandler(level, code, logger, pluginName, logLevel) {
138
127
  if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
139
128
  return (log, pos) => {
@@ -145,13 +134,6 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
145
134
  logger(level, log);
146
135
  };
147
136
  }
148
- var normalizeLog;
149
- var init_log_handler = __esm({ "src/log/log-handler.ts"() {
150
- init_misc();
151
- init_logging();
152
- init_logs();
153
- normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
154
- } });
155
137
 
156
138
  //#endregion
157
139
  //#region src/log/logger.ts
@@ -187,55 +169,47 @@ function getLogger(plugins, onLog, logLevel, watchMode) {
187
169
  };
188
170
  return logger;
189
171
  }
172
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
173
+ const { onwarn, onLog } = config;
174
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
175
+ if (onLog) {
176
+ const minimalPriority = logLevelPriority[logLevel];
177
+ return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
178
+ if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
179
+ if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
180
+ });
181
+ }
182
+ return defaultOnLog;
183
+ };
184
+ const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
185
+ if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
186
+ else printLog(level, log);
187
+ } : printLog;
188
+ const addLogToString = (log) => {
189
+ Object.defineProperty(log, "toString", {
190
+ value: () => getExtendedLogMessage(log),
191
+ writable: true
192
+ });
193
+ return log;
194
+ };
195
+ const defaultPrintLog = (level, log) => {
196
+ const message = getExtendedLogMessage(log);
197
+ switch (level) {
198
+ case LOG_LEVEL_WARN: return console.warn(message);
199
+ case LOG_LEVEL_DEBUG: return console.debug(message);
200
+ default: return console.info(message);
201
+ }
202
+ };
203
+ const getExtendedLogMessage = (log) => {
204
+ let prefix = "";
205
+ if (log.plugin) prefix += `(${log.plugin} plugin) `;
206
+ if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
207
+ return prefix + log.message;
208
+ };
190
209
  function relativeId(id) {
191
210
  if (!path.isAbsolute(id)) return id;
192
211
  return path.relative(path.resolve(), id);
193
212
  }
194
- var getOnLog, getDefaultOnLog, addLogToString, defaultPrintLog, getExtendedLogMessage;
195
- var init_logger = __esm({ "src/log/logger.ts"() {
196
- init_src();
197
- init_plugin_driver();
198
- init_log_handler();
199
- init_logging();
200
- init_logs();
201
- getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
202
- const { onwarn, onLog } = config;
203
- const defaultOnLog = getDefaultOnLog(printLog, onwarn);
204
- if (onLog) {
205
- const minimalPriority = logLevelPriority[logLevel];
206
- return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
207
- if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
208
- if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
209
- });
210
- }
211
- return defaultOnLog;
212
- };
213
- getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
214
- if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
215
- else printLog(level, log);
216
- } : printLog;
217
- addLogToString = (log) => {
218
- Object.defineProperty(log, "toString", {
219
- value: () => getExtendedLogMessage(log),
220
- writable: true
221
- });
222
- return log;
223
- };
224
- defaultPrintLog = (level, log) => {
225
- const message = getExtendedLogMessage(log);
226
- switch (level) {
227
- case LOG_LEVEL_WARN: return console.warn(message);
228
- case LOG_LEVEL_DEBUG: return console.debug(message);
229
- default: return console.info(message);
230
- }
231
- };
232
- getExtendedLogMessage = (log) => {
233
- let prefix = "";
234
- if (log.plugin) prefix += `(${log.plugin} plugin) `;
235
- if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
236
- return prefix + log.message;
237
- };
238
- } });
239
213
 
240
214
  //#endregion
241
215
  //#region src/utils/normalize-hook.ts
@@ -255,71 +229,75 @@ function normalizeHook(hook) {
255
229
  }
256
230
  unreachable("Invalid hook type");
257
231
  }
258
- var init_normalize_hook = __esm({ "src/utils/normalize-hook.ts"() {
259
- init_misc();
260
- } });
261
232
 
262
233
  //#endregion
263
234
  //#region src/constants/plugin.ts
264
- var ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, ENUMERATED_PLUGIN_HOOK_NAMES, DEFINED_HOOK_NAMES;
265
- var init_plugin$1 = __esm({ "src/constants/plugin.ts"() {
266
- ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
267
- "options",
268
- "buildStart",
269
- "resolveId",
270
- "load",
271
- "transform",
272
- "moduleParsed",
273
- "buildEnd",
274
- "onLog",
275
- "resolveDynamicImport",
276
- "closeBundle",
277
- "closeWatcher",
278
- "watchChange"
279
- ];
280
- ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
281
- "augmentChunkHash",
282
- "outputOptions",
283
- "renderChunk",
284
- "renderStart",
285
- "renderError",
286
- "writeBundle",
287
- "generateBundle"
288
- ];
289
- ENUMERATED_PLUGIN_HOOK_NAMES = [
290
- ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
291
- ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
292
- "footer",
293
- "banner",
294
- "intro",
295
- "outro"
296
- ];
297
- DEFINED_HOOK_NAMES = {
298
- [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
299
- [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
300
- [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
301
- [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
302
- [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
303
- [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
304
- [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
305
- [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
306
- [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
307
- [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
308
- [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
309
- [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
310
- [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
311
- [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
312
- [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
313
- [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
314
- [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
315
- [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
316
- [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
317
- [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
318
- [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
319
- [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
320
- [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
321
- };
322
- } });
235
+ const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
236
+ "options",
237
+ "buildStart",
238
+ "resolveId",
239
+ "load",
240
+ "transform",
241
+ "moduleParsed",
242
+ "buildEnd",
243
+ "onLog",
244
+ "resolveDynamicImport",
245
+ "closeBundle",
246
+ "closeWatcher",
247
+ "watchChange"
248
+ ];
249
+ const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
250
+ "augmentChunkHash",
251
+ "outputOptions",
252
+ "renderChunk",
253
+ "renderStart",
254
+ "renderError",
255
+ "writeBundle",
256
+ "generateBundle"
257
+ ];
258
+ const ENUMERATED_PLUGIN_HOOK_NAMES = [
259
+ ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
260
+ ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
261
+ "footer",
262
+ "banner",
263
+ "intro",
264
+ "outro"
265
+ ];
266
+ /**
267
+ * Names of all defined hooks. It's like
268
+ * ```js
269
+ * const DEFINED_HOOK_NAMES ={
270
+ * options: 'options',
271
+ * buildStart: 'buildStart',
272
+ * ...
273
+ * }
274
+ * ```
275
+ */
276
+ const DEFINED_HOOK_NAMES = {
277
+ [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
278
+ [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
279
+ [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
280
+ [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
281
+ [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
282
+ [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
283
+ [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
284
+ [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
285
+ [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
286
+ [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
287
+ [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
288
+ [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
289
+ [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
290
+ [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
291
+ [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
292
+ [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
293
+ [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
294
+ [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
295
+ [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
296
+ [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
297
+ [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
298
+ [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
299
+ [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
300
+ };
323
301
 
324
302
  //#endregion
325
303
  //#region src/utils/async-flatten.ts
@@ -329,10 +307,10 @@ async function asyncFlatten(array$1) {
329
307
  while (array$1.some((v) => v?.then));
330
308
  return array$1;
331
309
  }
332
- var init_async_flatten = __esm({ "src/utils/async-flatten.ts"() {} });
333
310
 
334
311
  //#endregion
335
312
  //#region src/utils/normalize-plugin-option.ts
313
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
336
314
  function checkOutputPluginOption(plugins, onLog) {
337
315
  for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
338
316
  delete plugin[hook];
@@ -348,52 +326,66 @@ function normalizePlugins(plugins, anonymousPrefix) {
348
326
  }
349
327
  return plugins;
350
328
  }
351
- var normalizePluginOption, ANONYMOUS_PLUGIN_PREFIX, ANONYMOUS_OUTPUT_PLUGIN_PREFIX, BUILTIN_PLUGINS;
352
- var init_normalize_plugin_option = __esm({ "src/utils/normalize-plugin-option.ts"() {
353
- init_constructors();
354
- init_plugin$1();
355
- init_logging();
356
- init_logs();
357
- init_async_flatten();
358
- normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
359
- ANONYMOUS_PLUGIN_PREFIX = "at position ";
360
- ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
361
- BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
362
- } });
329
+ const ANONYMOUS_PLUGIN_PREFIX = "at position ";
330
+ const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
331
+ const BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
363
332
 
364
333
  //#endregion
365
334
  //#region src/plugin/minimal-plugin-context.ts
366
- var MinimalPluginContextImpl;
367
- var init_minimal_plugin_context = __esm({ "src/plugin/minimal-plugin-context.ts"() {
368
- init_src();
369
- init_log_handler();
370
- init_logging();
371
- init_logs();
372
- MinimalPluginContextImpl = class {
373
- info;
374
- warn;
375
- debug;
376
- meta;
377
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
378
- this.pluginName = pluginName;
379
- this.hookName = hookName;
380
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
381
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
382
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
383
- this.meta = {
384
- rollupVersion: "4.23.0",
385
- rolldownVersion: VERSION,
386
- watchMode
387
- };
388
- }
389
- error(e) {
390
- return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
391
- }
392
- };
393
- } });
335
+ var MinimalPluginContextImpl = class {
336
+ info;
337
+ warn;
338
+ debug;
339
+ meta;
340
+ constructor(onLog, logLevel, pluginName, watchMode, hookName) {
341
+ this.pluginName = pluginName;
342
+ this.hookName = hookName;
343
+ this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
344
+ this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
345
+ this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
346
+ this.meta = {
347
+ rollupVersion: "4.23.0",
348
+ rolldownVersion: VERSION,
349
+ watchMode
350
+ };
351
+ }
352
+ error(e) {
353
+ return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
354
+ }
355
+ };
394
356
 
395
357
  //#endregion
396
358
  //#region src/plugin/plugin-driver.ts
359
+ var PluginDriver = class {
360
+ static async callOptionsHook(inputOptions, watchMode = false) {
361
+ const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
362
+ const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
363
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
364
+ for (const plugin of plugins) {
365
+ const name = plugin.name || "unknown";
366
+ const options = plugin.options;
367
+ if (options) {
368
+ const { handler } = normalizeHook(options);
369
+ const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
370
+ if (result) inputOptions = result;
371
+ }
372
+ }
373
+ return inputOptions;
374
+ }
375
+ static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
376
+ const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
377
+ for (const plugin of sortedPlugins) {
378
+ const name = plugin.name || "unknown";
379
+ const options = plugin.outputOptions;
380
+ if (options) {
381
+ const { handler } = normalizeHook(options);
382
+ const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
383
+ if (result) outputOptions = result;
384
+ }
385
+ }
386
+ return outputOptions;
387
+ }
388
+ };
397
389
  function getObjectPlugins(plugins) {
398
390
  return plugins.filter((plugin) => {
399
391
  if (!plugin) return void 0;
@@ -428,48 +420,10 @@ function getSortedPlugins(hookName, plugins) {
428
420
  ...post
429
421
  ];
430
422
  }
431
- var PluginDriver;
432
- var init_plugin_driver = __esm({ "src/plugin/plugin-driver.ts"() {
433
- init_constructors();
434
- init_logger();
435
- init_logging();
436
- init_normalize_hook();
437
- init_normalize_plugin_option();
438
- init_minimal_plugin_context();
439
- PluginDriver = class {
440
- static async callOptionsHook(inputOptions, watchMode = false) {
441
- const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
442
- const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
443
- const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
444
- for (const plugin of plugins) {
445
- const name = plugin.name || "unknown";
446
- const options = plugin.options;
447
- if (options) {
448
- const { handler } = normalizeHook(options);
449
- const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
450
- if (result) inputOptions = result;
451
- }
452
- }
453
- return inputOptions;
454
- }
455
- static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
456
- const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
457
- for (const plugin of sortedPlugins) {
458
- const name = plugin.name || "unknown";
459
- const options = plugin.outputOptions;
460
- if (options) {
461
- const { handler } = normalizeHook(options);
462
- const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
463
- if (result) outputOptions = result;
464
- }
465
- }
466
- return outputOptions;
467
- }
468
- };
469
- } });
470
423
 
471
424
  //#endregion
472
425
  //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
426
+ var store$1;
473
427
  /* @__NO_SIDE_EFFECTS__ */
474
428
  function getGlobalConfig(config2) {
475
429
  return {
@@ -479,14 +433,17 @@ function getGlobalConfig(config2) {
479
433
  abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
480
434
  };
481
435
  }
436
+ var store2;
482
437
  /* @__NO_SIDE_EFFECTS__ */
483
438
  function getGlobalMessage(lang) {
484
439
  return store2?.get(lang);
485
440
  }
441
+ var store3;
486
442
  /* @__NO_SIDE_EFFECTS__ */
487
443
  function getSchemaMessage(lang) {
488
444
  return store3?.get(lang);
489
445
  }
446
+ var store4;
490
447
  /* @__NO_SIDE_EFFECTS__ */
491
448
  function getSpecificMessage(reference, lang) {
492
449
  return store4?.get(reference)?.get(lang);
@@ -544,6 +501,18 @@ function _joinExpects(values2, separator) {
544
501
  if (list.length > 1) return `(${list.join(` ${separator} `)})`;
545
502
  return list[0] ?? "never";
546
503
  }
504
+ var ValiError = class extends Error {
505
+ /**
506
+ * Creates a Valibot error with useful information.
507
+ *
508
+ * @param issues The error issues.
509
+ */
510
+ constructor(issues) {
511
+ super(issues[0].message);
512
+ this.name = "ValiError";
513
+ this.issues = issues;
514
+ }
515
+ };
547
516
  /* @__NO_SIDE_EFFECTS__ */
548
517
  function args(schema) {
549
518
  return {
@@ -1440,21 +1409,6 @@ function safeParse(schema, input, config2) {
1440
1409
  issues: dataset.issues
1441
1410
  };
1442
1411
  }
1443
- var store$1, store2, store3, store4, ValiError;
1444
- var init_dist$2 = __esm({ "../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js"() {
1445
- ValiError = class extends Error {
1446
- /**
1447
- * Creates a Valibot error with useful information.
1448
- *
1449
- * @param issues The error issues.
1450
- */
1451
- constructor(issues) {
1452
- super(issues[0].message);
1453
- this.name = "ValiError";
1454
- this.issues = issues;
1455
- }
1456
- };
1457
- } });
1458
1412
 
1459
1413
  //#endregion
1460
1414
  //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.3.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
@@ -1672,6 +1626,7 @@ function convertAction(jsonSchema, valibotAction, config) {
1672
1626
  function flattenPipe(pipe$1) {
1673
1627
  return pipe$1.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1674
1628
  }
1629
+ let refCount = 0;
1675
1630
  /**
1676
1631
  * Converts any supported Valibot schema to the JSON Schema format.
1677
1632
  *
@@ -1855,6 +1810,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = fal
1855
1810
  if (errors) for (const message of errors) handleError(message, config);
1856
1811
  return jsonSchema;
1857
1812
  }
1813
+ let store;
1858
1814
  /**
1859
1815
  * Returns the current global schema definitions.
1860
1816
  *
@@ -1888,14 +1844,374 @@ function toJsonSchema(schema, config) {
1888
1844
  if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1889
1845
  return jsonSchema;
1890
1846
  }
1891
- var refCount, store;
1892
- var init_dist$1 = __esm({ "../../node_modules/.pnpm/@valibot+to-json-schema@1.3.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js"() {
1893
- init_dist$2();
1894
- refCount = 0;
1895
- } });
1896
1847
 
1897
1848
  //#endregion
1898
1849
  //#region src/utils/validator.ts
1850
+ const StringOrRegExpSchema = union([string(), instance(RegExp)]);
1851
+ const LogLevelSchema = union([
1852
+ literal("debug"),
1853
+ literal("info"),
1854
+ literal("warn")
1855
+ ]);
1856
+ const LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
1857
+ const LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
1858
+ const RollupLogSchema = any();
1859
+ const RollupLogWithStringSchema = union([RollupLogSchema, string()]);
1860
+ const InputOptionSchema = union([
1861
+ string(),
1862
+ array(string()),
1863
+ record(string(), string())
1864
+ ]);
1865
+ const ExternalSchema = union([
1866
+ StringOrRegExpSchema,
1867
+ array(StringOrRegExpSchema),
1868
+ pipe(function_(), args(tuple([
1869
+ string(),
1870
+ optional(string()),
1871
+ boolean()
1872
+ ])), returns(nullish(boolean())))
1873
+ ]);
1874
+ const ModuleTypesSchema = record(string(), union([
1875
+ literal("asset"),
1876
+ literal("base64"),
1877
+ literal("binary"),
1878
+ literal("css"),
1879
+ literal("dataurl"),
1880
+ literal("empty"),
1881
+ literal("js"),
1882
+ literal("json"),
1883
+ literal("jsx"),
1884
+ literal("text"),
1885
+ literal("ts"),
1886
+ literal("tsx")
1887
+ ]));
1888
+ const JsxOptionsSchema = strictObject({
1889
+ runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
1890
+ development: pipe(optional(boolean()), description("Development specific information")),
1891
+ throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1892
+ importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1893
+ pragma: pipe(optional(string()), description("Jsx element transformation")),
1894
+ pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1895
+ refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1896
+ });
1897
+ const RollupJsxOptionsSchema = strictObject({
1898
+ mode: optional(union([
1899
+ literal("classic"),
1900
+ literal("automatic"),
1901
+ literal("preserve")
1902
+ ])),
1903
+ factory: optional(string()),
1904
+ fragment: optional(string()),
1905
+ importSource: optional(string()),
1906
+ jsxImportSource: optional(string())
1907
+ });
1908
+ const HelperModeSchema = union([literal("Runtime"), literal("External")]);
1909
+ const DecoratorOptionSchema = object({
1910
+ legacy: optional(boolean()),
1911
+ emitDecoratorMetadata: optional(boolean())
1912
+ });
1913
+ const HelpersSchema = object({ mode: optional(HelperModeSchema) });
1914
+ const RewriteImportExtensionsSchema = union([
1915
+ literal("rewrite"),
1916
+ literal("remove"),
1917
+ boolean()
1918
+ ]);
1919
+ const TypescriptSchema = object({
1920
+ jsxPragma: optional(string()),
1921
+ jsxPragmaFrag: optional(string()),
1922
+ onlyRemoveTypeImports: optional(boolean()),
1923
+ allowNamespaces: optional(boolean()),
1924
+ allowDeclareFields: optional(boolean()),
1925
+ declaration: optional(object({
1926
+ stripInternal: optional(boolean()),
1927
+ sourcemap: optional(boolean())
1928
+ })),
1929
+ rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
1930
+ });
1931
+ const AssumptionsSchema = object({
1932
+ ignoreFunctionLength: optional(boolean()),
1933
+ noDocumentAll: optional(boolean()),
1934
+ objectRestNoSymbols: optional(boolean()),
1935
+ pureGetters: optional(boolean()),
1936
+ setPublicClassFields: optional(boolean())
1937
+ });
1938
+ const TransformOptionsSchema = object({
1939
+ assumptions: optional(AssumptionsSchema),
1940
+ typescript: optional(TypescriptSchema),
1941
+ helpers: optional(HelpersSchema),
1942
+ decorators: optional(DecoratorOptionSchema),
1943
+ jsx: optional(JsxOptionsSchema),
1944
+ target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
1945
+ });
1946
+ const WatchOptionsSchema = strictObject({
1947
+ chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
1948
+ exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
1949
+ include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
1950
+ notify: pipe(optional(strictObject({
1951
+ compareContents: optional(boolean()),
1952
+ pollInterval: optional(number())
1953
+ })), description("Notify options")),
1954
+ skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
1955
+ buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
1956
+ });
1957
+ const ChecksOptionsSchema = strictObject({
1958
+ circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
1959
+ eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
1960
+ missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
1961
+ missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
1962
+ mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
1963
+ unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
1964
+ unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
1965
+ filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
1966
+ commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
1967
+ importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
1968
+ configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
1969
+ });
1970
+ const MinifyOptionsSchema = strictObject({
1971
+ mangle: optional(boolean()),
1972
+ compress: optional(boolean()),
1973
+ removeWhitespace: optional(boolean())
1974
+ });
1975
+ const ResolveOptionsSchema = strictObject({
1976
+ alias: optional(record(string(), union([string(), array(string())]))),
1977
+ aliasFields: optional(array(array(string()))),
1978
+ conditionNames: optional(array(string())),
1979
+ extensionAlias: optional(record(string(), array(string()))),
1980
+ exportsFields: optional(array(array(string()))),
1981
+ extensions: optional(array(string())),
1982
+ mainFields: optional(array(string())),
1983
+ mainFiles: optional(array(string())),
1984
+ modules: optional(array(string())),
1985
+ symlinks: optional(boolean()),
1986
+ tsconfigFilename: optional(string())
1987
+ });
1988
+ const TreeshakingOptionsSchema = union([boolean(), looseObject({
1989
+ annotations: optional(boolean()),
1990
+ manualPureFunctions: optional(array(string())),
1991
+ unknownGlobalSideEffects: optional(boolean())
1992
+ })]);
1993
+ const OnLogSchema = pipe(function_(), args(tuple([
1994
+ LogLevelSchema,
1995
+ RollupLogSchema,
1996
+ pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
1997
+ ])));
1998
+ const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
1999
+ const HmrSchema = union([boolean(), strictObject({
2000
+ port: optional(number()),
2001
+ host: optional(string()),
2002
+ implement: optional(string())
2003
+ })]);
2004
+ const InputOptionsSchema = strictObject({
2005
+ input: optional(InputOptionSchema),
2006
+ plugins: optional(custom(() => true)),
2007
+ external: optional(ExternalSchema),
2008
+ makeAbsoluteExternalsRelative: optional(union([boolean(), literal("ifRelativeSource")])),
2009
+ resolve: optional(ResolveOptionsSchema),
2010
+ cwd: pipe(optional(string()), description("Current working directory")),
2011
+ platform: pipe(optional(union([
2012
+ literal("browser"),
2013
+ literal("neutral"),
2014
+ literal("node")
2015
+ ])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
2016
+ shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2017
+ treeshake: optional(TreeshakingOptionsSchema),
2018
+ logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
2019
+ onLog: optional(OnLogSchema),
2020
+ onwarn: optional(OnwarnSchema),
2021
+ moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
2022
+ experimental: optional(strictObject({
2023
+ disableLiveBindings: optional(boolean()),
2024
+ enableComposingJsPlugins: optional(boolean()),
2025
+ viteMode: optional(boolean()),
2026
+ resolveNewUrlToAsset: optional(boolean()),
2027
+ strictExecutionOrder: optional(boolean()),
2028
+ hmr: optional(HmrSchema),
2029
+ attachDebugInfo: optional(union([
2030
+ literal("none"),
2031
+ literal("simple"),
2032
+ literal("full")
2033
+ ]))
2034
+ })),
2035
+ define: pipe(optional(record(string(), string())), description("Define global variables")),
2036
+ inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2037
+ profilerNames: optional(boolean()),
2038
+ jsx: optional(union([
2039
+ literal(false),
2040
+ literal("react"),
2041
+ literal("react-jsx"),
2042
+ literal("preserve"),
2043
+ RollupJsxOptionsSchema
2044
+ ])),
2045
+ transform: optional(TransformOptionsSchema),
2046
+ watch: optional(union([WatchOptionsSchema, literal(false)])),
2047
+ dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2048
+ checks: optional(ChecksOptionsSchema),
2049
+ keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2050
+ debug: pipe(optional(object({ sessionId: pipe(optional(string()), description("Used to name the build.")) })), description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.")),
2051
+ preserveEntrySignatures: pipe(optional(union([
2052
+ literal("strict"),
2053
+ literal("allow-extension"),
2054
+ literal("exports-only"),
2055
+ literal(false)
2056
+ ])))
2057
+ });
2058
+ const InputCliOverrideSchema = strictObject({
2059
+ input: pipe(optional(array(string())), description("Entry file")),
2060
+ external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2061
+ inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2062
+ treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2063
+ makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
2064
+ jsx: pipe(optional(union([
2065
+ literal(false),
2066
+ literal("react"),
2067
+ literal("react-jsx"),
2068
+ literal("preserve")
2069
+ ])), description("Jsx options preset")),
2070
+ preserveEntrySignatures: pipe(optional(union([literal(false)])), description("Avoid facade chunks for entry points"))
2071
+ });
2072
+ const InputCliOptionsSchema = omit(strictObject({
2073
+ ...InputOptionsSchema.entries,
2074
+ ...InputCliOverrideSchema.entries
2075
+ }), [
2076
+ "plugins",
2077
+ "onwarn",
2078
+ "onLog",
2079
+ "resolve",
2080
+ "experimental",
2081
+ "profilerNames",
2082
+ "watch"
2083
+ ]);
2084
+ const ModuleFormatSchema = union([
2085
+ literal("es"),
2086
+ literal("cjs"),
2087
+ literal("esm"),
2088
+ literal("module"),
2089
+ literal("commonjs"),
2090
+ literal("iife"),
2091
+ literal("umd")
2092
+ ]);
2093
+ const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2094
+ const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2095
+ const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2096
+ const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2097
+ const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2098
+ const AdvancedChunksSchema = strictObject({
2099
+ minSize: optional(number()),
2100
+ maxSize: optional(number()),
2101
+ minModuleSize: optional(number()),
2102
+ maxModuleSize: optional(number()),
2103
+ minShareCount: optional(number()),
2104
+ groups: optional(array(strictObject({
2105
+ name: string(),
2106
+ test: optional(union([
2107
+ string(),
2108
+ instance(RegExp),
2109
+ pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2110
+ ])),
2111
+ priority: optional(number()),
2112
+ minSize: optional(number()),
2113
+ minShareCount: optional(number()),
2114
+ maxSize: optional(number()),
2115
+ minModuleSize: optional(number()),
2116
+ maxModuleSize: optional(number())
2117
+ })))
2118
+ });
2119
+ const OutputOptionsSchema = strictObject({
2120
+ dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2121
+ file: pipe(optional(string()), description("Single output file")),
2122
+ exports: pipe(optional(union([
2123
+ literal("auto"),
2124
+ literal("named"),
2125
+ literal("default"),
2126
+ literal("none")
2127
+ ])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
2128
+ hashCharacters: pipe(optional(union([
2129
+ literal("base64"),
2130
+ literal("base36"),
2131
+ literal("hex")
2132
+ ])), description("Use the specified character set for file hashes")),
2133
+ format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
2134
+ sourcemap: pipe(optional(union([
2135
+ boolean(),
2136
+ literal("inline"),
2137
+ literal("hidden")
2138
+ ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2139
+ sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2140
+ sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2141
+ sourcemapPathTransform: optional(custom(() => true)),
2142
+ banner: optional(union([string(), AddonFunctionSchema])),
2143
+ footer: optional(union([string(), AddonFunctionSchema])),
2144
+ intro: optional(union([string(), AddonFunctionSchema])),
2145
+ outro: optional(union([string(), AddonFunctionSchema])),
2146
+ extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2147
+ esModule: optional(union([boolean(), literal("if-default-prop")])),
2148
+ assetFileNames: optional(AssetFileNamesSchema),
2149
+ entryFileNames: optional(ChunkFileNamesSchema),
2150
+ chunkFileNames: optional(ChunkFileNamesSchema),
2151
+ cssEntryFileNames: optional(ChunkFileNamesSchema),
2152
+ cssChunkFileNames: optional(ChunkFileNamesSchema),
2153
+ sanitizeFileName: optional(SanitizeFileNameSchema),
2154
+ minify: pipe(optional(union([
2155
+ boolean(),
2156
+ string("dce-only"),
2157
+ MinifyOptionsSchema
2158
+ ])), description("Minify the bundled file")),
2159
+ name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2160
+ globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2161
+ externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2162
+ inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2163
+ manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2164
+ advancedChunks: optional(AdvancedChunksSchema),
2165
+ legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2166
+ plugins: optional(custom(() => true)),
2167
+ polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2168
+ hoistTransitiveImports: optional(custom((input) => {
2169
+ if (input) return false;
2170
+ return true;
2171
+ }, () => `The 'true' value is not supported`)),
2172
+ preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2173
+ preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2174
+ virtualDirname: optional(string())
2175
+ });
2176
+ const getAddonDescription = (placement, wrapper) => {
2177
+ return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
2178
+ };
2179
+ const OutputCliOverrideSchema = strictObject({
2180
+ assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2181
+ entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2182
+ chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2183
+ cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2184
+ cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2185
+ sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2186
+ banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2187
+ footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2188
+ intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2189
+ outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2190
+ esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2191
+ globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2192
+ advancedChunks: pipe(optional(strictObject({
2193
+ minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2194
+ minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2195
+ })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2196
+ minify: pipe(optional(boolean()), description("Minify the bundled file"))
2197
+ });
2198
+ const OutputCliOptionsSchema = omit(strictObject({
2199
+ ...OutputOptionsSchema.entries,
2200
+ ...OutputCliOverrideSchema.entries
2201
+ }), [
2202
+ "sourcemapIgnoreList",
2203
+ "sourcemapPathTransform",
2204
+ "plugins",
2205
+ "hoistTransitiveImports"
2206
+ ]);
2207
+ const CliOptionsSchema = strictObject({
2208
+ config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2209
+ help: pipe(optional(boolean()), description("Show help")),
2210
+ version: pipe(optional(boolean()), description("Show version number")),
2211
+ watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2212
+ ...InputCliOptionsSchema.entries,
2213
+ ...OutputCliOptionsSchema.entries
2214
+ });
1899
2215
  function validateCliOptions(options) {
1900
2216
  let parsed = safeParse(CliOptionsSchema, options);
1901
2217
  return [parsed.output, parsed.issues?.map((issue) => {
@@ -1903,6 +2219,8 @@ function validateCliOptions(options) {
1903
2219
  return `Invalid value for option ${option}: ${issue.message}`;
1904
2220
  })];
1905
2221
  }
2222
+ const inputHelperMsgRecord = { output: { ignored: true } };
2223
+ const outputHelperMsgRecord = {};
1906
2224
  function validateOption(key, options) {
1907
2225
  if (globalThis.process?.env?.ROLLUP_TEST) return;
1908
2226
  let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
@@ -1934,409 +2252,38 @@ function getOutputCliKeys() {
1934
2252
  function getJsonSchema() {
1935
2253
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
1936
2254
  }
1937
- var StringOrRegExpSchema, LogLevelSchema, LogLevelOptionSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, InputOptionSchema, ExternalSchema, ModuleTypesSchema, JsxOptionsSchema, RollupJsxOptionsSchema, HelperModeSchema, DecoratorOptionSchema, HelpersSchema, RewriteImportExtensionsSchema, TypescriptSchema, AssumptionsSchema, TransformOptionsSchema, WatchOptionsSchema, ChecksOptionsSchema, MinifyOptionsSchema, ResolveOptionsSchema, TreeshakingOptionsSchema, OnLogSchema, OnwarnSchema, HmrSchema, InputOptionsSchema, InputCliOverrideSchema, InputCliOptionsSchema, ModuleFormatSchema, AddonFunctionSchema, ChunkFileNamesSchema, AssetFileNamesSchema, SanitizeFileNameSchema, GlobalsFunctionSchema, AdvancedChunksSchema, OutputOptionsSchema, getAddonDescription, OutputCliOverrideSchema, OutputCliOptionsSchema, CliOptionsSchema, inputHelperMsgRecord, outputHelperMsgRecord;
1938
- var init_validator = __esm({ "src/utils/validator.ts"() {
1939
- init_dist$1();
1940
- init_dist$2();
1941
- StringOrRegExpSchema = union([string(), instance(RegExp)]);
1942
- LogLevelSchema = union([
1943
- literal("debug"),
1944
- literal("info"),
1945
- literal("warn")
1946
- ]);
1947
- LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
1948
- LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
1949
- RollupLogSchema = any();
1950
- RollupLogWithStringSchema = union([RollupLogSchema, string()]);
1951
- InputOptionSchema = union([
1952
- string(),
1953
- array(string()),
1954
- record(string(), string())
1955
- ]);
1956
- ExternalSchema = union([
1957
- StringOrRegExpSchema,
1958
- array(StringOrRegExpSchema),
1959
- pipe(function_(), args(tuple([
1960
- string(),
1961
- optional(string()),
1962
- boolean()
1963
- ])), returns(nullish(boolean())))
1964
- ]);
1965
- ModuleTypesSchema = record(string(), union([
1966
- literal("asset"),
1967
- literal("base64"),
1968
- literal("binary"),
1969
- literal("css"),
1970
- literal("dataurl"),
1971
- literal("empty"),
1972
- literal("js"),
1973
- literal("json"),
1974
- literal("jsx"),
1975
- literal("text"),
1976
- literal("ts"),
1977
- literal("tsx")
1978
- ]));
1979
- JsxOptionsSchema = strictObject({
1980
- runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
1981
- development: pipe(optional(boolean()), description("Development specific information")),
1982
- throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1983
- importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1984
- pragma: pipe(optional(string()), description("Jsx element transformation")),
1985
- pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1986
- refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1987
- });
1988
- RollupJsxOptionsSchema = strictObject({
1989
- mode: optional(union([
1990
- literal("classic"),
1991
- literal("automatic"),
1992
- literal("preserve")
1993
- ])),
1994
- factory: optional(string()),
1995
- fragment: optional(string()),
1996
- importSource: optional(string()),
1997
- jsxImportSource: optional(string())
1998
- });
1999
- HelperModeSchema = union([literal("Runtime"), literal("External")]);
2000
- DecoratorOptionSchema = object({
2001
- legacy: optional(boolean()),
2002
- emitDecoratorMetadata: optional(boolean())
2003
- });
2004
- HelpersSchema = object({ mode: optional(HelperModeSchema) });
2005
- RewriteImportExtensionsSchema = union([
2006
- literal("rewrite"),
2007
- literal("remove"),
2008
- boolean()
2009
- ]);
2010
- TypescriptSchema = object({
2011
- jsxPragma: optional(string()),
2012
- jsxPragmaFrag: optional(string()),
2013
- onlyRemoveTypeImports: optional(boolean()),
2014
- allowNamespaces: optional(boolean()),
2015
- allowDeclareFields: optional(boolean()),
2016
- declaration: optional(object({
2017
- stripInternal: optional(boolean()),
2018
- sourcemap: optional(boolean())
2019
- })),
2020
- rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
2021
- });
2022
- AssumptionsSchema = object({
2023
- ignoreFunctionLength: optional(boolean()),
2024
- noDocumentAll: optional(boolean()),
2025
- objectRestNoSymbols: optional(boolean()),
2026
- pureGetters: optional(boolean()),
2027
- setPublicClassFields: optional(boolean())
2028
- });
2029
- TransformOptionsSchema = object({
2030
- assumptions: optional(AssumptionsSchema),
2031
- typescript: optional(TypescriptSchema),
2032
- helpers: optional(HelpersSchema),
2033
- decorators: optional(DecoratorOptionSchema),
2034
- jsx: optional(JsxOptionsSchema),
2035
- target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
2036
- });
2037
- WatchOptionsSchema = strictObject({
2038
- chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
2039
- exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2040
- include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2041
- notify: pipe(optional(strictObject({
2042
- compareContents: optional(boolean()),
2043
- pollInterval: optional(number())
2044
- })), description("Notify options")),
2045
- skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
2046
- buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
2047
- });
2048
- ChecksOptionsSchema = strictObject({
2049
- circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
2050
- eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
2051
- missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
2052
- missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
2053
- mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
2054
- unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
2055
- unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
2056
- filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
2057
- commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
2058
- importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
2059
- configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
2060
- });
2061
- MinifyOptionsSchema = strictObject({
2062
- mangle: optional(boolean()),
2063
- compress: optional(boolean()),
2064
- removeWhitespace: optional(boolean())
2065
- });
2066
- ResolveOptionsSchema = strictObject({
2067
- alias: optional(record(string(), union([string(), array(string())]))),
2068
- aliasFields: optional(array(array(string()))),
2069
- conditionNames: optional(array(string())),
2070
- extensionAlias: optional(record(string(), array(string()))),
2071
- exportsFields: optional(array(array(string()))),
2072
- extensions: optional(array(string())),
2073
- mainFields: optional(array(string())),
2074
- mainFiles: optional(array(string())),
2075
- modules: optional(array(string())),
2076
- symlinks: optional(boolean()),
2077
- tsconfigFilename: optional(string())
2078
- });
2079
- TreeshakingOptionsSchema = union([boolean(), looseObject({
2080
- annotations: optional(boolean()),
2081
- manualPureFunctions: optional(array(string())),
2082
- unknownGlobalSideEffects: optional(boolean())
2083
- })]);
2084
- OnLogSchema = pipe(function_(), args(tuple([
2085
- LogLevelSchema,
2086
- RollupLogSchema,
2087
- pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
2088
- ])));
2089
- OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
2090
- HmrSchema = union([boolean(), strictObject({
2091
- port: optional(number()),
2092
- host: optional(string()),
2093
- implement: optional(string())
2094
- })]);
2095
- InputOptionsSchema = strictObject({
2096
- input: optional(InputOptionSchema),
2097
- plugins: optional(custom(() => true)),
2098
- external: optional(ExternalSchema),
2099
- makeAbsoluteExternalsRelative: optional(union([boolean(), literal("ifRelativeSource")])),
2100
- resolve: optional(ResolveOptionsSchema),
2101
- cwd: pipe(optional(string()), description("Current working directory")),
2102
- platform: pipe(optional(union([
2103
- literal("browser"),
2104
- literal("neutral"),
2105
- literal("node")
2106
- ])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
2107
- shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2108
- treeshake: optional(TreeshakingOptionsSchema),
2109
- logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
2110
- onLog: optional(OnLogSchema),
2111
- onwarn: optional(OnwarnSchema),
2112
- moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
2113
- experimental: optional(strictObject({
2114
- disableLiveBindings: optional(boolean()),
2115
- enableComposingJsPlugins: optional(boolean()),
2116
- resolveNewUrlToAsset: optional(boolean()),
2117
- strictExecutionOrder: optional(boolean()),
2118
- hmr: optional(HmrSchema),
2119
- attachDebugInfo: optional(union([
2120
- literal("none"),
2121
- literal("simple"),
2122
- literal("full")
2123
- ]))
2124
- })),
2125
- define: pipe(optional(record(string(), string())), description("Define global variables")),
2126
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2127
- profilerNames: optional(boolean()),
2128
- jsx: optional(union([
2129
- literal(false),
2130
- literal("react"),
2131
- literal("react-jsx"),
2132
- literal("preserve"),
2133
- RollupJsxOptionsSchema
2134
- ])),
2135
- transform: optional(TransformOptionsSchema),
2136
- watch: optional(union([WatchOptionsSchema, literal(false)])),
2137
- dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2138
- checks: optional(ChecksOptionsSchema),
2139
- keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2140
- debug: pipe(optional(object({ sessionId: pipe(optional(string()), description("Used to name the build.")) })), description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.")),
2141
- preserveEntrySignatures: pipe(optional(union([
2142
- literal("strict"),
2143
- literal("allow-extension"),
2144
- literal("exports-only"),
2145
- literal(false)
2146
- ])))
2147
- });
2148
- InputCliOverrideSchema = strictObject({
2149
- input: pipe(optional(array(string())), description("Entry file")),
2150
- external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2151
- inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2152
- treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2153
- makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
2154
- jsx: pipe(optional(union([
2155
- literal(false),
2156
- literal("react"),
2157
- literal("react-jsx"),
2158
- literal("preserve")
2159
- ])), description("Jsx options preset")),
2160
- preserveEntrySignatures: pipe(optional(union([literal(false)])), description("Avoid facade chunks for entry points"))
2161
- });
2162
- InputCliOptionsSchema = omit(strictObject({
2163
- ...InputOptionsSchema.entries,
2164
- ...InputCliOverrideSchema.entries
2165
- }), [
2166
- "plugins",
2167
- "onwarn",
2168
- "onLog",
2169
- "resolve",
2170
- "experimental",
2171
- "profilerNames",
2172
- "watch"
2173
- ]);
2174
- ModuleFormatSchema = union([
2175
- literal("es"),
2176
- literal("cjs"),
2177
- literal("esm"),
2178
- literal("module"),
2179
- literal("commonjs"),
2180
- literal("iife"),
2181
- literal("umd")
2182
- ]);
2183
- AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2184
- ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2185
- AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2186
- SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2187
- GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2188
- AdvancedChunksSchema = strictObject({
2189
- minSize: optional(number()),
2190
- maxSize: optional(number()),
2191
- minModuleSize: optional(number()),
2192
- maxModuleSize: optional(number()),
2193
- minShareCount: optional(number()),
2194
- groups: optional(array(strictObject({
2195
- name: string(),
2196
- test: optional(union([
2197
- string(),
2198
- instance(RegExp),
2199
- pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2200
- ])),
2201
- priority: optional(number()),
2202
- minSize: optional(number()),
2203
- minShareCount: optional(number()),
2204
- maxSize: optional(number()),
2205
- minModuleSize: optional(number()),
2206
- maxModuleSize: optional(number())
2207
- })))
2208
- });
2209
- OutputOptionsSchema = strictObject({
2210
- dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2211
- file: pipe(optional(string()), description("Single output file")),
2212
- exports: pipe(optional(union([
2213
- literal("auto"),
2214
- literal("named"),
2215
- literal("default"),
2216
- literal("none")
2217
- ])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
2218
- hashCharacters: pipe(optional(union([
2219
- literal("base64"),
2220
- literal("base36"),
2221
- literal("hex")
2222
- ])), description("Use the specified character set for file hashes")),
2223
- format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
2224
- sourcemap: pipe(optional(union([
2225
- boolean(),
2226
- literal("inline"),
2227
- literal("hidden")
2228
- ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2229
- sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2230
- sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2231
- sourcemapPathTransform: optional(custom(() => true)),
2232
- banner: optional(union([string(), AddonFunctionSchema])),
2233
- footer: optional(union([string(), AddonFunctionSchema])),
2234
- intro: optional(union([string(), AddonFunctionSchema])),
2235
- outro: optional(union([string(), AddonFunctionSchema])),
2236
- extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2237
- esModule: optional(union([boolean(), literal("if-default-prop")])),
2238
- assetFileNames: optional(AssetFileNamesSchema),
2239
- entryFileNames: optional(ChunkFileNamesSchema),
2240
- chunkFileNames: optional(ChunkFileNamesSchema),
2241
- cssEntryFileNames: optional(ChunkFileNamesSchema),
2242
- cssChunkFileNames: optional(ChunkFileNamesSchema),
2243
- sanitizeFileName: optional(SanitizeFileNameSchema),
2244
- minify: pipe(optional(union([
2245
- boolean(),
2246
- string("dce-only"),
2247
- MinifyOptionsSchema
2248
- ])), description("Minify the bundled file")),
2249
- name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2250
- globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2251
- externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2252
- inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2253
- manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2254
- advancedChunks: optional(AdvancedChunksSchema),
2255
- legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2256
- plugins: optional(custom(() => true)),
2257
- polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2258
- hoistTransitiveImports: optional(custom((input) => {
2259
- if (input) return false;
2260
- return true;
2261
- }, () => `The 'true' value is not supported`)),
2262
- preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2263
- preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2264
- virtualDirname: optional(string())
2265
- });
2266
- getAddonDescription = (placement, wrapper) => {
2267
- return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
2268
- };
2269
- OutputCliOverrideSchema = strictObject({
2270
- assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2271
- entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2272
- chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2273
- cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2274
- cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2275
- sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2276
- banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2277
- footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2278
- intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2279
- outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2280
- esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2281
- globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2282
- advancedChunks: pipe(optional(strictObject({
2283
- minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2284
- minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2285
- })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2286
- minify: pipe(optional(boolean()), description("Minify the bundled file"))
2287
- });
2288
- OutputCliOptionsSchema = omit(strictObject({
2289
- ...OutputOptionsSchema.entries,
2290
- ...OutputCliOverrideSchema.entries
2291
- }), [
2292
- "sourcemapIgnoreList",
2293
- "sourcemapPathTransform",
2294
- "plugins",
2295
- "hoistTransitiveImports"
2296
- ]);
2297
- CliOptionsSchema = strictObject({
2298
- config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2299
- help: pipe(optional(boolean()), description("Show help")),
2300
- version: pipe(optional(boolean()), description("Show version number")),
2301
- watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2302
- ...InputCliOptionsSchema.entries,
2303
- ...OutputCliOptionsSchema.entries
2304
- });
2305
- inputHelperMsgRecord = { output: { ignored: true } };
2306
- outputHelperMsgRecord = {};
2307
- } });
2308
2255
 
2309
2256
  //#endregion
2310
2257
  //#region src/constants/plugin-context.ts
2311
- var SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF;
2312
- var init_plugin_context$1 = __esm({ "src/constants/plugin-context.ts"() {
2313
- SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2314
- } });
2258
+ /**
2259
+ * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2260
+ * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2261
+ * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2262
+ * internally.
2263
+ */
2264
+ const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2315
2265
 
2316
2266
  //#endregion
2317
2267
  //#region src/options/normalized-input-options.ts
2318
- var NormalizedInputOptionsImpl;
2319
- var init_normalized_input_options = __esm({ "src/options/normalized-input-options.ts"() {
2320
- NormalizedInputOptionsImpl = class {
2321
- inner;
2322
- constructor(inner, onLog) {
2323
- this.onLog = onLog;
2324
- this.inner = inner;
2325
- }
2326
- get shimMissingExports() {
2327
- return this.inner.shimMissingExports;
2328
- }
2329
- get input() {
2330
- return this.inner.input;
2331
- }
2332
- get cwd() {
2333
- return this.inner.cwd ?? void 0;
2334
- }
2335
- get platform() {
2336
- return this.inner.platform;
2337
- }
2338
- };
2339
- } });
2268
+ var NormalizedInputOptionsImpl = class {
2269
+ inner;
2270
+ constructor(inner, onLog) {
2271
+ this.onLog = onLog;
2272
+ this.inner = inner;
2273
+ }
2274
+ get shimMissingExports() {
2275
+ return this.inner.shimMissingExports;
2276
+ }
2277
+ get input() {
2278
+ return this.inner.input;
2279
+ }
2280
+ get cwd() {
2281
+ return this.inner.cwd ?? void 0;
2282
+ }
2283
+ get platform() {
2284
+ return this.inner.platform;
2285
+ }
2286
+ };
2340
2287
 
2341
2288
  //#endregion
2342
2289
  //#region src/types/sourcemap.ts
@@ -2353,7 +2300,6 @@ function bindingifySourcemap(map) {
2353
2300
  debugId: "debugId" in map ? map.debugId : void 0
2354
2301
  } };
2355
2302
  }
2356
- var init_sourcemap = __esm({ "src/types/sourcemap.ts"() {} });
2357
2303
 
2358
2304
  //#endregion
2359
2305
  //#region src/utils/error.ts
@@ -2404,7 +2350,6 @@ function getErrorMessage(e) {
2404
2350
  function joinNewLine(s1, s2) {
2405
2351
  return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
2406
2352
  }
2407
- var init_error = __esm({ "src/utils/error.ts"() {} });
2408
2353
 
2409
2354
  //#endregion
2410
2355
  //#region src/utils/transform-module-info.ts
@@ -2426,26 +2371,19 @@ function transformModuleInfo(info, option) {
2426
2371
  ...option
2427
2372
  };
2428
2373
  }
2429
- var init_transform_module_info = __esm({ "src/utils/transform-module-info.ts"() {
2430
- init_misc();
2431
- } });
2432
2374
 
2433
2375
  //#endregion
2434
2376
  //#region src/utils/transform-side-effects.ts
2435
2377
  function bindingifySideEffects(sideEffects) {
2436
2378
  switch (sideEffects) {
2437
- case true: return import_binding$5.BindingHookSideEffects.True;
2438
- case false: return import_binding$5.BindingHookSideEffects.False;
2439
- case "no-treeshake": return import_binding$5.BindingHookSideEffects.NoTreeshake;
2379
+ case true: return BindingHookSideEffects.True;
2380
+ case false: return BindingHookSideEffects.False;
2381
+ case "no-treeshake": return BindingHookSideEffects.NoTreeshake;
2440
2382
  case null:
2441
2383
  case void 0: return void 0;
2442
2384
  default: throw new Error(`Unexpected side effects: ${sideEffects}`);
2443
2385
  }
2444
2386
  }
2445
- var import_binding$5;
2446
- var init_transform_side_effects = __esm({ "src/utils/transform-side-effects.ts"() {
2447
- import_binding$5 = __toESM(require_binding());
2448
- } });
2449
2387
 
2450
2388
  //#endregion
2451
2389
  //#region src/utils/transform-sourcemap.ts
@@ -2461,7 +2399,6 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2461
2399
  if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
2462
2400
  return map;
2463
2401
  }
2464
- var init_transform_sourcemap = __esm({ "src/utils/transform-sourcemap.ts"() {} });
2465
2402
 
2466
2403
  //#endregion
2467
2404
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
@@ -2472,7 +2409,6 @@ function u$1(o, n, a) {
2472
2409
  lazyArgs: n
2473
2410
  });
2474
2411
  }
2475
- var init_chunk_D6FCK2GA = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js"() {} });
2476
2412
 
2477
2413
  //#endregion
2478
2414
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-WIMGWYZL.js
@@ -2482,40 +2418,23 @@ function u(r, n, o) {
2482
2418
  if (a === 1) return u$1(r, n, o);
2483
2419
  throw new Error("Wrong number of arguments");
2484
2420
  }
2485
- var init_chunk_WIMGWYZL = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-WIMGWYZL.js"() {
2486
- init_chunk_D6FCK2GA();
2487
- } });
2488
2421
 
2489
2422
  //#endregion
2490
2423
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-3IFJP4R5.js
2491
2424
  function d(...r) {
2492
2425
  return u(i, r);
2493
2426
  }
2494
- var i;
2495
- var init_chunk_3IFJP4R5 = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-3IFJP4R5.js"() {
2496
- init_chunk_WIMGWYZL();
2497
- i = (r, t$1) => {
2498
- let a = [[], []];
2499
- for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
2500
- return a;
2501
- };
2502
- } });
2427
+ var i = (r, t$1) => {
2428
+ let a = [[], []];
2429
+ for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
2430
+ return a;
2431
+ };
2503
2432
 
2504
2433
  //#endregion
2505
2434
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2506
2435
  function t(...n) {
2507
2436
  return u(Object.keys, n);
2508
2437
  }
2509
- var init_chunk_5NQBDF4H = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js"() {
2510
- init_chunk_WIMGWYZL();
2511
- } });
2512
-
2513
- //#endregion
2514
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/index.js
2515
- var init_dist = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/index.js"() {
2516
- init_chunk_3IFJP4R5();
2517
- init_chunk_5NQBDF4H();
2518
- } });
2519
2438
 
2520
2439
  //#endregion
2521
2440
  //#region src/plugin/bindingify-hook-filter.ts
@@ -2657,10 +2576,6 @@ function bindingifyRenderChunkFilter(filterOption) {
2657
2576
  if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
2658
2577
  return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
2659
2578
  }
2660
- var init_bindingify_hook_filter = __esm({ "src/plugin/bindingify-hook-filter.ts"() {
2661
- init_dist();
2662
- init_misc();
2663
- } });
2664
2579
 
2665
2580
  //#endregion
2666
2581
  //#region src/plugin/bindingify-plugin-hook-meta.ts
@@ -2669,17 +2584,13 @@ function bindingifyPluginHookMeta(options) {
2669
2584
  }
2670
2585
  function bindingPluginOrder(order) {
2671
2586
  switch (order) {
2672
- case "post": return import_binding$4.BindingPluginOrder.Post;
2673
- case "pre": return import_binding$4.BindingPluginOrder.Pre;
2587
+ case "post": return BindingPluginOrder.Post;
2588
+ case "pre": return BindingPluginOrder.Pre;
2674
2589
  case null:
2675
2590
  case void 0: return void 0;
2676
2591
  default: throw new Error(`Unknown plugin order: ${order}`);
2677
2592
  }
2678
2593
  }
2679
- var import_binding$4;
2680
- var init_bindingify_plugin_hook_meta = __esm({ "src/plugin/bindingify-plugin-hook-meta.ts"() {
2681
- import_binding$4 = __toESM(require_binding());
2682
- } });
2683
2594
 
2684
2595
  //#endregion
2685
2596
  //#region src/utils/asset-source.ts
@@ -2689,150 +2600,132 @@ function transformAssetSource(bindingAssetSource$1) {
2689
2600
  function bindingAssetSource(source) {
2690
2601
  return { inner: source };
2691
2602
  }
2692
- var init_asset_source = __esm({ "src/utils/asset-source.ts"() {} });
2693
2603
 
2694
2604
  //#endregion
2695
2605
  //#region src/plugin/plugin-context.ts
2696
- var PluginContextImpl;
2697
- var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
2698
- init_logging();
2699
- init_logs();
2700
- init_parse_ast_index();
2701
- init_minimal_plugin_context();
2702
- init_asset_source();
2703
- init_bindingify_input_options();
2704
- init_misc();
2705
- init_transform_side_effects();
2706
- PluginContextImpl = class extends MinimalPluginContextImpl {
2707
- getModuleInfo;
2708
- constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2709
- super(onLog, logLevel, plugin.name, watchMode);
2710
- this.outputOptions = outputOptions;
2711
- this.context = context;
2712
- this.data = data;
2713
- this.onLog = onLog;
2714
- this.currentLoadingModule = currentLoadingModule;
2715
- this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
2716
- }
2717
- async load(options) {
2718
- const id = options.id;
2719
- if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2720
- const moduleInfo = this.data.getModuleInfo(id, this.context);
2721
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2722
- const rawOptions = {
2723
- meta: options.meta || {},
2724
- moduleSideEffects: options.moduleSideEffects || null,
2725
- invalidate: false
2726
- };
2727
- this.data.updateModuleOption(id, rawOptions);
2728
- async function createLoadModulePromise(context, data) {
2729
- const loadPromise = data.loadModulePromiseMap.get(id);
2730
- if (loadPromise) return loadPromise;
2731
- const promise$1 = new Promise((resolve, _) => {
2732
- data.loadModulePromiseResolveFnMap.set(id, resolve);
2733
- });
2734
- data.loadModulePromiseMap.set(id, promise$1);
2735
- try {
2736
- await context.load(id, bindingifySideEffects(options.moduleSideEffects));
2737
- } catch (e) {
2738
- data.loadModulePromiseMap.delete(id);
2739
- data.loadModulePromiseResolveFnMap.delete(id);
2740
- throw e;
2741
- }
2742
- return promise$1;
2743
- }
2744
- await createLoadModulePromise(this.context, this.data);
2745
- return this.data.getModuleInfo(id, this.context);
2746
- }
2747
- async resolve(source, importer, options) {
2748
- let receipt = void 0;
2749
- if (options != null) receipt = this.data.saveResolveOptions(options);
2750
- const res = await this.context.resolve(source, importer, {
2751
- custom: receipt,
2752
- skipSelf: options?.skipSelf
2753
- });
2754
- if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2755
- if (res == null) return null;
2756
- const info = this.data.getModuleOption(res.id) || {};
2757
- return {
2758
- ...res,
2759
- external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2760
- ...info
2761
- };
2762
- }
2763
- emitFile = (file) => {
2764
- if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2765
- if (file.type === "chunk") return this.context.emitChunk({
2766
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
2767
- ...file
2768
- });
2769
- const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2770
- const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2771
- return this.context.emitFile({
2772
- ...file,
2773
- originalFileName: file.originalFileName || void 0,
2774
- source: bindingAssetSource(file.source)
2775
- }, filename, fnSanitizedFileName);
2606
+ var PluginContextImpl = class extends MinimalPluginContextImpl {
2607
+ getModuleInfo;
2608
+ constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2609
+ super(onLog, logLevel, plugin.name, watchMode);
2610
+ this.outputOptions = outputOptions;
2611
+ this.context = context;
2612
+ this.data = data;
2613
+ this.onLog = onLog;
2614
+ this.currentLoadingModule = currentLoadingModule;
2615
+ this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
2616
+ }
2617
+ async load(options) {
2618
+ const id = options.id;
2619
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2620
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
2621
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2622
+ const rawOptions = {
2623
+ meta: options.meta || {},
2624
+ moduleSideEffects: options.moduleSideEffects || null,
2625
+ invalidate: false
2776
2626
  };
2777
- getAssetFileNames(file) {
2778
- if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2779
- names: file.name ? [file.name] : [],
2780
- originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2781
- source: file.source,
2782
- type: "asset"
2627
+ this.data.updateModuleOption(id, rawOptions);
2628
+ async function createLoadModulePromise(context, data) {
2629
+ const loadPromise = data.loadModulePromiseMap.get(id);
2630
+ if (loadPromise) return loadPromise;
2631
+ const promise$1 = new Promise((resolve, _) => {
2632
+ data.loadModulePromiseResolveFnMap.set(id, resolve);
2783
2633
  });
2634
+ data.loadModulePromiseMap.set(id, promise$1);
2635
+ try {
2636
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects));
2637
+ } catch (e) {
2638
+ data.loadModulePromiseMap.delete(id);
2639
+ data.loadModulePromiseResolveFnMap.delete(id);
2640
+ throw e;
2641
+ }
2642
+ return promise$1;
2784
2643
  }
2785
- getFileName(referenceId) {
2786
- return this.context.getFileName(referenceId);
2787
- }
2788
- getModuleIds() {
2789
- return this.data.getModuleIds(this.context);
2790
- }
2791
- addWatchFile(id) {
2792
- this.context.addWatchFile(id);
2793
- }
2794
- parse(input, options) {
2795
- return parseAst(input, options);
2796
- }
2644
+ await createLoadModulePromise(this.context, this.data);
2645
+ return this.data.getModuleInfo(id, this.context);
2646
+ }
2647
+ async resolve(source, importer, options) {
2648
+ let receipt = void 0;
2649
+ if (options != null) receipt = this.data.saveResolveOptions(options);
2650
+ const res = await this.context.resolve(source, importer, {
2651
+ custom: receipt,
2652
+ skipSelf: options?.skipSelf
2653
+ });
2654
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2655
+ if (res == null) return null;
2656
+ const info = this.data.getModuleOption(res.id) || {};
2657
+ return {
2658
+ ...res,
2659
+ external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2660
+ ...info
2661
+ };
2662
+ }
2663
+ emitFile = (file) => {
2664
+ if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2665
+ if (file.type === "chunk") return this.context.emitChunk({
2666
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
2667
+ ...file
2668
+ });
2669
+ const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2670
+ const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2671
+ return this.context.emitFile({
2672
+ ...file,
2673
+ originalFileName: file.originalFileName || void 0,
2674
+ source: bindingAssetSource(file.source)
2675
+ }, filename, fnSanitizedFileName);
2797
2676
  };
2798
- } });
2677
+ getAssetFileNames(file) {
2678
+ if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2679
+ names: file.name ? [file.name] : [],
2680
+ originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2681
+ source: file.source,
2682
+ type: "asset"
2683
+ });
2684
+ }
2685
+ getFileName(referenceId) {
2686
+ return this.context.getFileName(referenceId);
2687
+ }
2688
+ getModuleIds() {
2689
+ return this.data.getModuleIds(this.context);
2690
+ }
2691
+ addWatchFile(id) {
2692
+ this.context.addWatchFile(id);
2693
+ }
2694
+ parse(input, options) {
2695
+ return parseAst(input, options);
2696
+ }
2697
+ };
2799
2698
 
2800
2699
  //#endregion
2801
2700
  //#region src/plugin/transform-plugin-context.ts
2802
- var TransformPluginContextImpl;
2803
- var init_transform_plugin_context = __esm({ "src/plugin/transform-plugin-context.ts"() {
2804
- init_log_handler();
2805
- init_logs();
2806
- init_plugin_context();
2807
- TransformPluginContextImpl = class extends PluginContextImpl {
2808
- constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2809
- super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2810
- this.inner = inner;
2811
- this.moduleId = moduleId;
2812
- this.moduleSource = moduleSource;
2813
- const getLogHandler$1 = (handler) => (log, pos) => {
2814
- log = normalizeLog(log);
2815
- if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2816
- log.id = moduleId;
2817
- log.hook = "transform";
2818
- handler(log);
2819
- };
2820
- this.debug = getLogHandler$1(this.debug);
2821
- this.warn = getLogHandler$1(this.warn);
2822
- this.info = getLogHandler$1(this.info);
2823
- }
2824
- error(e, pos) {
2825
- if (typeof e === "string") e = { message: e };
2826
- if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
2827
- e.id = this.moduleId;
2828
- e.hook = "transform";
2829
- return error(logPluginError(normalizeLog(e), this.pluginName));
2830
- }
2831
- getCombinedSourcemap() {
2832
- return JSON.parse(this.inner.getCombinedSourcemap());
2833
- }
2834
- };
2835
- } });
2701
+ var TransformPluginContextImpl = class extends PluginContextImpl {
2702
+ constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2703
+ super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2704
+ this.inner = inner;
2705
+ this.moduleId = moduleId;
2706
+ this.moduleSource = moduleSource;
2707
+ const getLogHandler$1 = (handler) => (log, pos) => {
2708
+ log = normalizeLog(log);
2709
+ if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2710
+ log.id = moduleId;
2711
+ log.hook = "transform";
2712
+ handler(log);
2713
+ };
2714
+ this.debug = getLogHandler$1(this.debug);
2715
+ this.warn = getLogHandler$1(this.warn);
2716
+ this.info = getLogHandler$1(this.info);
2717
+ }
2718
+ error(e, pos) {
2719
+ if (typeof e === "string") e = { message: e };
2720
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
2721
+ e.id = this.moduleId;
2722
+ e.hook = "transform";
2723
+ return error(logPluginError(normalizeLog(e), this.pluginName));
2724
+ }
2725
+ getCombinedSourcemap() {
2726
+ return JSON.parse(this.inner.getCombinedSourcemap());
2727
+ }
2728
+ };
2836
2729
 
2837
2730
  //#endregion
2838
2731
  //#region src/plugin/bindingify-build-hooks.ts
@@ -2997,20 +2890,6 @@ function bindingifyModuleParsed(args$1) {
2997
2890
  meta: bindingifyPluginHookMeta(meta)
2998
2891
  };
2999
2892
  }
3000
- var init_bindingify_build_hooks = __esm({ "src/plugin/bindingify-build-hooks.ts"() {
3001
- init_normalize_hook();
3002
- init_plugin_context$1();
3003
- init_normalized_input_options();
3004
- init_sourcemap();
3005
- init_error();
3006
- init_transform_module_info();
3007
- init_transform_side_effects();
3008
- init_transform_sourcemap();
3009
- init_bindingify_hook_filter();
3010
- init_bindingify_plugin_hook_meta();
3011
- init_plugin_context();
3012
- init_transform_plugin_context();
3013
- } });
3014
2893
 
3015
2894
  //#endregion
3016
2895
  //#region src/utils/transform-rendered-module.ts
@@ -3027,7 +2906,6 @@ function transformToRenderedModule(bindingRenderedModule) {
3027
2906
  }
3028
2907
  };
3029
2908
  }
3030
- var init_transform_rendered_module = __esm({ "src/utils/transform-rendered-module.ts"() {} });
3031
2909
 
3032
2910
  //#endregion
3033
2911
  //#region src/utils/transform-rendered-chunk.ts
@@ -3077,9 +2955,6 @@ function transformChunkModules(modules) {
3077
2955
  }
3078
2956
  return result;
3079
2957
  }
3080
- var init_transform_rendered_chunk = __esm({ "src/utils/transform-rendered-chunk.ts"() {
3081
- init_transform_rendered_module();
3082
- } });
3083
2958
 
3084
2959
  //#endregion
3085
2960
  //#region src/utils/bindingify-output-options.ts
@@ -3164,125 +3039,116 @@ function bindingifyAssetFilenames(assetFileNames) {
3164
3039
  };
3165
3040
  return assetFileNames;
3166
3041
  }
3167
- var init_bindingify_output_options = __esm({ "src/utils/bindingify-output-options.ts"() {
3168
- init_asset_source();
3169
- init_misc();
3170
- init_transform_rendered_chunk();
3171
- } });
3172
3042
 
3173
3043
  //#endregion
3174
3044
  //#region src/options/normalized-output-options.ts
3045
+ var NormalizedOutputOptionsImpl = class {
3046
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3047
+ this.inner = inner;
3048
+ this.outputOptions = outputOptions;
3049
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3050
+ }
3051
+ get dir() {
3052
+ return this.inner.dir ?? void 0;
3053
+ }
3054
+ get entryFileNames() {
3055
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3056
+ }
3057
+ get chunkFileNames() {
3058
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3059
+ }
3060
+ get assetFileNames() {
3061
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3062
+ }
3063
+ get format() {
3064
+ return this.inner.format;
3065
+ }
3066
+ get exports() {
3067
+ return this.inner.exports;
3068
+ }
3069
+ get sourcemap() {
3070
+ return this.inner.sourcemap;
3071
+ }
3072
+ get cssEntryFileNames() {
3073
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3074
+ }
3075
+ get cssChunkFileNames() {
3076
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3077
+ }
3078
+ get shimMissingExports() {
3079
+ return this.inner.shimMissingExports;
3080
+ }
3081
+ get name() {
3082
+ return this.inner.name ?? void 0;
3083
+ }
3084
+ get file() {
3085
+ return this.inner.file ?? void 0;
3086
+ }
3087
+ get inlineDynamicImports() {
3088
+ return this.inner.inlineDynamicImports;
3089
+ }
3090
+ get externalLiveBindings() {
3091
+ return this.inner.externalLiveBindings;
3092
+ }
3093
+ get banner() {
3094
+ return normalizeAddon(this.outputOptions.banner);
3095
+ }
3096
+ get footer() {
3097
+ return normalizeAddon(this.outputOptions.footer);
3098
+ }
3099
+ get intro() {
3100
+ return normalizeAddon(this.outputOptions.intro);
3101
+ }
3102
+ get outro() {
3103
+ return normalizeAddon(this.outputOptions.outro);
3104
+ }
3105
+ get esModule() {
3106
+ return this.inner.esModule;
3107
+ }
3108
+ get extend() {
3109
+ return this.inner.extend;
3110
+ }
3111
+ get globals() {
3112
+ return this.inner.globals || this.outputOptions.globals;
3113
+ }
3114
+ get hashCharacters() {
3115
+ return this.inner.hashCharacters;
3116
+ }
3117
+ get sourcemapDebugIds() {
3118
+ return this.inner.sourcemapDebugIds;
3119
+ }
3120
+ get sourcemapIgnoreList() {
3121
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3122
+ }
3123
+ get sourcemapPathTransform() {
3124
+ return this.outputOptions.sourcemapPathTransform;
3125
+ }
3126
+ get minify() {
3127
+ return this.inner.minify;
3128
+ }
3129
+ get legalComments() {
3130
+ return this.inner.legalComments;
3131
+ }
3132
+ get polyfillRequire() {
3133
+ return this.inner.polyfillRequire;
3134
+ }
3135
+ get plugins() {
3136
+ return this.normalizedOutputPlugins;
3137
+ }
3138
+ get preserveModules() {
3139
+ return this.inner.preserveModules;
3140
+ }
3141
+ get preserveModulesRoot() {
3142
+ return this.inner.preserveModulesRoot;
3143
+ }
3144
+ get virtualDirname() {
3145
+ return this.inner.virtualDirname;
3146
+ }
3147
+ };
3175
3148
  function normalizeAddon(value) {
3176
3149
  if (typeof value === "function") return value;
3177
3150
  return () => value || "";
3178
3151
  }
3179
- var NormalizedOutputOptionsImpl;
3180
- var init_normalized_output_options = __esm({ "src/options/normalized-output-options.ts"() {
3181
- init_bindingify_output_options();
3182
- NormalizedOutputOptionsImpl = class {
3183
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3184
- this.inner = inner;
3185
- this.outputOptions = outputOptions;
3186
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3187
- }
3188
- get dir() {
3189
- return this.inner.dir ?? void 0;
3190
- }
3191
- get entryFileNames() {
3192
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3193
- }
3194
- get chunkFileNames() {
3195
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3196
- }
3197
- get assetFileNames() {
3198
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3199
- }
3200
- get format() {
3201
- return this.inner.format;
3202
- }
3203
- get exports() {
3204
- return this.inner.exports;
3205
- }
3206
- get sourcemap() {
3207
- return this.inner.sourcemap;
3208
- }
3209
- get cssEntryFileNames() {
3210
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3211
- }
3212
- get cssChunkFileNames() {
3213
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3214
- }
3215
- get shimMissingExports() {
3216
- return this.inner.shimMissingExports;
3217
- }
3218
- get name() {
3219
- return this.inner.name ?? void 0;
3220
- }
3221
- get file() {
3222
- return this.inner.file ?? void 0;
3223
- }
3224
- get inlineDynamicImports() {
3225
- return this.inner.inlineDynamicImports;
3226
- }
3227
- get externalLiveBindings() {
3228
- return this.inner.externalLiveBindings;
3229
- }
3230
- get banner() {
3231
- return normalizeAddon(this.outputOptions.banner);
3232
- }
3233
- get footer() {
3234
- return normalizeAddon(this.outputOptions.footer);
3235
- }
3236
- get intro() {
3237
- return normalizeAddon(this.outputOptions.intro);
3238
- }
3239
- get outro() {
3240
- return normalizeAddon(this.outputOptions.outro);
3241
- }
3242
- get esModule() {
3243
- return this.inner.esModule;
3244
- }
3245
- get extend() {
3246
- return this.inner.extend;
3247
- }
3248
- get globals() {
3249
- return this.inner.globals || this.outputOptions.globals;
3250
- }
3251
- get hashCharacters() {
3252
- return this.inner.hashCharacters;
3253
- }
3254
- get sourcemapDebugIds() {
3255
- return this.inner.sourcemapDebugIds;
3256
- }
3257
- get sourcemapIgnoreList() {
3258
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3259
- }
3260
- get sourcemapPathTransform() {
3261
- return this.outputOptions.sourcemapPathTransform;
3262
- }
3263
- get minify() {
3264
- return this.inner.minify;
3265
- }
3266
- get legalComments() {
3267
- return this.inner.legalComments;
3268
- }
3269
- get polyfillRequire() {
3270
- return this.inner.polyfillRequire;
3271
- }
3272
- get plugins() {
3273
- return this.normalizedOutputPlugins;
3274
- }
3275
- get preserveModules() {
3276
- return this.inner.preserveModules;
3277
- }
3278
- get preserveModulesRoot() {
3279
- return this.inner.preserveModulesRoot;
3280
- }
3281
- get virtualDirname() {
3282
- return this.inner.virtualDirname;
3283
- }
3284
- };
3285
- } });
3286
3152
 
3287
3153
  //#endregion
3288
3154
  //#region src/utils/transform-to-rollup-output.ts
@@ -3440,12 +3306,6 @@ function collectChangedBundle(changed, bundle) {
3440
3306
  deleted: Array.from(changed.deleted)
3441
3307
  };
3442
3308
  }
3443
- var init_transform_to_rollup_output = __esm({ "src/utils/transform-to-rollup-output.ts"() {
3444
- init_sourcemap();
3445
- init_asset_source();
3446
- init_error();
3447
- init_transform_rendered_chunk();
3448
- } });
3449
3309
 
3450
3310
  //#endregion
3451
3311
  //#region src/plugin/bindingify-output-hooks.ts
@@ -3597,18 +3457,6 @@ function bindingifyOutro(args$1) {
3597
3457
  meta: bindingifyPluginHookMeta(meta)
3598
3458
  };
3599
3459
  }
3600
- var init_bindingify_output_hooks = __esm({ "src/plugin/bindingify-output-hooks.ts"() {
3601
- init_normalized_input_options();
3602
- init_normalized_output_options();
3603
- init_sourcemap();
3604
- init_error();
3605
- init_normalize_hook();
3606
- init_transform_rendered_chunk();
3607
- init_transform_to_rollup_output();
3608
- init_bindingify_hook_filter();
3609
- init_bindingify_plugin_hook_meta();
3610
- init_plugin_context();
3611
- } });
3612
3460
 
3613
3461
  //#endregion
3614
3462
  //#region src/plugin/bindingify-watch-hooks.ts
@@ -3634,14 +3482,43 @@ function bindingifyCloseWatcher(args$1) {
3634
3482
  meta: bindingifyPluginHookMeta(meta)
3635
3483
  };
3636
3484
  }
3637
- var init_bindingify_watch_hooks = __esm({ "src/plugin/bindingify-watch-hooks.ts"() {
3638
- init_normalize_hook();
3639
- init_bindingify_plugin_hook_meta();
3640
- init_plugin_context();
3641
- } });
3642
3485
 
3643
3486
  //#endregion
3644
3487
  //#region src/plugin/generated/hook-usage.ts
3488
+ let HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3489
+ HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3490
+ HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3491
+ HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3492
+ HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3493
+ HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3494
+ HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3495
+ HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3496
+ HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3497
+ HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3498
+ HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3499
+ HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3500
+ HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3501
+ HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3502
+ HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3503
+ HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3504
+ HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3505
+ HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3506
+ HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3507
+ HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3508
+ HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3509
+ HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3510
+ return HookUsageKind$1;
3511
+ }({});
3512
+ var HookUsage = class {
3513
+ bitflag = BigInt(0);
3514
+ constructor() {}
3515
+ union(kind) {
3516
+ this.bitflag |= BigInt(kind);
3517
+ }
3518
+ inner() {
3519
+ return Number(this.bitflag);
3520
+ }
3521
+ };
3645
3522
  function extractHookUsage(plugin) {
3646
3523
  let hookUsage = new HookUsage();
3647
3524
  if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
@@ -3666,43 +3543,6 @@ function extractHookUsage(plugin) {
3666
3543
  if (plugin.outro) hookUsage.union(HookUsageKind.outro);
3667
3544
  return hookUsage;
3668
3545
  }
3669
- var HookUsageKind, HookUsage;
3670
- var init_hook_usage = __esm({ "src/plugin/generated/hook-usage.ts"() {
3671
- HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3672
- HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3673
- HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3674
- HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3675
- HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3676
- HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3677
- HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3678
- HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3679
- HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3680
- HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3681
- HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3682
- HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3683
- HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3684
- HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3685
- HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3686
- HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3687
- HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3688
- HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3689
- HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3690
- HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3691
- HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3692
- HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3693
- return HookUsageKind$1;
3694
- }({});
3695
- HookUsage = class {
3696
- bitflag = BigInt(0);
3697
- constructor() {}
3698
- union(kind) {
3699
- this.bitflag |= BigInt(kind);
3700
- }
3701
- inner() {
3702
- return Number(this.bitflag);
3703
- }
3704
- };
3705
- } });
3706
3546
 
3707
3547
  //#endregion
3708
3548
  //#region src/plugin/bindingify-plugin.ts
@@ -3825,106 +3665,95 @@ function wrapHandlers(plugin) {
3825
3665
  }
3826
3666
  return plugin;
3827
3667
  }
3828
- var init_bindingify_plugin = __esm({ "src/plugin/bindingify-plugin.ts"() {
3829
- init_bindingify_build_hooks();
3830
- init_bindingify_output_hooks();
3831
- init_logs();
3832
- init_bindingify_watch_hooks();
3833
- init_hook_usage();
3834
- } });
3835
3668
 
3836
3669
  //#endregion
3837
3670
  //#region src/plugin/plugin-context-data.ts
3838
- var PluginContextData;
3839
- var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
3840
- init_transform_module_info();
3841
- PluginContextData = class {
3842
- moduleOptionMap = /* @__PURE__ */ new Map();
3843
- resolveOptionsMap = /* @__PURE__ */ new Map();
3844
- loadModulePromiseMap = /* @__PURE__ */ new Map();
3845
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3846
- renderedChunkMeta = null;
3847
- updateModuleOption(id, option) {
3848
- const existing = this.moduleOptionMap.get(id);
3849
- if (existing) {
3850
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3851
- if (option.meta != null) Object.assign(existing.meta, option.meta);
3852
- if (option.invalidate != null) existing.invalidate = option.invalidate;
3853
- } else {
3854
- this.moduleOptionMap.set(id, option);
3855
- return option;
3856
- }
3857
- return existing;
3858
- }
3859
- getModuleOption(id) {
3860
- const option = this.moduleOptionMap.get(id);
3861
- if (!option) {
3862
- const raw = {
3863
- moduleSideEffects: null,
3864
- meta: {}
3865
- };
3866
- this.moduleOptionMap.set(id, raw);
3867
- return raw;
3868
- }
3671
+ var PluginContextData = class {
3672
+ moduleOptionMap = /* @__PURE__ */ new Map();
3673
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3674
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3675
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3676
+ renderedChunkMeta = null;
3677
+ updateModuleOption(id, option) {
3678
+ const existing = this.moduleOptionMap.get(id);
3679
+ if (existing) {
3680
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3681
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3682
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3683
+ } else {
3684
+ this.moduleOptionMap.set(id, option);
3869
3685
  return option;
3870
3686
  }
3871
- getModuleInfo(id, context) {
3872
- const bindingInfo = context.getModuleInfo(id);
3873
- if (bindingInfo) {
3874
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
3875
- return this.proxyModuleInfo(id, info);
3876
- }
3877
- return null;
3878
- }
3879
- proxyModuleInfo(id, info) {
3880
- let moduleSideEffects = info.moduleSideEffects;
3881
- Object.defineProperty(info, "moduleSideEffects", {
3882
- get() {
3883
- return moduleSideEffects;
3884
- },
3885
- set: (v) => {
3886
- this.updateModuleOption(id, {
3887
- moduleSideEffects: v,
3888
- meta: info.meta,
3889
- invalidate: true
3890
- });
3891
- moduleSideEffects = v;
3892
- }
3893
- });
3894
- return info;
3895
- }
3896
- getModuleIds(context) {
3897
- const moduleIds = context.getModuleIds();
3898
- return moduleIds.values();
3899
- }
3900
- saveResolveOptions(options) {
3901
- const index = this.resolveOptionsMap.size;
3902
- this.resolveOptionsMap.set(index, options);
3903
- return index;
3904
- }
3905
- getSavedResolveOptions(receipt) {
3906
- return this.resolveOptionsMap.get(receipt);
3907
- }
3908
- removeSavedResolveOptions(receipt) {
3909
- this.resolveOptionsMap.delete(receipt);
3910
- }
3911
- setRenderChunkMeta(meta) {
3912
- this.renderedChunkMeta = meta;
3913
- }
3914
- getRenderChunkMeta() {
3915
- return this.renderedChunkMeta;
3916
- }
3917
- markModuleLoaded(id, _success) {
3918
- const resolve = this.loadModulePromiseResolveFnMap.get(id);
3919
- if (resolve) resolve();
3687
+ return existing;
3688
+ }
3689
+ getModuleOption(id) {
3690
+ const option = this.moduleOptionMap.get(id);
3691
+ if (!option) {
3692
+ const raw = {
3693
+ moduleSideEffects: null,
3694
+ meta: {}
3695
+ };
3696
+ this.moduleOptionMap.set(id, raw);
3697
+ return raw;
3920
3698
  }
3921
- clear() {
3922
- this.renderedChunkMeta = null;
3923
- this.loadModulePromiseMap.clear();
3924
- this.loadModulePromiseResolveFnMap.clear();
3699
+ return option;
3700
+ }
3701
+ getModuleInfo(id, context) {
3702
+ const bindingInfo = context.getModuleInfo(id);
3703
+ if (bindingInfo) {
3704
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
3705
+ return this.proxyModuleInfo(id, info);
3925
3706
  }
3926
- };
3927
- } });
3707
+ return null;
3708
+ }
3709
+ proxyModuleInfo(id, info) {
3710
+ let moduleSideEffects = info.moduleSideEffects;
3711
+ Object.defineProperty(info, "moduleSideEffects", {
3712
+ get() {
3713
+ return moduleSideEffects;
3714
+ },
3715
+ set: (v) => {
3716
+ this.updateModuleOption(id, {
3717
+ moduleSideEffects: v,
3718
+ meta: info.meta,
3719
+ invalidate: true
3720
+ });
3721
+ moduleSideEffects = v;
3722
+ }
3723
+ });
3724
+ return info;
3725
+ }
3726
+ getModuleIds(context) {
3727
+ const moduleIds = context.getModuleIds();
3728
+ return moduleIds.values();
3729
+ }
3730
+ saveResolveOptions(options) {
3731
+ const index = this.resolveOptionsMap.size;
3732
+ this.resolveOptionsMap.set(index, options);
3733
+ return index;
3734
+ }
3735
+ getSavedResolveOptions(receipt) {
3736
+ return this.resolveOptionsMap.get(receipt);
3737
+ }
3738
+ removeSavedResolveOptions(receipt) {
3739
+ this.resolveOptionsMap.delete(receipt);
3740
+ }
3741
+ setRenderChunkMeta(meta) {
3742
+ this.renderedChunkMeta = meta;
3743
+ }
3744
+ getRenderChunkMeta() {
3745
+ return this.renderedChunkMeta;
3746
+ }
3747
+ markModuleLoaded(id, _success) {
3748
+ const resolve = this.loadModulePromiseResolveFnMap.get(id);
3749
+ if (resolve) resolve();
3750
+ }
3751
+ clear() {
3752
+ this.renderedChunkMeta = null;
3753
+ this.loadModulePromiseMap.clear();
3754
+ this.loadModulePromiseResolveFnMap.clear();
3755
+ }
3756
+ };
3928
3757
 
3929
3758
  //#endregion
3930
3759
  //#region src/utils/normalize-string-or-regex.ts
@@ -3936,7 +3765,6 @@ function normalizedStringOrRegex(pattern) {
3936
3765
  function isReadonlyArray(input) {
3937
3766
  return Array.isArray(input);
3938
3767
  }
3939
- var init_normalize_string_or_regex = __esm({ "src/utils/normalize-string-or-regex.ts"() {} });
3940
3768
 
3941
3769
  //#endregion
3942
3770
  //#region src/utils/bindingify-input-options.ts
@@ -4004,9 +3832,9 @@ function bindingifyHmr(hmr) {
4004
3832
  function bindingifyAttachDebugInfo(attachDebugInfo) {
4005
3833
  switch (attachDebugInfo) {
4006
3834
  case void 0: return void 0;
4007
- case "full": return import_binding$3.BindingAttachDebugInfo.Full;
4008
- case "simple": return import_binding$3.BindingAttachDebugInfo.Simple;
4009
- case "none": return import_binding$3.BindingAttachDebugInfo.None;
3835
+ case "full": return BindingAttachDebugInfo.Full;
3836
+ case "simple": return BindingAttachDebugInfo.Simple;
3837
+ case "none": return BindingAttachDebugInfo.None;
4010
3838
  }
4011
3839
  }
4012
3840
  function bindingifyExternal(external) {
@@ -4064,10 +3892,10 @@ function bindingifyInject(inject) {
4064
3892
  }
4065
3893
  function bindingifyLogLevel(logLevel) {
4066
3894
  switch (logLevel) {
4067
- case "silent": return import_binding$3.BindingLogLevel.Silent;
4068
- case "debug": return import_binding$3.BindingLogLevel.Debug;
4069
- case "warn": return import_binding$3.BindingLogLevel.Warn;
4070
- case "info": return import_binding$3.BindingLogLevel.Info;
3895
+ case "silent": return BindingLogLevel.Silent;
3896
+ case "debug": return BindingLogLevel.Debug;
3897
+ case "warn": return BindingLogLevel.Warn;
3898
+ case "info": return BindingLogLevel.Info;
4071
3899
  default: throw new Error(`Unexpected log level: ${logLevel}`);
4072
3900
  }
4073
3901
  }
@@ -4084,7 +3912,7 @@ function bindingifyInput(input) {
4084
3912
  }
4085
3913
  function bindingifyJsx(input) {
4086
3914
  if (typeof input === "object") {
4087
- if (input.mode === "preserve") return { jsx: import_binding$3.BindingJsx.Preserve };
3915
+ if (input.mode === "preserve") return { jsx: BindingJsx.Preserve };
4088
3916
  const mode = input.mode ?? "automatic";
4089
3917
  return { jsxTransform: { jsx: {
4090
3918
  runtime: mode,
@@ -4094,10 +3922,10 @@ function bindingifyJsx(input) {
4094
3922
  } } };
4095
3923
  }
4096
3924
  switch (input) {
4097
- case false: return { jsx: import_binding$3.BindingJsx.Disable };
4098
- case "react": return { jsx: import_binding$3.BindingJsx.React };
4099
- case "react-jsx": return { jsx: import_binding$3.BindingJsx.ReactJsx };
4100
- case "preserve": return { jsx: import_binding$3.BindingJsx.Preserve };
3925
+ case false: return { jsx: BindingJsx.Disable };
3926
+ case "react": return { jsx: BindingJsx.React };
3927
+ case "react-jsx": return { jsx: BindingJsx.ReactJsx };
3928
+ case "preserve": return { jsx: BindingJsx.Preserve };
4101
3929
  default: return { jsx: void 0 };
4102
3930
  }
4103
3931
  }
@@ -4147,33 +3975,31 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4147
3975
  field0: preserveEntrySignatures
4148
3976
  };
4149
3977
  }
4150
- var import_binding$3;
4151
- var init_bindingify_input_options = __esm({ "src/utils/bindingify-input-options.ts"() {
4152
- import_binding$3 = __toESM(require_binding());
4153
- init_constructors();
4154
- init_utils();
4155
- init_bindingify_plugin();
4156
- init_plugin_context_data();
4157
- init_misc();
4158
- init_normalize_string_or_regex();
4159
- init_transform_side_effects();
4160
- } });
4161
3978
 
4162
3979
  //#endregion
4163
3980
  //#region src/utils/plugin/index.ts
4164
- var isPluginHookName;
4165
- var init_plugin = __esm({ "src/utils/plugin/index.ts"() {
4166
- init_plugin$1();
4167
- isPluginHookName = function() {
4168
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4169
- return function isPluginHookName$1(hookName) {
4170
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4171
- };
4172
- }();
4173
- } });
3981
+ const isPluginHookName = function() {
3982
+ const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
3983
+ return function isPluginHookName$1(hookName) {
3984
+ return PLUGIN_HOOK_NAMES_SET.has(hookName);
3985
+ };
3986
+ }();
4174
3987
 
4175
3988
  //#endregion
4176
3989
  //#region src/utils/compose-js-plugins.ts
3990
+ const unsupportedHookName = [
3991
+ "augmentChunkHash",
3992
+ "generateBundle",
3993
+ "moduleParsed",
3994
+ "onLog",
3995
+ "options",
3996
+ "outputOptions",
3997
+ "renderError",
3998
+ "renderStart",
3999
+ "resolveDynamicImport",
4000
+ "writeBundle"
4001
+ ];
4002
+ const unsupportedHooks = new Set(unsupportedHookName);
4177
4003
  function isUnsupportedHooks(hookName) {
4178
4004
  return unsupportedHooks.has(hookName);
4179
4005
  }
@@ -4466,28 +4292,6 @@ function composeJsPlugins(plugins) {
4466
4292
  }
4467
4293
  return newPlugins;
4468
4294
  }
4469
- var unsupportedHookName, unsupportedHooks;
4470
- var init_compose_js_plugins = __esm({ "src/utils/compose-js-plugins.ts"() {
4471
- init_dist();
4472
- init_constructors();
4473
- init_plugin_context$1();
4474
- init_misc();
4475
- init_normalize_hook();
4476
- init_plugin();
4477
- unsupportedHookName = [
4478
- "augmentChunkHash",
4479
- "generateBundle",
4480
- "moduleParsed",
4481
- "onLog",
4482
- "options",
4483
- "outputOptions",
4484
- "renderError",
4485
- "renderStart",
4486
- "resolveDynamicImport",
4487
- "writeBundle"
4488
- ];
4489
- unsupportedHooks = new Set(unsupportedHookName);
4490
- } });
4491
4295
 
4492
4296
  //#endregion
4493
4297
  //#region src/utils/initialize-parallel-plugins.ts
@@ -4503,7 +4307,7 @@ async function initializeParallelPlugins(plugins) {
4503
4307
  }
4504
4308
  if (pluginInfos.length <= 0) return void 0;
4505
4309
  const count = availableParallelism();
4506
- const parallelJsPluginRegistry = new import_binding$2.ParallelJsPluginRegistry(count);
4310
+ const parallelJsPluginRegistry = new ParallelJsPluginRegistry(count);
4507
4311
  const registryId = parallelJsPluginRegistry.id;
4508
4312
  const workers = await initializeWorkers(registryId, count, pluginInfos);
4509
4313
  const stopWorkers = async () => {
@@ -4540,20 +4344,16 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
4540
4344
  throw e;
4541
4345
  }
4542
4346
  }
4543
- var import_binding$2, availableParallelism;
4544
- var init_initialize_parallel_plugins = __esm({ "src/utils/initialize-parallel-plugins.ts"() {
4545
- import_binding$2 = __toESM(require_binding());
4546
- availableParallelism = () => {
4547
- let availableParallelism$1 = 1;
4548
- try {
4549
- availableParallelism$1 = os.availableParallelism();
4550
- } catch {
4551
- const cpus = os.cpus();
4552
- if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4553
- }
4554
- return Math.min(availableParallelism$1, 8);
4555
- };
4556
- } });
4347
+ const availableParallelism = () => {
4348
+ let availableParallelism$1 = 1;
4349
+ try {
4350
+ availableParallelism$1 = os.availableParallelism();
4351
+ } catch {
4352
+ const cpus = os.cpus();
4353
+ if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4354
+ }
4355
+ return Math.min(availableParallelism$1, 8);
4356
+ };
4557
4357
 
4558
4358
  //#endregion
4559
4359
  //#region src/utils/create-bundler-option.ts
@@ -4589,28 +4389,19 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4589
4389
  throw e;
4590
4390
  }
4591
4391
  }
4592
- var init_create_bundler_option = __esm({ "src/utils/create-bundler-option.ts"() {
4593
- init_logger();
4594
- init_logging();
4595
- init_plugin_driver();
4596
- init_bindingify_input_options();
4597
- init_bindingify_output_options();
4598
- init_compose_js_plugins();
4599
- init_initialize_parallel_plugins();
4600
- init_normalize_plugin_option();
4601
- } });
4602
4392
 
4603
4393
  //#endregion
4604
4394
  //#region src/utils/create-bundler.ts
4605
- async function createBundler(inputOptions, outputOptions, isClose) {
4395
+ let asyncRuntimeShutdown = false;
4396
+ async function createBundlerImpl(bundler, inputOptions, outputOptions, isClose) {
4606
4397
  const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
4607
- if (asyncRuntimeShutdown) (0, import_binding$1.startAsyncRuntime)();
4398
+ if (asyncRuntimeShutdown) startAsyncRuntime();
4608
4399
  try {
4609
4400
  return {
4610
- bundler: new import_binding$1.Bundler(option.bundlerOptions),
4401
+ impl: bundler.createImpl(option.bundlerOptions),
4611
4402
  stopWorkers: option.stopWorkers,
4612
4403
  shutdown: () => {
4613
- (0, import_binding$1.shutdownAsyncRuntime)();
4404
+ shutdownAsyncRuntime();
4614
4405
  asyncRuntimeShutdown = true;
4615
4406
  }
4616
4407
  };
@@ -4619,12 +4410,6 @@ async function createBundler(inputOptions, outputOptions, isClose) {
4619
4410
  throw e;
4620
4411
  }
4621
4412
  }
4622
- var import_binding$1, asyncRuntimeShutdown;
4623
- var init_create_bundler = __esm({ "src/utils/create-bundler.ts"() {
4624
- import_binding$1 = __toESM(require_binding());
4625
- init_create_bundler_option();
4626
- asyncRuntimeShutdown = false;
4627
- } });
4628
4413
 
4629
4414
  //#endregion
4630
4415
  //#region src/utils/transform-hmr-patch-output.ts
@@ -4637,80 +4422,66 @@ function handleHmrPatchOutputErrors(output) {
4637
4422
  const rawErrors = output.errors;
4638
4423
  if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
4639
4424
  }
4640
- var init_transform_hmr_patch_output = __esm({ "src/utils/transform-hmr-patch-output.ts"() {
4641
- init_error();
4642
- } });
4643
4425
 
4644
4426
  //#endregion
4645
4427
  //#region src/api/rolldown/rolldown-build.ts
4646
- var RolldownBuild;
4647
- var init_rolldown_build = __esm({ "src/api/rolldown/rolldown-build.ts"() {
4648
- init_create_bundler();
4649
- init_transform_to_rollup_output();
4650
- init_transform_hmr_patch_output();
4651
- init_validator();
4652
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4653
- RolldownBuild = class {
4654
- #inputOptions;
4655
- #bundler;
4656
- constructor(inputOptions) {
4657
- this.#inputOptions = inputOptions;
4658
- }
4659
- get closed() {
4660
- return this.#bundler?.bundler.closed ?? false;
4661
- }
4662
- async #getBundlerWithStopWorker(outputOptions, isClose) {
4663
- if (this.#bundler) await this.#bundler.stopWorkers?.();
4664
- return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
4665
- }
4666
- async generate(outputOptions = {}) {
4667
- validateOption("output", outputOptions);
4668
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4669
- const output = await bundler.generate();
4670
- return transformToRollupOutput(output);
4671
- }
4672
- async write(outputOptions = {}) {
4673
- validateOption("output", outputOptions);
4674
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4675
- const output = await bundler.write();
4676
- return transformToRollupOutput(output);
4677
- }
4678
- async close() {
4679
- const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4680
- await stopWorkers?.();
4681
- await bundler.close();
4682
- shutdown();
4683
- }
4684
- async [Symbol.asyncDispose]() {
4685
- await this.close();
4686
- }
4687
- async generateHmrPatch(changedFiles) {
4688
- const output = await this.#bundler.bundler.generateHmrPatch(changedFiles);
4689
- return transformHmrPatchOutput(output);
4690
- }
4691
- async hmrInvalidate(file, firstInvalidatedBy) {
4692
- const output = await this.#bundler.bundler.hmrInvalidate(file, firstInvalidatedBy);
4693
- return transformHmrPatchOutput(output);
4694
- }
4695
- get watchFiles() {
4696
- return this.#bundler?.bundler.getWatchFiles() ?? Promise.resolve([]);
4697
- }
4698
- };
4699
- } });
4428
+ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4429
+ var RolldownBuild = class {
4430
+ #inputOptions;
4431
+ #bundler;
4432
+ #bundlerImpl;
4433
+ constructor(inputOptions) {
4434
+ this.#inputOptions = inputOptions;
4435
+ this.#bundler = new BindingBundler();
4436
+ }
4437
+ get closed() {
4438
+ return this.#bundlerImpl?.impl.closed ?? false;
4439
+ }
4440
+ async #getBundlerWithStopWorker(outputOptions, isClose) {
4441
+ if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4442
+ return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions, isClose);
4443
+ }
4444
+ async generate(outputOptions = {}) {
4445
+ validateOption("output", outputOptions);
4446
+ const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4447
+ const output = await impl.generate();
4448
+ return transformToRollupOutput(output);
4449
+ }
4450
+ async write(outputOptions = {}) {
4451
+ validateOption("output", outputOptions);
4452
+ const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4453
+ const output = await impl.write();
4454
+ return transformToRollupOutput(output);
4455
+ }
4456
+ async close() {
4457
+ const { impl, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4458
+ await stopWorkers?.();
4459
+ await impl.close();
4460
+ shutdown();
4461
+ }
4462
+ async [Symbol.asyncDispose]() {
4463
+ await this.close();
4464
+ }
4465
+ async generateHmrPatch(changedFiles) {
4466
+ const output = await this.#bundlerImpl.impl.generateHmrPatch(changedFiles);
4467
+ return transformHmrPatchOutput(output);
4468
+ }
4469
+ async hmrInvalidate(file, firstInvalidatedBy) {
4470
+ const output = await this.#bundlerImpl.impl.hmrInvalidate(file, firstInvalidatedBy);
4471
+ return transformHmrPatchOutput(output);
4472
+ }
4473
+ get watchFiles() {
4474
+ return this.#bundlerImpl?.impl.getWatchFiles() ?? Promise.resolve([]);
4475
+ }
4476
+ };
4700
4477
 
4701
4478
  //#endregion
4702
4479
  //#region src/api/rolldown/index.ts
4703
- var rolldown;
4704
- var init_rolldown = __esm({ "src/api/rolldown/index.ts"() {
4705
- init_plugin_driver();
4706
- init_validator();
4707
- init_rolldown_build();
4708
- rolldown = async (input) => {
4709
- validateOption("input", input);
4710
- const inputOptions = await PluginDriver.callOptionsHook(input);
4711
- return new RolldownBuild(inputOptions);
4712
- };
4713
- } });
4480
+ const rolldown = async (input) => {
4481
+ validateOption("input", input);
4482
+ const inputOptions = await PluginDriver.callOptionsHook(input);
4483
+ return new RolldownBuild(inputOptions);
4484
+ };
4714
4485
 
4715
4486
  //#endregion
4716
4487
  //#region src/api/build.ts
@@ -4727,86 +4498,106 @@ async function build(options) {
4727
4498
  }
4728
4499
  }
4729
4500
  }
4730
- var init_build = __esm({ "src/api/build.ts"() {
4731
- init_rolldown();
4732
- } });
4733
4501
 
4734
4502
  //#endregion
4735
4503
  //#region src/api/watch/watch-emitter.ts
4736
- var WatcherEmitter;
4737
- var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
4738
- init_error();
4739
- WatcherEmitter = class {
4740
- listeners = /* @__PURE__ */ new Map();
4741
- timer;
4742
- constructor() {
4743
- this.timer = setInterval(() => {}, 1e9);
4744
- }
4745
- on(event, listener) {
4746
- const listeners = this.listeners.get(event);
4747
- if (listeners) listeners.push(listener);
4748
- else this.listeners.set(event, [listener]);
4749
- return this;
4750
- }
4751
- off(event, listener) {
4752
- const listeners = this.listeners.get(event);
4753
- if (listeners) {
4754
- const index = listeners.indexOf(listener);
4755
- if (index !== -1) listeners.splice(index, 1);
4756
- }
4757
- return this;
4504
+ var WatcherEmitter = class {
4505
+ listeners = /* @__PURE__ */ new Map();
4506
+ timer;
4507
+ constructor() {
4508
+ this.timer = setInterval(() => {}, 1e9);
4509
+ }
4510
+ on(event, listener) {
4511
+ const listeners = this.listeners.get(event);
4512
+ if (listeners) listeners.push(listener);
4513
+ else this.listeners.set(event, [listener]);
4514
+ return this;
4515
+ }
4516
+ off(event, listener) {
4517
+ const listeners = this.listeners.get(event);
4518
+ if (listeners) {
4519
+ const index = listeners.indexOf(listener);
4520
+ if (index !== -1) listeners.splice(index, 1);
4758
4521
  }
4759
- async onEvent(event) {
4760
- const listeners = this.listeners.get(event.eventKind());
4761
- if (listeners) switch (event.eventKind()) {
4762
- case "close":
4763
- case "restart":
4764
- for (const listener of listeners) await listener();
4765
- break;
4766
- case "event":
4767
- for (const listener of listeners) {
4768
- const code = event.bundleEventKind();
4769
- switch (code) {
4770
- case "BUNDLE_END":
4771
- const { duration, output, result } = event.bundleEndData();
4772
- await listener({
4773
- code: "BUNDLE_END",
4774
- duration,
4775
- output: [output],
4776
- result
4777
- });
4778
- break;
4779
- case "ERROR":
4780
- const data = event.bundleErrorData();
4781
- await listener({
4782
- code: "ERROR",
4783
- error: normalizeErrors(data.error),
4784
- result: data.result
4785
- });
4786
- break;
4787
- default:
4788
- await listener({ code });
4789
- break;
4790
- }
4791
- }
4792
- break;
4793
- case "change":
4794
- for (const listener of listeners) {
4795
- const { path: path$1, kind } = event.watchChangeData();
4796
- await listener(path$1, { event: kind });
4522
+ return this;
4523
+ }
4524
+ async onEvent(event) {
4525
+ const listeners = this.listeners.get(event.eventKind());
4526
+ if (listeners) switch (event.eventKind()) {
4527
+ case "close":
4528
+ case "restart":
4529
+ for (const listener of listeners) await listener();
4530
+ break;
4531
+ case "event":
4532
+ for (const listener of listeners) {
4533
+ const code = event.bundleEventKind();
4534
+ switch (code) {
4535
+ case "BUNDLE_END":
4536
+ const { duration, output, result } = event.bundleEndData();
4537
+ await listener({
4538
+ code: "BUNDLE_END",
4539
+ duration,
4540
+ output: [output],
4541
+ result
4542
+ });
4543
+ break;
4544
+ case "ERROR":
4545
+ const data = event.bundleErrorData();
4546
+ await listener({
4547
+ code: "ERROR",
4548
+ error: normalizeErrors(data.error),
4549
+ result: data.result
4550
+ });
4551
+ break;
4552
+ default:
4553
+ await listener({ code });
4554
+ break;
4797
4555
  }
4798
- break;
4799
- default: throw new Error(`Unknown event: ${event}`);
4800
- }
4801
- }
4802
- async close() {
4803
- clearInterval(this.timer);
4556
+ }
4557
+ break;
4558
+ case "change":
4559
+ for (const listener of listeners) {
4560
+ const { path: path$1, kind } = event.watchChangeData();
4561
+ await listener(path$1, { event: kind });
4562
+ }
4563
+ break;
4564
+ default: throw new Error(`Unknown event: ${event}`);
4804
4565
  }
4805
- };
4806
- } });
4566
+ }
4567
+ async close() {
4568
+ clearInterval(this.timer);
4569
+ }
4570
+ };
4807
4571
 
4808
4572
  //#endregion
4809
4573
  //#region src/api/watch/watcher.ts
4574
+ var Watcher = class {
4575
+ closed;
4576
+ inner;
4577
+ emitter;
4578
+ stopWorkers;
4579
+ constructor(emitter, inner, stopWorkers) {
4580
+ this.closed = false;
4581
+ this.inner = inner;
4582
+ this.emitter = emitter;
4583
+ const originClose = emitter.close.bind(emitter);
4584
+ emitter.close = async () => {
4585
+ await this.close();
4586
+ originClose();
4587
+ };
4588
+ this.stopWorkers = stopWorkers;
4589
+ }
4590
+ async close() {
4591
+ if (this.closed) return;
4592
+ this.closed = true;
4593
+ for (const stop of this.stopWorkers) await stop?.();
4594
+ await this.inner.close();
4595
+ shutdownAsyncRuntime();
4596
+ }
4597
+ start() {
4598
+ process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4599
+ }
4600
+ };
4810
4601
  async function createWatcher(emitter, input) {
4811
4602
  const options = arraify(input);
4812
4603
  const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
@@ -4814,7 +4605,7 @@ async function createWatcher(emitter, input) {
4814
4605
  return createBundlerOptions(inputOptions, output, true);
4815
4606
  })).flat());
4816
4607
  const notifyOptions = getValidNotifyOption(bundlerOptions);
4817
- const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
4608
+ const bindingWatcher = new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
4818
4609
  const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
4819
4610
  watcher.start();
4820
4611
  }
@@ -4828,73 +4619,24 @@ function getValidNotifyOption(bundlerOptions) {
4828
4619
  } else result = notifyOption;
4829
4620
  }
4830
4621
  }
4831
- var import_binding, Watcher;
4832
- var init_watcher = __esm({ "src/api/watch/watcher.ts"() {
4833
- import_binding = __toESM(require_binding());
4834
- init_logging();
4835
- init_logs();
4836
- init_plugin_driver();
4837
- init_create_bundler_option();
4838
- init_misc();
4839
- Watcher = class {
4840
- closed;
4841
- inner;
4842
- emitter;
4843
- stopWorkers;
4844
- constructor(emitter, inner, stopWorkers) {
4845
- this.closed = false;
4846
- this.inner = inner;
4847
- this.emitter = emitter;
4848
- const originClose = emitter.close.bind(emitter);
4849
- emitter.close = async () => {
4850
- await this.close();
4851
- originClose();
4852
- };
4853
- this.stopWorkers = stopWorkers;
4854
- }
4855
- async close() {
4856
- if (this.closed) return;
4857
- this.closed = true;
4858
- for (const stop of this.stopWorkers) await stop?.();
4859
- await this.inner.close();
4860
- (0, import_binding.shutdownAsyncRuntime)();
4861
- }
4862
- start() {
4863
- process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4864
- }
4865
- };
4866
- } });
4867
4622
 
4868
4623
  //#endregion
4869
4624
  //#region src/api/watch/index.ts
4870
- var watch;
4871
- var init_watch = __esm({ "src/api/watch/index.ts"() {
4872
- init_watch_emitter();
4873
- init_watcher();
4874
- watch = (input) => {
4875
- const emitter = new WatcherEmitter();
4876
- createWatcher(emitter, input);
4877
- return emitter;
4878
- };
4879
- } });
4625
+ const watch = (input) => {
4626
+ const emitter = new WatcherEmitter();
4627
+ createWatcher(emitter, input);
4628
+ return emitter;
4629
+ };
4880
4630
 
4881
4631
  //#endregion
4882
4632
  //#region src/utils/define-config.ts
4883
4633
  function defineConfig(config) {
4884
4634
  return config;
4885
4635
  }
4886
- var init_define_config = __esm({ "src/utils/define-config.ts"() {} });
4887
4636
 
4888
4637
  //#endregion
4889
4638
  //#region src/index.ts
4890
- var VERSION;
4891
- var init_src = __esm({ "src/index.ts"() {
4892
- init_build();
4893
- init_rolldown();
4894
- init_watch();
4895
- init_define_config();
4896
- VERSION = version;
4897
- } });
4639
+ const VERSION = version;
4898
4640
 
4899
4641
  //#endregion
4900
- export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, init_bindingify_plugin, init_compose_js_plugins, init_constructors, init_create_bundler, init_define_config, init_normalize_string_or_regex, init_plugin_context_data, init_plugin_driver, init_rolldown, init_src, init_transform_to_rollup_output, init_validator, init_watch, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };
4642
+ export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundlerImpl, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin };