@rolldown/browser 1.0.0-beta.16 → 1.0.0-beta.17

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 (45) hide show
  1. package/dist/cli.cjs +3 -3
  2. package/dist/cli.mjs +1040 -1081
  3. package/dist/config.cjs +2 -2
  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.browser.mjs +3 -3
  8. package/dist/experimental-index.cjs +2 -2
  9. package/dist/experimental-index.d.cts +2 -2
  10. package/dist/experimental-index.d.mts +2 -2
  11. package/dist/experimental-index.mjs +5 -17
  12. package/dist/filter-index.d.cts +2 -2
  13. package/dist/filter-index.d.mts +2 -2
  14. package/dist/filter-index.mjs +1 -6
  15. package/dist/index.browser.mjs +1 -1
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.cts +2 -2
  18. package/dist/index.d.mts +2 -2
  19. package/dist/index.mjs +3 -4
  20. package/dist/parallel-plugin-worker.cjs +1 -1
  21. package/dist/parallel-plugin-worker.mjs +27 -33
  22. package/dist/parallel-plugin.d.cts +2 -2
  23. package/dist/parallel-plugin.d.mts +2 -2
  24. package/dist/parse-ast-index.d.cts +1 -1
  25. package/dist/parse-ast-index.d.mts +1 -1
  26. package/dist/parse-ast-index.mjs +1 -2
  27. package/dist/rolldown-binding.wasi-browser.js +3 -2
  28. package/dist/rolldown-binding.wasi.cjs +2 -1
  29. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  30. package/dist/shared/{binding--Y47JZSL.d.cts → binding-CWvDTpOw.d.mts} +14 -14
  31. package/dist/shared/{binding-C_9au5Eg.d.mts → binding-um3VI33z.d.cts} +14 -14
  32. package/dist/shared/{define-config-CFPAmfEQ.d.mts → define-config-DETTMcOl.d.mts} +69 -9
  33. package/dist/shared/{define-config-CAyC9-af.d.cts → define-config-POPyhxOq.d.cts} +69 -9
  34. package/dist/shared/dist-BoWaIc-K.mjs +147 -0
  35. package/dist/shared/{load-config-CHic6lPj.mjs → load-config-C0FU-xTD.mjs} +14 -19
  36. package/dist/shared/{load-config-CKPqlbjH.cjs → load-config-Cp5Lu-qW.cjs} +1 -1
  37. package/dist/shared/{parse-ast-index-BjSB6ZTb.mjs → parse-ast-index-B5AmHtd5.mjs} +9 -27
  38. package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
  39. package/dist/shared/{src-C_ps7iS5.mjs → src-CsIMaM6C.mjs} +1143 -1367
  40. package/dist/shared/{src-Cw7MpyXh.cjs → src-D8KQ1KMN.cjs} +19 -17
  41. package/dist/{src-UXJBOke0.js → src-Bv_xHi2_.js} +19 -17
  42. package/package.json +3 -2
  43. package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
  44. package/dist/shared/dist-DeDsdiza.mjs +0 -153
  45. package/dist/shared/prompt-C14hEutp.mjs +0 -854
@@ -1,14 +1,39 @@
1
- import { __commonJS, __esm, __toESM } from "./chunk-DSsiIF1Z.mjs";
2
- import { and, arraify, code, exclude, id, include, init_dist, init_misc, isNullish, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-DeDsdiza.mjs";
3
- import { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-BjSB6ZTb.mjs";
4
- import { BindingAttachDebugInfo, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, Bundler, ParallelJsPluginRegistry, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
1
+ import { and, arraify, code, exclude, id, include, isNullish, moduleType, noop, or, unimplemented, unreachable, unsupported } from "./dist-BoWaIc-K.mjs";
2
+ import { augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst } from "./parse-ast-index-B5AmHtd5.mjs";
3
+ import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingHookSideEffects, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, shutdownAsyncRuntime, startAsyncRuntime } from "../rolldown-binding.wasi.cjs";
5
4
  import path from "node:path";
6
5
  import { fileURLToPath } from "node:url";
7
6
  import os from "node:os";
8
7
  import { Worker } from "node:worker_threads";
9
8
 
9
+ //#region rolldown:runtime
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __commonJS = (cb, mod) => function() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i$2 = 0, n$1 = keys.length, key; i$2 < n$1; i$2++) {
21
+ key = keys[i$2];
22
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
23
+ get: ((k) => from[k]).bind(null, key),
24
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
25
+ });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+
34
+ //#endregion
10
35
  //#region package.json
11
- var version = "1.0.0-beta.16";
36
+ var version = "1.0.0-beta.17";
12
37
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
38
 
14
39
  //#endregion
@@ -27,10 +52,15 @@ function bindingifyBuiltInPlugin(plugin) {
27
52
  options: plugin._options
28
53
  };
29
54
  }
30
- var init_utils = __esm({ "src/builtin-plugin/utils.ts"() {} });
31
55
 
32
56
  //#endregion
33
57
  //#region src/builtin-plugin/constructors.ts
58
+ var BuiltinPlugin = class {
59
+ constructor(name, _options) {
60
+ this.name = name;
61
+ this._options = _options;
62
+ }
63
+ };
34
64
  function modulePreloadPolyfillPlugin(config) {
35
65
  return new BuiltinPlugin("builtin:module-preload-polyfill", config);
36
66
  }
@@ -100,36 +130,24 @@ function webWorkerPostPlugin() {
100
130
  function oxcRuntimePlugin(config) {
101
131
  return new BuiltinPlugin("builtin:oxc-runtime", config);
102
132
  }
103
- var BuiltinPlugin;
104
- var init_constructors = __esm({ "src/builtin-plugin/constructors.ts"() {
105
- init_utils();
106
- BuiltinPlugin = class {
107
- constructor(name, _options) {
108
- this.name = name;
109
- this._options = _options;
110
- }
111
- };
112
- } });
113
133
 
114
134
  //#endregion
115
135
  //#region src/log/logging.ts
116
- var LOG_LEVEL_SILENT, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, logLevelPriority;
117
- var init_logging = __esm({ "src/log/logging.ts"() {
118
- LOG_LEVEL_SILENT = "silent";
119
- LOG_LEVEL_ERROR = "error";
120
- LOG_LEVEL_WARN = "warn";
121
- LOG_LEVEL_INFO = "info";
122
- LOG_LEVEL_DEBUG = "debug";
123
- logLevelPriority = {
124
- [LOG_LEVEL_DEBUG]: 0,
125
- [LOG_LEVEL_INFO]: 1,
126
- [LOG_LEVEL_WARN]: 2,
127
- [LOG_LEVEL_SILENT]: 3
128
- };
129
- } });
136
+ const LOG_LEVEL_SILENT = "silent";
137
+ const LOG_LEVEL_ERROR = "error";
138
+ const LOG_LEVEL_WARN = "warn";
139
+ const LOG_LEVEL_INFO = "info";
140
+ const LOG_LEVEL_DEBUG = "debug";
141
+ const logLevelPriority = {
142
+ [LOG_LEVEL_DEBUG]: 0,
143
+ [LOG_LEVEL_INFO]: 1,
144
+ [LOG_LEVEL_WARN]: 2,
145
+ [LOG_LEVEL_SILENT]: 3
146
+ };
130
147
 
131
148
  //#endregion
132
149
  //#region src/log/log-handler.ts
150
+ const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
133
151
  function getLogHandler(level, code$1, logger, pluginName, logLevel) {
134
152
  if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
135
153
  return (log, pos) => {
@@ -141,13 +159,6 @@ function getLogHandler(level, code$1, logger, pluginName, logLevel) {
141
159
  logger(level, log);
142
160
  };
143
161
  }
144
- var normalizeLog;
145
- var init_log_handler = __esm({ "src/log/log-handler.ts"() {
146
- init_misc();
147
- init_logging();
148
- init_logs();
149
- normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
150
- } });
151
162
 
152
163
  //#endregion
153
164
  //#region src/log/logger.ts
@@ -183,55 +194,47 @@ function getLogger(plugins, onLog, logLevel, watchMode) {
183
194
  };
184
195
  return logger;
185
196
  }
197
+ const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
198
+ const { onwarn, onLog } = config;
199
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
200
+ if (onLog) {
201
+ const minimalPriority = logLevelPriority[logLevel];
202
+ return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
203
+ if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
204
+ if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
205
+ });
206
+ }
207
+ return defaultOnLog;
208
+ };
209
+ const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
210
+ if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
211
+ else printLog(level, log);
212
+ } : printLog;
213
+ const addLogToString = (log) => {
214
+ Object.defineProperty(log, "toString", {
215
+ value: () => getExtendedLogMessage(log),
216
+ writable: true
217
+ });
218
+ return log;
219
+ };
220
+ const defaultPrintLog = (level, log) => {
221
+ const message = getExtendedLogMessage(log);
222
+ switch (level) {
223
+ case LOG_LEVEL_WARN: return console.warn(message);
224
+ case LOG_LEVEL_DEBUG: return console.debug(message);
225
+ default: return console.info(message);
226
+ }
227
+ };
228
+ const getExtendedLogMessage = (log) => {
229
+ let prefix = "";
230
+ if (log.plugin) prefix += `(${log.plugin} plugin) `;
231
+ if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
232
+ return prefix + log.message;
233
+ };
186
234
  function relativeId(id$1) {
187
235
  if (!path.isAbsolute(id$1)) return id$1;
188
236
  return path.relative(path.resolve(), id$1);
189
237
  }
190
- var getOnLog, getDefaultOnLog, addLogToString, defaultPrintLog, getExtendedLogMessage;
191
- var init_logger = __esm({ "src/log/logger.ts"() {
192
- init_src();
193
- init_plugin_driver();
194
- init_log_handler();
195
- init_logging();
196
- init_logs();
197
- getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
198
- const { onwarn, onLog } = config;
199
- const defaultOnLog = getDefaultOnLog(printLog, onwarn);
200
- if (onLog) {
201
- const minimalPriority = logLevelPriority[logLevel];
202
- return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
203
- if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
204
- if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
205
- });
206
- }
207
- return defaultOnLog;
208
- };
209
- getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
210
- if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
211
- else printLog(level, log);
212
- } : printLog;
213
- addLogToString = (log) => {
214
- Object.defineProperty(log, "toString", {
215
- value: () => getExtendedLogMessage(log),
216
- writable: true
217
- });
218
- return log;
219
- };
220
- defaultPrintLog = (level, log) => {
221
- const message = getExtendedLogMessage(log);
222
- switch (level) {
223
- case LOG_LEVEL_WARN: return console.warn(message);
224
- case LOG_LEVEL_DEBUG: return console.debug(message);
225
- default: return console.info(message);
226
- }
227
- };
228
- getExtendedLogMessage = (log) => {
229
- let prefix = "";
230
- if (log.plugin) prefix += `(${log.plugin} plugin) `;
231
- if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
232
- return prefix + log.message;
233
- };
234
- } });
235
238
 
236
239
  //#endregion
237
240
  //#region src/utils/normalize-hook.ts
@@ -251,71 +254,75 @@ function normalizeHook(hook) {
251
254
  }
252
255
  unreachable("Invalid hook type");
253
256
  }
254
- var init_normalize_hook = __esm({ "src/utils/normalize-hook.ts"() {
255
- init_misc();
256
- } });
257
257
 
258
258
  //#endregion
259
259
  //#region src/constants/plugin.ts
260
- var ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, ENUMERATED_PLUGIN_HOOK_NAMES, DEFINED_HOOK_NAMES;
261
- var init_plugin$1 = __esm({ "src/constants/plugin.ts"() {
262
- ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
263
- "options",
264
- "buildStart",
265
- "resolveId",
266
- "load",
267
- "transform",
268
- "moduleParsed",
269
- "buildEnd",
270
- "onLog",
271
- "resolveDynamicImport",
272
- "closeBundle",
273
- "closeWatcher",
274
- "watchChange"
275
- ];
276
- ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
277
- "augmentChunkHash",
278
- "outputOptions",
279
- "renderChunk",
280
- "renderStart",
281
- "renderError",
282
- "writeBundle",
283
- "generateBundle"
284
- ];
285
- ENUMERATED_PLUGIN_HOOK_NAMES = [
286
- ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
287
- ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
288
- "footer",
289
- "banner",
290
- "intro",
291
- "outro"
292
- ];
293
- DEFINED_HOOK_NAMES = {
294
- [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
295
- [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
296
- [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
297
- [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
298
- [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
299
- [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
300
- [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
301
- [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
302
- [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
303
- [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
304
- [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
305
- [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
306
- [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
307
- [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
308
- [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
309
- [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
310
- [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
311
- [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
312
- [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
313
- [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
314
- [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
315
- [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
316
- [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
317
- };
318
- } });
260
+ const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
261
+ "options",
262
+ "buildStart",
263
+ "resolveId",
264
+ "load",
265
+ "transform",
266
+ "moduleParsed",
267
+ "buildEnd",
268
+ "onLog",
269
+ "resolveDynamicImport",
270
+ "closeBundle",
271
+ "closeWatcher",
272
+ "watchChange"
273
+ ];
274
+ const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
275
+ "augmentChunkHash",
276
+ "outputOptions",
277
+ "renderChunk",
278
+ "renderStart",
279
+ "renderError",
280
+ "writeBundle",
281
+ "generateBundle"
282
+ ];
283
+ const ENUMERATED_PLUGIN_HOOK_NAMES = [
284
+ ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
285
+ ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
286
+ "footer",
287
+ "banner",
288
+ "intro",
289
+ "outro"
290
+ ];
291
+ /**
292
+ * Names of all defined hooks. It's like
293
+ * ```js
294
+ * const DEFINED_HOOK_NAMES ={
295
+ * options: 'options',
296
+ * buildStart: 'buildStart',
297
+ * ...
298
+ * }
299
+ * ```
300
+ */
301
+ const DEFINED_HOOK_NAMES = {
302
+ [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
303
+ [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
304
+ [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
305
+ [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
306
+ [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
307
+ [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
308
+ [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
309
+ [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
310
+ [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
311
+ [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
312
+ [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
313
+ [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
314
+ [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
315
+ [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
316
+ [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
317
+ [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
318
+ [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
319
+ [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
320
+ [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
321
+ [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
322
+ [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
323
+ [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
324
+ [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
325
+ };
319
326
 
320
327
  //#endregion
321
328
  //#region src/utils/async-flatten.ts
@@ -325,10 +332,10 @@ async function asyncFlatten(array$1) {
325
332
  while (array$1.some((v) => v?.then));
326
333
  return array$1;
327
334
  }
328
- var init_async_flatten = __esm({ "src/utils/async-flatten.ts"() {} });
329
335
 
330
336
  //#endregion
331
337
  //#region src/utils/normalize-plugin-option.ts
338
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
332
339
  function checkOutputPluginOption(plugins, onLog) {
333
340
  for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
334
341
  delete plugin[hook];
@@ -344,52 +351,66 @@ function normalizePlugins(plugins, anonymousPrefix) {
344
351
  }
345
352
  return plugins;
346
353
  }
347
- var normalizePluginOption, ANONYMOUS_PLUGIN_PREFIX, ANONYMOUS_OUTPUT_PLUGIN_PREFIX, BUILTIN_PLUGINS;
348
- var init_normalize_plugin_option = __esm({ "src/utils/normalize-plugin-option.ts"() {
349
- init_constructors();
350
- init_plugin$1();
351
- init_logging();
352
- init_logs();
353
- init_async_flatten();
354
- normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
355
- ANONYMOUS_PLUGIN_PREFIX = "at position ";
356
- ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
357
- BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
358
- } });
354
+ const ANONYMOUS_PLUGIN_PREFIX = "at position ";
355
+ const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
356
+ const BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
359
357
 
360
358
  //#endregion
361
359
  //#region src/plugin/minimal-plugin-context.ts
362
- var MinimalPluginContextImpl;
363
- var init_minimal_plugin_context = __esm({ "src/plugin/minimal-plugin-context.ts"() {
364
- init_src();
365
- init_log_handler();
366
- init_logging();
367
- init_logs();
368
- MinimalPluginContextImpl = class {
369
- info;
370
- warn;
371
- debug;
372
- meta;
373
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
374
- this.pluginName = pluginName;
375
- this.hookName = hookName;
376
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
377
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
378
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
379
- this.meta = {
380
- rollupVersion: "4.23.0",
381
- rolldownVersion: VERSION,
382
- watchMode
383
- };
384
- }
385
- error(e$1) {
386
- return error(logPluginError(normalizeLog(e$1), this.pluginName, { hook: this.hookName }));
387
- }
388
- };
389
- } });
360
+ var MinimalPluginContextImpl = class {
361
+ info;
362
+ warn;
363
+ debug;
364
+ meta;
365
+ constructor(onLog, logLevel, pluginName, watchMode, hookName) {
366
+ this.pluginName = pluginName;
367
+ this.hookName = hookName;
368
+ this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
369
+ this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
370
+ this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
371
+ this.meta = {
372
+ rollupVersion: "4.23.0",
373
+ rolldownVersion: VERSION,
374
+ watchMode
375
+ };
376
+ }
377
+ error(e$1) {
378
+ return error(logPluginError(normalizeLog(e$1), this.pluginName, { hook: this.hookName }));
379
+ }
380
+ };
390
381
 
391
382
  //#endregion
392
383
  //#region src/plugin/plugin-driver.ts
384
+ var PluginDriver = class {
385
+ static async callOptionsHook(inputOptions, watchMode = false) {
386
+ const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
387
+ const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
388
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
389
+ for (const plugin of plugins) {
390
+ const name = plugin.name || "unknown";
391
+ const options = plugin.options;
392
+ if (options) {
393
+ const { handler } = normalizeHook(options);
394
+ const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
395
+ if (result) inputOptions = result;
396
+ }
397
+ }
398
+ return inputOptions;
399
+ }
400
+ static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
401
+ const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
402
+ for (const plugin of sortedPlugins) {
403
+ const name = plugin.name || "unknown";
404
+ const options = plugin.outputOptions;
405
+ if (options) {
406
+ const { handler } = normalizeHook(options);
407
+ const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
408
+ if (result) outputOptions = result;
409
+ }
410
+ }
411
+ return outputOptions;
412
+ }
413
+ };
393
414
  function getObjectPlugins(plugins) {
394
415
  return plugins.filter((plugin) => {
395
416
  if (!plugin) return void 0;
@@ -424,48 +445,10 @@ function getSortedPlugins(hookName, plugins) {
424
445
  ...post
425
446
  ];
426
447
  }
427
- var PluginDriver;
428
- var init_plugin_driver = __esm({ "src/plugin/plugin-driver.ts"() {
429
- init_constructors();
430
- init_logger();
431
- init_logging();
432
- init_normalize_hook();
433
- init_normalize_plugin_option();
434
- init_minimal_plugin_context();
435
- PluginDriver = class {
436
- static async callOptionsHook(inputOptions, watchMode = false) {
437
- const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
438
- const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
439
- const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
440
- for (const plugin of plugins) {
441
- const name = plugin.name || "unknown";
442
- const options = plugin.options;
443
- if (options) {
444
- const { handler } = normalizeHook(options);
445
- const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
446
- if (result) inputOptions = result;
447
- }
448
- }
449
- return inputOptions;
450
- }
451
- static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
452
- const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
453
- for (const plugin of sortedPlugins) {
454
- const name = plugin.name || "unknown";
455
- const options = plugin.outputOptions;
456
- if (options) {
457
- const { handler } = normalizeHook(options);
458
- const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
459
- if (result) outputOptions = result;
460
- }
461
- }
462
- return outputOptions;
463
- }
464
- };
465
- } });
466
448
 
467
449
  //#endregion
468
450
  //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
451
+ var store$1;
469
452
  /* @__NO_SIDE_EFFECTS__ */
470
453
  function getGlobalConfig(config2) {
471
454
  return {
@@ -475,14 +458,17 @@ function getGlobalConfig(config2) {
475
458
  abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
476
459
  };
477
460
  }
461
+ var store2;
478
462
  /* @__NO_SIDE_EFFECTS__ */
479
463
  function getGlobalMessage(lang) {
480
464
  return store2?.get(lang);
481
465
  }
466
+ var store3;
482
467
  /* @__NO_SIDE_EFFECTS__ */
483
468
  function getSchemaMessage(lang) {
484
469
  return store3?.get(lang);
485
470
  }
471
+ var store4;
486
472
  /* @__NO_SIDE_EFFECTS__ */
487
473
  function getSpecificMessage(reference, lang) {
488
474
  return store4?.get(reference)?.get(lang);
@@ -540,6 +526,18 @@ function _joinExpects(values2, separator) {
540
526
  if (list.length > 1) return `(${list.join(` ${separator} `)})`;
541
527
  return list[0] ?? "never";
542
528
  }
529
+ var ValiError = class extends Error {
530
+ /**
531
+ * Creates a Valibot error with useful information.
532
+ *
533
+ * @param issues The error issues.
534
+ */
535
+ constructor(issues) {
536
+ super(issues[0].message);
537
+ this.name = "ValiError";
538
+ this.issues = issues;
539
+ }
540
+ };
543
541
  /* @__NO_SIDE_EFFECTS__ */
544
542
  function args(schema) {
545
543
  return {
@@ -1436,21 +1434,6 @@ function safeParse(schema, input, config2) {
1436
1434
  issues: dataset.issues
1437
1435
  };
1438
1436
  }
1439
- var store$1, store2, store3, store4, ValiError;
1440
- var init_dist$3 = __esm({ "../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js"() {
1441
- ValiError = class extends Error {
1442
- /**
1443
- * Creates a Valibot error with useful information.
1444
- *
1445
- * @param issues The error issues.
1446
- */
1447
- constructor(issues) {
1448
- super(issues[0].message);
1449
- this.name = "ValiError";
1450
- this.issues = issues;
1451
- }
1452
- };
1453
- } });
1454
1437
 
1455
1438
  //#endregion
1456
1439
  //#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
@@ -1668,6 +1651,7 @@ function convertAction(jsonSchema, valibotAction, config) {
1668
1651
  function flattenPipe(pipe$1) {
1669
1652
  return pipe$1.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1670
1653
  }
1654
+ let refCount = 0;
1671
1655
  /**
1672
1656
  * Converts any supported Valibot schema to the JSON Schema format.
1673
1657
  *
@@ -1851,6 +1835,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = fal
1851
1835
  if (errors) for (const message of errors) handleError(message, config);
1852
1836
  return jsonSchema;
1853
1837
  }
1838
+ let store;
1854
1839
  /**
1855
1840
  * Returns the current global schema definitions.
1856
1841
  *
@@ -1884,11 +1869,6 @@ function toJsonSchema(schema, config) {
1884
1869
  if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1885
1870
  return jsonSchema;
1886
1871
  }
1887
- var refCount, store;
1888
- var init_dist$2 = __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"() {
1889
- init_dist$3();
1890
- refCount = 0;
1891
- } });
1892
1872
 
1893
1873
  //#endregion
1894
1874
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.cjs
@@ -1997,15 +1977,376 @@ var require_ansis = __commonJS({ "../../node_modules/.pnpm/ansis@4.1.0/node_modu
1997
1977
 
1998
1978
  //#endregion
1999
1979
  //#region ../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.mjs
2000
- var import_ansis, ansis_default, Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright;
2001
- var init_ansis = __esm({ "../../node_modules/.pnpm/ansis@4.1.0/node_modules/ansis/index.mjs"() {
2002
- import_ansis = __toESM(require_ansis(), 1);
2003
- ansis_default = import_ansis.default;
2004
- ({Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright} = import_ansis.default);
2005
- } });
1980
+ var import_ansis = __toESM(require_ansis(), 1);
1981
+ var ansis_default = import_ansis.default;
1982
+ const { Ansis, fg, bg, rgb, bgRgb, hex, bgHex, reset, inverse, hidden, visible, bold, dim, italic, underline, strikethrough, black, red, green, yellow, blue, magenta, cyan, white, gray, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bgGray, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = import_ansis.default;
2006
1983
 
2007
1984
  //#endregion
2008
1985
  //#region src/utils/validator.ts
1986
+ const StringOrRegExpSchema = union([string(), instance(RegExp)]);
1987
+ const LogLevelSchema = union([
1988
+ literal("debug"),
1989
+ literal("info"),
1990
+ literal("warn")
1991
+ ]);
1992
+ const LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
1993
+ const LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
1994
+ const RollupLogSchema = any();
1995
+ const RollupLogWithStringSchema = union([RollupLogSchema, string()]);
1996
+ const InputOptionSchema = union([
1997
+ string(),
1998
+ array(string()),
1999
+ record(string(), string())
2000
+ ]);
2001
+ const ExternalSchema = union([
2002
+ StringOrRegExpSchema,
2003
+ array(StringOrRegExpSchema),
2004
+ pipe(function_(), args(tuple([
2005
+ string(),
2006
+ optional(string()),
2007
+ boolean()
2008
+ ])), returns(nullish(boolean())))
2009
+ ]);
2010
+ const ModuleTypesSchema = record(string(), union([
2011
+ literal("asset"),
2012
+ literal("base64"),
2013
+ literal("binary"),
2014
+ literal("css"),
2015
+ literal("dataurl"),
2016
+ literal("empty"),
2017
+ literal("js"),
2018
+ literal("json"),
2019
+ literal("jsx"),
2020
+ literal("text"),
2021
+ literal("ts"),
2022
+ literal("tsx")
2023
+ ]));
2024
+ const JsxOptionsSchema = strictObject({
2025
+ runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
2026
+ development: pipe(optional(boolean()), description("Development specific information")),
2027
+ throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
2028
+ importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
2029
+ pragma: pipe(optional(string()), description("Jsx element transformation")),
2030
+ pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
2031
+ refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
2032
+ });
2033
+ const RollupJsxOptionsSchema = strictObject({
2034
+ mode: optional(union([
2035
+ literal("classic"),
2036
+ literal("automatic"),
2037
+ literal("preserve")
2038
+ ])),
2039
+ factory: optional(string()),
2040
+ fragment: optional(string()),
2041
+ importSource: optional(string()),
2042
+ jsxImportSource: optional(string())
2043
+ });
2044
+ const HelperModeSchema = union([literal("Runtime"), literal("External")]);
2045
+ const DecoratorOptionSchema = object({
2046
+ legacy: optional(boolean()),
2047
+ emitDecoratorMetadata: optional(boolean())
2048
+ });
2049
+ const HelpersSchema = object({ mode: optional(HelperModeSchema) });
2050
+ const RewriteImportExtensionsSchema = union([
2051
+ literal("rewrite"),
2052
+ literal("remove"),
2053
+ boolean()
2054
+ ]);
2055
+ const TypescriptSchema = object({
2056
+ jsxPragma: optional(string()),
2057
+ jsxPragmaFrag: optional(string()),
2058
+ onlyRemoveTypeImports: optional(boolean()),
2059
+ allowNamespaces: optional(boolean()),
2060
+ allowDeclareFields: optional(boolean()),
2061
+ declaration: optional(object({
2062
+ stripInternal: optional(boolean()),
2063
+ sourcemap: optional(boolean())
2064
+ })),
2065
+ rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
2066
+ });
2067
+ const AssumptionsSchema = object({
2068
+ ignoreFunctionLength: optional(boolean()),
2069
+ noDocumentAll: optional(boolean()),
2070
+ objectRestNoSymbols: optional(boolean()),
2071
+ pureGetters: optional(boolean()),
2072
+ setPublicClassFields: optional(boolean())
2073
+ });
2074
+ const TransformOptionsSchema = object({
2075
+ assumptions: optional(AssumptionsSchema),
2076
+ typescript: optional(TypescriptSchema),
2077
+ helpers: optional(HelpersSchema),
2078
+ decorators: optional(DecoratorOptionSchema),
2079
+ jsx: optional(JsxOptionsSchema),
2080
+ target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
2081
+ });
2082
+ const WatchOptionsSchema = strictObject({
2083
+ chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
2084
+ exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2085
+ include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2086
+ notify: pipe(optional(strictObject({
2087
+ compareContents: optional(boolean()),
2088
+ pollInterval: optional(number())
2089
+ })), description("Notify options")),
2090
+ skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
2091
+ buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
2092
+ });
2093
+ const ChecksOptionsSchema = strictObject({
2094
+ circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
2095
+ eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
2096
+ missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
2097
+ missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
2098
+ mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
2099
+ unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
2100
+ unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
2101
+ filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
2102
+ commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
2103
+ importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
2104
+ configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
2105
+ });
2106
+ const MinifyOptionsSchema = strictObject({
2107
+ mangle: optional(boolean()),
2108
+ compress: optional(boolean()),
2109
+ removeWhitespace: optional(boolean())
2110
+ });
2111
+ const ResolveOptionsSchema = strictObject({
2112
+ alias: optional(record(string(), union([string(), array(string())]))),
2113
+ aliasFields: optional(array(array(string()))),
2114
+ conditionNames: optional(array(string())),
2115
+ extensionAlias: optional(record(string(), array(string()))),
2116
+ exportsFields: optional(array(array(string()))),
2117
+ extensions: optional(array(string())),
2118
+ mainFields: optional(array(string())),
2119
+ mainFiles: optional(array(string())),
2120
+ modules: optional(array(string())),
2121
+ symlinks: optional(boolean()),
2122
+ tsconfigFilename: optional(string())
2123
+ });
2124
+ const TreeshakingOptionsSchema = union([boolean(), looseObject({
2125
+ annotations: optional(boolean()),
2126
+ manualPureFunctions: optional(array(string())),
2127
+ unknownGlobalSideEffects: optional(boolean())
2128
+ })]);
2129
+ const OnLogSchema = pipe(function_(), args(tuple([
2130
+ LogLevelSchema,
2131
+ RollupLogSchema,
2132
+ pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
2133
+ ])));
2134
+ const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
2135
+ const HmrSchema = union([boolean(), strictObject({
2136
+ port: optional(number()),
2137
+ host: optional(string()),
2138
+ implement: optional(string())
2139
+ })]);
2140
+ const InputOptionsSchema = strictObject({
2141
+ input: optional(InputOptionSchema),
2142
+ plugins: optional(custom(() => true)),
2143
+ external: optional(ExternalSchema),
2144
+ makeAbsoluteExternalsRelative: optional(union([boolean(), literal("ifRelativeSource")])),
2145
+ resolve: optional(ResolveOptionsSchema),
2146
+ cwd: pipe(optional(string()), description("Current working directory")),
2147
+ platform: pipe(optional(union([
2148
+ literal("browser"),
2149
+ literal("neutral"),
2150
+ literal("node")
2151
+ ])), description(`Platform for which the code should be generated (node, ${ansis_default.underline("browser")}, neutral)`)),
2152
+ shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2153
+ treeshake: optional(TreeshakingOptionsSchema),
2154
+ logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${ansis_default.dim("silent")}, ${ansis_default.underline(ansis_default.gray("info"))}, debug, ${ansis_default.yellow("warn")})`)),
2155
+ onLog: optional(OnLogSchema),
2156
+ onwarn: optional(OnwarnSchema),
2157
+ moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
2158
+ experimental: optional(strictObject({
2159
+ disableLiveBindings: optional(boolean()),
2160
+ enableComposingJsPlugins: optional(boolean()),
2161
+ resolveNewUrlToAsset: optional(boolean()),
2162
+ strictExecutionOrder: optional(boolean()),
2163
+ hmr: optional(HmrSchema),
2164
+ attachDebugInfo: optional(union([
2165
+ literal("none"),
2166
+ literal("simple"),
2167
+ literal("full")
2168
+ ]))
2169
+ })),
2170
+ define: pipe(optional(record(string(), string())), description("Define global variables")),
2171
+ inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2172
+ profilerNames: optional(boolean()),
2173
+ jsx: optional(union([
2174
+ literal(false),
2175
+ literal("react"),
2176
+ literal("react-jsx"),
2177
+ literal("preserve"),
2178
+ RollupJsxOptionsSchema
2179
+ ])),
2180
+ transform: optional(TransformOptionsSchema),
2181
+ watch: optional(union([WatchOptionsSchema, literal(false)])),
2182
+ dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2183
+ checks: optional(ChecksOptionsSchema),
2184
+ keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2185
+ 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.")),
2186
+ preserveEntrySignatures: pipe(optional(union([
2187
+ literal("strict"),
2188
+ literal("allow-extension"),
2189
+ literal("exports-only"),
2190
+ literal(false)
2191
+ ])))
2192
+ });
2193
+ const InputCliOverrideSchema = strictObject({
2194
+ input: pipe(optional(array(string())), description("Entry file")),
2195
+ external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2196
+ inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2197
+ treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2198
+ makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
2199
+ jsx: pipe(optional(union([
2200
+ literal(false),
2201
+ literal("react"),
2202
+ literal("react-jsx"),
2203
+ literal("preserve")
2204
+ ])), description("Jsx options preset")),
2205
+ preserveEntrySignatures: pipe(optional(union([literal(false)])), description("Avoid facade chunks for entry points"))
2206
+ });
2207
+ const InputCliOptionsSchema = omit(strictObject({
2208
+ ...InputOptionsSchema.entries,
2209
+ ...InputCliOverrideSchema.entries
2210
+ }), [
2211
+ "plugins",
2212
+ "onwarn",
2213
+ "onLog",
2214
+ "resolve",
2215
+ "experimental",
2216
+ "profilerNames",
2217
+ "watch"
2218
+ ]);
2219
+ const ModuleFormatSchema = union([
2220
+ literal("es"),
2221
+ literal("cjs"),
2222
+ literal("esm"),
2223
+ literal("module"),
2224
+ literal("commonjs"),
2225
+ literal("iife"),
2226
+ literal("umd")
2227
+ ]);
2228
+ const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2229
+ const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2230
+ const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2231
+ const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2232
+ const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2233
+ const AdvancedChunksSchema = strictObject({
2234
+ minSize: optional(number()),
2235
+ maxSize: optional(number()),
2236
+ minModuleSize: optional(number()),
2237
+ maxModuleSize: optional(number()),
2238
+ minShareCount: optional(number()),
2239
+ groups: optional(array(strictObject({
2240
+ name: string(),
2241
+ test: optional(union([
2242
+ string(),
2243
+ instance(RegExp),
2244
+ pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2245
+ ])),
2246
+ priority: optional(number()),
2247
+ minSize: optional(number()),
2248
+ minShareCount: optional(number()),
2249
+ maxSize: optional(number()),
2250
+ minModuleSize: optional(number()),
2251
+ maxModuleSize: optional(number())
2252
+ })))
2253
+ });
2254
+ const OutputOptionsSchema = strictObject({
2255
+ dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2256
+ file: pipe(optional(string()), description("Single output file")),
2257
+ exports: pipe(optional(union([
2258
+ literal("auto"),
2259
+ literal("named"),
2260
+ literal("default"),
2261
+ literal("none")
2262
+ ])), description(`Specify a export mode (${ansis_default.underline("auto")}, named, default, none)`)),
2263
+ hashCharacters: pipe(optional(union([
2264
+ literal("base64"),
2265
+ literal("base36"),
2266
+ literal("hex")
2267
+ ])), description("Use the specified character set for file hashes")),
2268
+ format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${ansis_default.underline("esm")}, cjs, and iife)`)),
2269
+ sourcemap: pipe(optional(union([
2270
+ boolean(),
2271
+ literal("inline"),
2272
+ literal("hidden")
2273
+ ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${ansis_default.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2274
+ sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2275
+ sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2276
+ sourcemapPathTransform: optional(custom(() => true)),
2277
+ banner: optional(union([string(), AddonFunctionSchema])),
2278
+ footer: optional(union([string(), AddonFunctionSchema])),
2279
+ intro: optional(union([string(), AddonFunctionSchema])),
2280
+ outro: optional(union([string(), AddonFunctionSchema])),
2281
+ extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2282
+ esModule: optional(union([boolean(), literal("if-default-prop")])),
2283
+ assetFileNames: optional(AssetFileNamesSchema),
2284
+ entryFileNames: optional(ChunkFileNamesSchema),
2285
+ chunkFileNames: optional(ChunkFileNamesSchema),
2286
+ cssEntryFileNames: optional(ChunkFileNamesSchema),
2287
+ cssChunkFileNames: optional(ChunkFileNamesSchema),
2288
+ sanitizeFileName: optional(SanitizeFileNameSchema),
2289
+ minify: pipe(optional(union([
2290
+ boolean(),
2291
+ string("dce-only"),
2292
+ MinifyOptionsSchema
2293
+ ])), description("Minify the bundled file")),
2294
+ name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2295
+ globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2296
+ externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2297
+ inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2298
+ manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2299
+ advancedChunks: optional(AdvancedChunksSchema),
2300
+ legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2301
+ plugins: optional(custom(() => true)),
2302
+ polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2303
+ hoistTransitiveImports: optional(custom((input) => {
2304
+ if (input) return false;
2305
+ return true;
2306
+ }, () => `The 'true' value is not supported`)),
2307
+ preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2308
+ preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2309
+ virtualDirname: optional(string())
2310
+ });
2311
+ const getAddonDescription = (placement, wrapper) => {
2312
+ return `Code to insert the ${ansis_default.bold(placement)} of the bundled file (${ansis_default.bold(wrapper)} the wrapper function)`;
2313
+ };
2314
+ const OutputCliOverrideSchema = strictObject({
2315
+ assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2316
+ entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2317
+ chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2318
+ cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2319
+ cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2320
+ sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2321
+ banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2322
+ footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2323
+ intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2324
+ outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2325
+ esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2326
+ globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2327
+ advancedChunks: pipe(optional(strictObject({
2328
+ minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2329
+ minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2330
+ })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2331
+ minify: pipe(optional(boolean()), description("Minify the bundled file"))
2332
+ });
2333
+ const OutputCliOptionsSchema = omit(strictObject({
2334
+ ...OutputOptionsSchema.entries,
2335
+ ...OutputCliOverrideSchema.entries
2336
+ }), [
2337
+ "sourcemapIgnoreList",
2338
+ "sourcemapPathTransform",
2339
+ "plugins",
2340
+ "hoistTransitiveImports"
2341
+ ]);
2342
+ const CliOptionsSchema = strictObject({
2343
+ config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2344
+ help: pipe(optional(boolean()), description("Show help")),
2345
+ version: pipe(optional(boolean()), description("Show version number")),
2346
+ watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2347
+ ...InputCliOptionsSchema.entries,
2348
+ ...OutputCliOptionsSchema.entries
2349
+ });
2009
2350
  function validateCliOptions(options) {
2010
2351
  let parsed = safeParse(CliOptionsSchema, options);
2011
2352
  return [parsed.output, parsed.issues?.map((issue) => {
@@ -2013,6 +2354,8 @@ function validateCliOptions(options) {
2013
2354
  return `Invalid value for option ${option}: ${issue.message}`;
2014
2355
  })];
2015
2356
  }
2357
+ const inputHelperMsgRecord = { output: { ignored: true } };
2358
+ const outputHelperMsgRecord = {};
2016
2359
  function validateOption(key, options) {
2017
2360
  if (globalThis.process?.env?.ROLLUP_TEST) return;
2018
2361
  let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
@@ -2044,410 +2387,38 @@ function getOutputCliKeys() {
2044
2387
  function getJsonSchema() {
2045
2388
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2046
2389
  }
2047
- 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;
2048
- var init_validator = __esm({ "src/utils/validator.ts"() {
2049
- init_dist$2();
2050
- init_ansis();
2051
- init_dist$3();
2052
- StringOrRegExpSchema = union([string(), instance(RegExp)]);
2053
- LogLevelSchema = union([
2054
- literal("debug"),
2055
- literal("info"),
2056
- literal("warn")
2057
- ]);
2058
- LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
2059
- LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
2060
- RollupLogSchema = any();
2061
- RollupLogWithStringSchema = union([RollupLogSchema, string()]);
2062
- InputOptionSchema = union([
2063
- string(),
2064
- array(string()),
2065
- record(string(), string())
2066
- ]);
2067
- ExternalSchema = union([
2068
- StringOrRegExpSchema,
2069
- array(StringOrRegExpSchema),
2070
- pipe(function_(), args(tuple([
2071
- string(),
2072
- optional(string()),
2073
- boolean()
2074
- ])), returns(nullish(boolean())))
2075
- ]);
2076
- ModuleTypesSchema = record(string(), union([
2077
- literal("asset"),
2078
- literal("base64"),
2079
- literal("binary"),
2080
- literal("css"),
2081
- literal("dataurl"),
2082
- literal("empty"),
2083
- literal("js"),
2084
- literal("json"),
2085
- literal("jsx"),
2086
- literal("text"),
2087
- literal("ts"),
2088
- literal("tsx")
2089
- ]));
2090
- JsxOptionsSchema = strictObject({
2091
- runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
2092
- development: pipe(optional(boolean()), description("Development specific information")),
2093
- throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
2094
- importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
2095
- pragma: pipe(optional(string()), description("Jsx element transformation")),
2096
- pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
2097
- refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
2098
- });
2099
- RollupJsxOptionsSchema = strictObject({
2100
- mode: optional(union([
2101
- literal("classic"),
2102
- literal("automatic"),
2103
- literal("preserve")
2104
- ])),
2105
- factory: optional(string()),
2106
- fragment: optional(string()),
2107
- importSource: optional(string()),
2108
- jsxImportSource: optional(string())
2109
- });
2110
- HelperModeSchema = union([literal("Runtime"), literal("External")]);
2111
- DecoratorOptionSchema = object({
2112
- legacy: optional(boolean()),
2113
- emitDecoratorMetadata: optional(boolean())
2114
- });
2115
- HelpersSchema = object({ mode: optional(HelperModeSchema) });
2116
- RewriteImportExtensionsSchema = union([
2117
- literal("rewrite"),
2118
- literal("remove"),
2119
- boolean()
2120
- ]);
2121
- TypescriptSchema = object({
2122
- jsxPragma: optional(string()),
2123
- jsxPragmaFrag: optional(string()),
2124
- onlyRemoveTypeImports: optional(boolean()),
2125
- allowNamespaces: optional(boolean()),
2126
- allowDeclareFields: optional(boolean()),
2127
- declaration: optional(object({
2128
- stripInternal: optional(boolean()),
2129
- sourcemap: optional(boolean())
2130
- })),
2131
- rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
2132
- });
2133
- AssumptionsSchema = object({
2134
- ignoreFunctionLength: optional(boolean()),
2135
- noDocumentAll: optional(boolean()),
2136
- objectRestNoSymbols: optional(boolean()),
2137
- pureGetters: optional(boolean()),
2138
- setPublicClassFields: optional(boolean())
2139
- });
2140
- TransformOptionsSchema = object({
2141
- assumptions: optional(AssumptionsSchema),
2142
- typescript: optional(TypescriptSchema),
2143
- helpers: optional(HelpersSchema),
2144
- decorators: optional(DecoratorOptionSchema),
2145
- jsx: optional(JsxOptionsSchema),
2146
- target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
2147
- });
2148
- WatchOptionsSchema = strictObject({
2149
- chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
2150
- exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2151
- include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2152
- notify: pipe(optional(strictObject({
2153
- compareContents: optional(boolean()),
2154
- pollInterval: optional(number())
2155
- })), description("Notify options")),
2156
- skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
2157
- buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
2158
- });
2159
- ChecksOptionsSchema = strictObject({
2160
- circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
2161
- eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
2162
- missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
2163
- missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
2164
- mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
2165
- unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
2166
- unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
2167
- filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
2168
- commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
2169
- importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
2170
- configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
2171
- });
2172
- MinifyOptionsSchema = strictObject({
2173
- mangle: optional(boolean()),
2174
- compress: optional(boolean()),
2175
- removeWhitespace: optional(boolean())
2176
- });
2177
- ResolveOptionsSchema = strictObject({
2178
- alias: optional(record(string(), union([string(), array(string())]))),
2179
- aliasFields: optional(array(array(string()))),
2180
- conditionNames: optional(array(string())),
2181
- extensionAlias: optional(record(string(), array(string()))),
2182
- exportsFields: optional(array(array(string()))),
2183
- extensions: optional(array(string())),
2184
- mainFields: optional(array(string())),
2185
- mainFiles: optional(array(string())),
2186
- modules: optional(array(string())),
2187
- symlinks: optional(boolean()),
2188
- tsconfigFilename: optional(string())
2189
- });
2190
- TreeshakingOptionsSchema = union([boolean(), looseObject({
2191
- annotations: optional(boolean()),
2192
- manualPureFunctions: optional(array(string())),
2193
- unknownGlobalSideEffects: optional(boolean())
2194
- })]);
2195
- OnLogSchema = pipe(function_(), args(tuple([
2196
- LogLevelSchema,
2197
- RollupLogSchema,
2198
- pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
2199
- ])));
2200
- OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
2201
- HmrSchema = union([boolean(), strictObject({
2202
- port: optional(number()),
2203
- host: optional(string()),
2204
- implement: optional(string())
2205
- })]);
2206
- InputOptionsSchema = strictObject({
2207
- input: optional(InputOptionSchema),
2208
- plugins: optional(custom(() => true)),
2209
- external: optional(ExternalSchema),
2210
- makeAbsoluteExternalsRelative: optional(union([boolean(), literal("ifRelativeSource")])),
2211
- resolve: optional(ResolveOptionsSchema),
2212
- cwd: pipe(optional(string()), description("Current working directory")),
2213
- platform: pipe(optional(union([
2214
- literal("browser"),
2215
- literal("neutral"),
2216
- literal("node")
2217
- ])), description(`Platform for which the code should be generated (node, ${ansis_default.underline("browser")}, neutral)`)),
2218
- shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2219
- treeshake: optional(TreeshakingOptionsSchema),
2220
- logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${ansis_default.dim("silent")}, ${ansis_default.underline(ansis_default.gray("info"))}, debug, ${ansis_default.yellow("warn")})`)),
2221
- onLog: optional(OnLogSchema),
2222
- onwarn: optional(OnwarnSchema),
2223
- moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
2224
- experimental: optional(strictObject({
2225
- disableLiveBindings: optional(boolean()),
2226
- enableComposingJsPlugins: optional(boolean()),
2227
- resolveNewUrlToAsset: optional(boolean()),
2228
- strictExecutionOrder: optional(boolean()),
2229
- hmr: optional(HmrSchema),
2230
- attachDebugInfo: optional(union([
2231
- literal("none"),
2232
- literal("simple"),
2233
- literal("full")
2234
- ]))
2235
- })),
2236
- define: pipe(optional(record(string(), string())), description("Define global variables")),
2237
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2238
- profilerNames: optional(boolean()),
2239
- jsx: optional(union([
2240
- literal(false),
2241
- literal("react"),
2242
- literal("react-jsx"),
2243
- literal("preserve"),
2244
- RollupJsxOptionsSchema
2245
- ])),
2246
- transform: optional(TransformOptionsSchema),
2247
- watch: optional(union([WatchOptionsSchema, literal(false)])),
2248
- dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2249
- checks: optional(ChecksOptionsSchema),
2250
- keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2251
- 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.")),
2252
- preserveEntrySignatures: pipe(optional(union([
2253
- literal("strict"),
2254
- literal("allow-extension"),
2255
- literal("exports-only"),
2256
- literal(false)
2257
- ])))
2258
- });
2259
- InputCliOverrideSchema = strictObject({
2260
- input: pipe(optional(array(string())), description("Entry file")),
2261
- external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2262
- inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2263
- treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2264
- makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
2265
- jsx: pipe(optional(union([
2266
- literal(false),
2267
- literal("react"),
2268
- literal("react-jsx"),
2269
- literal("preserve")
2270
- ])), description("Jsx options preset")),
2271
- preserveEntrySignatures: pipe(optional(union([literal(false)])), description("Avoid facade chunks for entry points"))
2272
- });
2273
- InputCliOptionsSchema = omit(strictObject({
2274
- ...InputOptionsSchema.entries,
2275
- ...InputCliOverrideSchema.entries
2276
- }), [
2277
- "plugins",
2278
- "onwarn",
2279
- "onLog",
2280
- "resolve",
2281
- "experimental",
2282
- "profilerNames",
2283
- "watch"
2284
- ]);
2285
- ModuleFormatSchema = union([
2286
- literal("es"),
2287
- literal("cjs"),
2288
- literal("esm"),
2289
- literal("module"),
2290
- literal("commonjs"),
2291
- literal("iife"),
2292
- literal("umd")
2293
- ]);
2294
- AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2295
- ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2296
- AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2297
- SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2298
- GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2299
- AdvancedChunksSchema = strictObject({
2300
- minSize: optional(number()),
2301
- maxSize: optional(number()),
2302
- minModuleSize: optional(number()),
2303
- maxModuleSize: optional(number()),
2304
- minShareCount: optional(number()),
2305
- groups: optional(array(strictObject({
2306
- name: string(),
2307
- test: optional(union([
2308
- string(),
2309
- instance(RegExp),
2310
- pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2311
- ])),
2312
- priority: optional(number()),
2313
- minSize: optional(number()),
2314
- minShareCount: optional(number()),
2315
- maxSize: optional(number()),
2316
- minModuleSize: optional(number()),
2317
- maxModuleSize: optional(number())
2318
- })))
2319
- });
2320
- OutputOptionsSchema = strictObject({
2321
- dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2322
- file: pipe(optional(string()), description("Single output file")),
2323
- exports: pipe(optional(union([
2324
- literal("auto"),
2325
- literal("named"),
2326
- literal("default"),
2327
- literal("none")
2328
- ])), description(`Specify a export mode (${ansis_default.underline("auto")}, named, default, none)`)),
2329
- hashCharacters: pipe(optional(union([
2330
- literal("base64"),
2331
- literal("base36"),
2332
- literal("hex")
2333
- ])), description("Use the specified character set for file hashes")),
2334
- format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${ansis_default.underline("esm")}, cjs, and iife)`)),
2335
- sourcemap: pipe(optional(union([
2336
- boolean(),
2337
- literal("inline"),
2338
- literal("hidden")
2339
- ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${ansis_default.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2340
- sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2341
- sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2342
- sourcemapPathTransform: optional(custom(() => true)),
2343
- banner: optional(union([string(), AddonFunctionSchema])),
2344
- footer: optional(union([string(), AddonFunctionSchema])),
2345
- intro: optional(union([string(), AddonFunctionSchema])),
2346
- outro: optional(union([string(), AddonFunctionSchema])),
2347
- extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2348
- esModule: optional(union([boolean(), literal("if-default-prop")])),
2349
- assetFileNames: optional(AssetFileNamesSchema),
2350
- entryFileNames: optional(ChunkFileNamesSchema),
2351
- chunkFileNames: optional(ChunkFileNamesSchema),
2352
- cssEntryFileNames: optional(ChunkFileNamesSchema),
2353
- cssChunkFileNames: optional(ChunkFileNamesSchema),
2354
- sanitizeFileName: optional(SanitizeFileNameSchema),
2355
- minify: pipe(optional(union([
2356
- boolean(),
2357
- string("dce-only"),
2358
- MinifyOptionsSchema
2359
- ])), description("Minify the bundled file")),
2360
- name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2361
- globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2362
- externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2363
- inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2364
- manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2365
- advancedChunks: optional(AdvancedChunksSchema),
2366
- legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2367
- plugins: optional(custom(() => true)),
2368
- polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2369
- hoistTransitiveImports: optional(custom((input) => {
2370
- if (input) return false;
2371
- return true;
2372
- }, () => `The 'true' value is not supported`)),
2373
- preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2374
- preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2375
- virtualDirname: optional(string())
2376
- });
2377
- getAddonDescription = (placement, wrapper) => {
2378
- return `Code to insert the ${ansis_default.bold(placement)} of the bundled file (${ansis_default.bold(wrapper)} the wrapper function)`;
2379
- };
2380
- OutputCliOverrideSchema = strictObject({
2381
- assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2382
- entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2383
- chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2384
- cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2385
- cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2386
- sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2387
- banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2388
- footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2389
- intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2390
- outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2391
- esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2392
- globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2393
- advancedChunks: pipe(optional(strictObject({
2394
- minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2395
- minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2396
- })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2397
- minify: pipe(optional(boolean()), description("Minify the bundled file"))
2398
- });
2399
- OutputCliOptionsSchema = omit(strictObject({
2400
- ...OutputOptionsSchema.entries,
2401
- ...OutputCliOverrideSchema.entries
2402
- }), [
2403
- "sourcemapIgnoreList",
2404
- "sourcemapPathTransform",
2405
- "plugins",
2406
- "hoistTransitiveImports"
2407
- ]);
2408
- CliOptionsSchema = strictObject({
2409
- config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2410
- help: pipe(optional(boolean()), description("Show help")),
2411
- version: pipe(optional(boolean()), description("Show version number")),
2412
- watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2413
- ...InputCliOptionsSchema.entries,
2414
- ...OutputCliOptionsSchema.entries
2415
- });
2416
- inputHelperMsgRecord = { output: { ignored: true } };
2417
- outputHelperMsgRecord = {};
2418
- } });
2419
2390
 
2420
2391
  //#endregion
2421
2392
  //#region src/constants/plugin-context.ts
2422
- var SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF;
2423
- var init_plugin_context$1 = __esm({ "src/constants/plugin-context.ts"() {
2424
- SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2425
- } });
2393
+ /**
2394
+ * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2395
+ * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2396
+ * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2397
+ * internally.
2398
+ */
2399
+ const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2426
2400
 
2427
2401
  //#endregion
2428
2402
  //#region src/options/normalized-input-options.ts
2429
- var NormalizedInputOptionsImpl;
2430
- var init_normalized_input_options = __esm({ "src/options/normalized-input-options.ts"() {
2431
- NormalizedInputOptionsImpl = class {
2432
- inner;
2433
- constructor(inner, onLog) {
2434
- this.onLog = onLog;
2435
- this.inner = inner;
2436
- }
2437
- get shimMissingExports() {
2438
- return this.inner.shimMissingExports;
2439
- }
2440
- get input() {
2441
- return this.inner.input;
2442
- }
2443
- get cwd() {
2444
- return this.inner.cwd ?? void 0;
2445
- }
2446
- get platform() {
2447
- return this.inner.platform;
2448
- }
2449
- };
2450
- } });
2403
+ var NormalizedInputOptionsImpl = class {
2404
+ inner;
2405
+ constructor(inner, onLog) {
2406
+ this.onLog = onLog;
2407
+ this.inner = inner;
2408
+ }
2409
+ get shimMissingExports() {
2410
+ return this.inner.shimMissingExports;
2411
+ }
2412
+ get input() {
2413
+ return this.inner.input;
2414
+ }
2415
+ get cwd() {
2416
+ return this.inner.cwd ?? void 0;
2417
+ }
2418
+ get platform() {
2419
+ return this.inner.platform;
2420
+ }
2421
+ };
2451
2422
 
2452
2423
  //#endregion
2453
2424
  //#region src/types/sourcemap.ts
@@ -2464,7 +2435,6 @@ function bindingifySourcemap(map) {
2464
2435
  debugId: "debugId" in map ? map.debugId : void 0
2465
2436
  } };
2466
2437
  }
2467
- var init_sourcemap = __esm({ "src/types/sourcemap.ts"() {} });
2468
2438
 
2469
2439
  //#endregion
2470
2440
  //#region src/utils/error.ts
@@ -2515,7 +2485,6 @@ function getErrorMessage(e$1) {
2515
2485
  function joinNewLine(s1, s2) {
2516
2486
  return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
2517
2487
  }
2518
- var init_error = __esm({ "src/utils/error.ts"() {} });
2519
2488
 
2520
2489
  //#endregion
2521
2490
  //#region src/utils/transform-module-info.ts
@@ -2537,9 +2506,6 @@ function transformModuleInfo(info, option) {
2537
2506
  ...option
2538
2507
  };
2539
2508
  }
2540
- var init_transform_module_info = __esm({ "src/utils/transform-module-info.ts"() {
2541
- init_misc();
2542
- } });
2543
2509
 
2544
2510
  //#endregion
2545
2511
  //#region src/utils/transform-side-effects.ts
@@ -2553,7 +2519,6 @@ function bindingifySideEffects(sideEffects) {
2553
2519
  default: throw new Error(`Unexpected side effects: ${sideEffects}`);
2554
2520
  }
2555
2521
  }
2556
- var init_transform_side_effects = __esm({ "src/utils/transform-side-effects.ts"() {} });
2557
2522
 
2558
2523
  //#endregion
2559
2524
  //#region src/utils/transform-sourcemap.ts
@@ -2569,7 +2534,6 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2569
2534
  if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id$1) map.sources = [id$1];
2570
2535
  return map;
2571
2536
  }
2572
- var init_transform_sourcemap = __esm({ "src/utils/transform-sourcemap.ts"() {} });
2573
2537
 
2574
2538
  //#endregion
2575
2539
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
@@ -2580,7 +2544,6 @@ function u$1(o$1, n$1, a$2) {
2580
2544
  lazyArgs: n$1
2581
2545
  });
2582
2546
  }
2583
- var init_chunk_D6FCK2GA = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-D6FCK2GA.js"() {} });
2584
2547
 
2585
2548
  //#endregion
2586
2549
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-WIMGWYZL.js
@@ -2590,40 +2553,23 @@ function u(r$1, n$1, o$1) {
2590
2553
  if (a$2 === 1) return u$1(r$1, n$1, o$1);
2591
2554
  throw new Error("Wrong number of arguments");
2592
2555
  }
2593
- var init_chunk_WIMGWYZL = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-WIMGWYZL.js"() {
2594
- init_chunk_D6FCK2GA();
2595
- } });
2596
2556
 
2597
2557
  //#endregion
2598
2558
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-3IFJP4R5.js
2599
2559
  function d(...r$1) {
2600
2560
  return u(i, r$1);
2601
2561
  }
2602
- var i;
2603
- var init_chunk_3IFJP4R5 = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-3IFJP4R5.js"() {
2604
- init_chunk_WIMGWYZL();
2605
- i = (r$1, t$2) => {
2606
- let a$2 = [[], []];
2607
- for (let [o$1, e$1] of r$1.entries()) t$2(e$1, o$1, r$1) ? a$2[0].push(e$1) : a$2[1].push(e$1);
2608
- return a$2;
2609
- };
2610
- } });
2562
+ var i = (r$1, t$2) => {
2563
+ let a$2 = [[], []];
2564
+ for (let [o$1, e$1] of r$1.entries()) t$2(e$1, o$1, r$1) ? a$2[0].push(e$1) : a$2[1].push(e$1);
2565
+ return a$2;
2566
+ };
2611
2567
 
2612
2568
  //#endregion
2613
2569
  //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js
2614
2570
  function t(...n$1) {
2615
2571
  return u(Object.keys, n$1);
2616
2572
  }
2617
- var init_chunk_5NQBDF4H = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-5NQBDF4H.js"() {
2618
- init_chunk_WIMGWYZL();
2619
- } });
2620
-
2621
- //#endregion
2622
- //#region ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/index.js
2623
- var init_dist$1 = __esm({ "../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/index.js"() {
2624
- init_chunk_3IFJP4R5();
2625
- init_chunk_5NQBDF4H();
2626
- } });
2627
2573
 
2628
2574
  //#endregion
2629
2575
  //#region src/plugin/bindingify-hook-filter.ts
@@ -2765,11 +2711,6 @@ function bindingifyRenderChunkFilter(filterOption) {
2765
2711
  if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
2766
2712
  return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
2767
2713
  }
2768
- var init_bindingify_hook_filter = __esm({ "src/plugin/bindingify-hook-filter.ts"() {
2769
- init_dist();
2770
- init_dist$1();
2771
- init_misc();
2772
- } });
2773
2714
 
2774
2715
  //#endregion
2775
2716
  //#region src/plugin/bindingify-plugin-hook-meta.ts
@@ -2785,7 +2726,6 @@ function bindingPluginOrder(order) {
2785
2726
  default: throw new Error(`Unknown plugin order: ${order}`);
2786
2727
  }
2787
2728
  }
2788
- var init_bindingify_plugin_hook_meta = __esm({ "src/plugin/bindingify-plugin-hook-meta.ts"() {} });
2789
2729
 
2790
2730
  //#endregion
2791
2731
  //#region src/utils/asset-source.ts
@@ -2795,150 +2735,132 @@ function transformAssetSource(bindingAssetSource$1) {
2795
2735
  function bindingAssetSource(source) {
2796
2736
  return { inner: source };
2797
2737
  }
2798
- var init_asset_source = __esm({ "src/utils/asset-source.ts"() {} });
2799
2738
 
2800
2739
  //#endregion
2801
2740
  //#region src/plugin/plugin-context.ts
2802
- var PluginContextImpl;
2803
- var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
2804
- init_logging();
2805
- init_logs();
2806
- init_parse_ast_index();
2807
- init_minimal_plugin_context();
2808
- init_asset_source();
2809
- init_bindingify_input_options();
2810
- init_misc();
2811
- init_transform_side_effects();
2812
- PluginContextImpl = class extends MinimalPluginContextImpl {
2813
- getModuleInfo;
2814
- constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2815
- super(onLog, logLevel, plugin.name, watchMode);
2816
- this.outputOptions = outputOptions;
2817
- this.context = context;
2818
- this.data = data;
2819
- this.onLog = onLog;
2820
- this.currentLoadingModule = currentLoadingModule;
2821
- this.getModuleInfo = (id$1) => this.data.getModuleInfo(id$1, context);
2822
- }
2823
- async load(options) {
2824
- const id$1 = options.id;
2825
- if (id$1 === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2826
- const moduleInfo = this.data.getModuleInfo(id$1, this.context);
2827
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2828
- const rawOptions = {
2829
- meta: options.meta || {},
2830
- moduleSideEffects: options.moduleSideEffects || null,
2831
- invalidate: false
2832
- };
2833
- this.data.updateModuleOption(id$1, rawOptions);
2834
- async function createLoadModulePromise(context, data) {
2835
- const loadPromise = data.loadModulePromiseMap.get(id$1);
2836
- if (loadPromise) return loadPromise;
2837
- const promise$1 = new Promise((resolve, _) => {
2838
- data.loadModulePromiseResolveFnMap.set(id$1, resolve);
2839
- });
2840
- data.loadModulePromiseMap.set(id$1, promise$1);
2841
- try {
2842
- await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
2843
- } catch (e$1) {
2844
- data.loadModulePromiseMap.delete(id$1);
2845
- data.loadModulePromiseResolveFnMap.delete(id$1);
2846
- throw e$1;
2847
- }
2848
- return promise$1;
2849
- }
2850
- await createLoadModulePromise(this.context, this.data);
2851
- return this.data.getModuleInfo(id$1, this.context);
2852
- }
2853
- async resolve(source, importer, options) {
2854
- let receipt = void 0;
2855
- if (options != null) receipt = this.data.saveResolveOptions(options);
2856
- const res = await this.context.resolve(source, importer, {
2857
- custom: receipt,
2858
- skipSelf: options?.skipSelf
2859
- });
2860
- if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2861
- if (res == null) return null;
2862
- const info = this.data.getModuleOption(res.id) || {};
2863
- return {
2864
- ...res,
2865
- external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2866
- ...info
2867
- };
2868
- }
2869
- emitFile = (file) => {
2870
- if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2871
- if (file.type === "chunk") return this.context.emitChunk({
2872
- preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
2873
- ...file
2874
- });
2875
- const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2876
- const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2877
- return this.context.emitFile({
2878
- ...file,
2879
- originalFileName: file.originalFileName || void 0,
2880
- source: bindingAssetSource(file.source)
2881
- }, filename, fnSanitizedFileName);
2741
+ var PluginContextImpl = class extends MinimalPluginContextImpl {
2742
+ getModuleInfo;
2743
+ constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2744
+ super(onLog, logLevel, plugin.name, watchMode);
2745
+ this.outputOptions = outputOptions;
2746
+ this.context = context;
2747
+ this.data = data;
2748
+ this.onLog = onLog;
2749
+ this.currentLoadingModule = currentLoadingModule;
2750
+ this.getModuleInfo = (id$1) => this.data.getModuleInfo(id$1, context);
2751
+ }
2752
+ async load(options) {
2753
+ const id$1 = options.id;
2754
+ if (id$1 === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2755
+ const moduleInfo = this.data.getModuleInfo(id$1, this.context);
2756
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2757
+ const rawOptions = {
2758
+ meta: options.meta || {},
2759
+ moduleSideEffects: options.moduleSideEffects || null,
2760
+ invalidate: false
2882
2761
  };
2883
- getAssetFileNames(file) {
2884
- if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2885
- names: file.name ? [file.name] : [],
2886
- originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2887
- source: file.source,
2888
- type: "asset"
2762
+ this.data.updateModuleOption(id$1, rawOptions);
2763
+ async function createLoadModulePromise(context, data) {
2764
+ const loadPromise = data.loadModulePromiseMap.get(id$1);
2765
+ if (loadPromise) return loadPromise;
2766
+ const promise$1 = new Promise((resolve, _) => {
2767
+ data.loadModulePromiseResolveFnMap.set(id$1, resolve);
2889
2768
  });
2769
+ data.loadModulePromiseMap.set(id$1, promise$1);
2770
+ try {
2771
+ await context.load(id$1, bindingifySideEffects(options.moduleSideEffects));
2772
+ } catch (e$1) {
2773
+ data.loadModulePromiseMap.delete(id$1);
2774
+ data.loadModulePromiseResolveFnMap.delete(id$1);
2775
+ throw e$1;
2776
+ }
2777
+ return promise$1;
2890
2778
  }
2891
- getFileName(referenceId) {
2892
- return this.context.getFileName(referenceId);
2893
- }
2894
- getModuleIds() {
2895
- return this.data.getModuleIds(this.context);
2896
- }
2897
- addWatchFile(id$1) {
2898
- this.context.addWatchFile(id$1);
2899
- }
2900
- parse(input, options) {
2901
- return parseAst(input, options);
2902
- }
2779
+ await createLoadModulePromise(this.context, this.data);
2780
+ return this.data.getModuleInfo(id$1, this.context);
2781
+ }
2782
+ async resolve(source, importer, options) {
2783
+ let receipt = void 0;
2784
+ if (options != null) receipt = this.data.saveResolveOptions(options);
2785
+ const res = await this.context.resolve(source, importer, {
2786
+ custom: receipt,
2787
+ skipSelf: options?.skipSelf
2788
+ });
2789
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2790
+ if (res == null) return null;
2791
+ const info = this.data.getModuleOption(res.id) || {};
2792
+ return {
2793
+ ...res,
2794
+ external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2795
+ ...info
2796
+ };
2797
+ }
2798
+ emitFile = (file) => {
2799
+ if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2800
+ if (file.type === "chunk") return this.context.emitChunk({
2801
+ preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
2802
+ ...file
2803
+ });
2804
+ const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2805
+ const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2806
+ return this.context.emitFile({
2807
+ ...file,
2808
+ originalFileName: file.originalFileName || void 0,
2809
+ source: bindingAssetSource(file.source)
2810
+ }, filename, fnSanitizedFileName);
2903
2811
  };
2904
- } });
2812
+ getAssetFileNames(file) {
2813
+ if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2814
+ names: file.name ? [file.name] : [],
2815
+ originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2816
+ source: file.source,
2817
+ type: "asset"
2818
+ });
2819
+ }
2820
+ getFileName(referenceId) {
2821
+ return this.context.getFileName(referenceId);
2822
+ }
2823
+ getModuleIds() {
2824
+ return this.data.getModuleIds(this.context);
2825
+ }
2826
+ addWatchFile(id$1) {
2827
+ this.context.addWatchFile(id$1);
2828
+ }
2829
+ parse(input, options) {
2830
+ return parseAst(input, options);
2831
+ }
2832
+ };
2905
2833
 
2906
2834
  //#endregion
2907
2835
  //#region src/plugin/transform-plugin-context.ts
2908
- var TransformPluginContextImpl;
2909
- var init_transform_plugin_context = __esm({ "src/plugin/transform-plugin-context.ts"() {
2910
- init_log_handler();
2911
- init_logs();
2912
- init_plugin_context();
2913
- TransformPluginContextImpl = class extends PluginContextImpl {
2914
- constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2915
- super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2916
- this.inner = inner;
2917
- this.moduleId = moduleId;
2918
- this.moduleSource = moduleSource;
2919
- const getLogHandler$1 = (handler) => (log, pos) => {
2920
- log = normalizeLog(log);
2921
- if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2922
- log.id = moduleId;
2923
- log.hook = "transform";
2924
- handler(log);
2925
- };
2926
- this.debug = getLogHandler$1(this.debug);
2927
- this.warn = getLogHandler$1(this.warn);
2928
- this.info = getLogHandler$1(this.info);
2929
- }
2930
- error(e$1, pos) {
2931
- if (typeof e$1 === "string") e$1 = { message: e$1 };
2932
- if (pos) augmentCodeLocation(e$1, pos, this.moduleSource, this.moduleId);
2933
- e$1.id = this.moduleId;
2934
- e$1.hook = "transform";
2935
- return error(logPluginError(normalizeLog(e$1), this.pluginName));
2936
- }
2937
- getCombinedSourcemap() {
2938
- return JSON.parse(this.inner.getCombinedSourcemap());
2939
- }
2940
- };
2941
- } });
2836
+ var TransformPluginContextImpl = class extends PluginContextImpl {
2837
+ constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2838
+ super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2839
+ this.inner = inner;
2840
+ this.moduleId = moduleId;
2841
+ this.moduleSource = moduleSource;
2842
+ const getLogHandler$1 = (handler) => (log, pos) => {
2843
+ log = normalizeLog(log);
2844
+ if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2845
+ log.id = moduleId;
2846
+ log.hook = "transform";
2847
+ handler(log);
2848
+ };
2849
+ this.debug = getLogHandler$1(this.debug);
2850
+ this.warn = getLogHandler$1(this.warn);
2851
+ this.info = getLogHandler$1(this.info);
2852
+ }
2853
+ error(e$1, pos) {
2854
+ if (typeof e$1 === "string") e$1 = { message: e$1 };
2855
+ if (pos) augmentCodeLocation(e$1, pos, this.moduleSource, this.moduleId);
2856
+ e$1.id = this.moduleId;
2857
+ e$1.hook = "transform";
2858
+ return error(logPluginError(normalizeLog(e$1), this.pluginName));
2859
+ }
2860
+ getCombinedSourcemap() {
2861
+ return JSON.parse(this.inner.getCombinedSourcemap());
2862
+ }
2863
+ };
2942
2864
 
2943
2865
  //#endregion
2944
2866
  //#region src/plugin/bindingify-build-hooks.ts
@@ -3103,20 +3025,6 @@ function bindingifyModuleParsed(args$1) {
3103
3025
  meta: bindingifyPluginHookMeta(meta)
3104
3026
  };
3105
3027
  }
3106
- var init_bindingify_build_hooks = __esm({ "src/plugin/bindingify-build-hooks.ts"() {
3107
- init_normalize_hook();
3108
- init_plugin_context$1();
3109
- init_normalized_input_options();
3110
- init_sourcemap();
3111
- init_error();
3112
- init_transform_module_info();
3113
- init_transform_side_effects();
3114
- init_transform_sourcemap();
3115
- init_bindingify_hook_filter();
3116
- init_bindingify_plugin_hook_meta();
3117
- init_plugin_context();
3118
- init_transform_plugin_context();
3119
- } });
3120
3028
 
3121
3029
  //#endregion
3122
3030
  //#region src/utils/transform-rendered-module.ts
@@ -3133,7 +3041,6 @@ function transformToRenderedModule(bindingRenderedModule) {
3133
3041
  }
3134
3042
  };
3135
3043
  }
3136
- var init_transform_rendered_module = __esm({ "src/utils/transform-rendered-module.ts"() {} });
3137
3044
 
3138
3045
  //#endregion
3139
3046
  //#region src/utils/transform-rendered-chunk.ts
@@ -3183,9 +3090,6 @@ function transformChunkModules(modules) {
3183
3090
  }
3184
3091
  return result;
3185
3092
  }
3186
- var init_transform_rendered_chunk = __esm({ "src/utils/transform-rendered-chunk.ts"() {
3187
- init_transform_rendered_module();
3188
- } });
3189
3093
 
3190
3094
  //#endregion
3191
3095
  //#region src/utils/bindingify-output-options.ts
@@ -3270,125 +3174,116 @@ function bindingifyAssetFilenames(assetFileNames) {
3270
3174
  };
3271
3175
  return assetFileNames;
3272
3176
  }
3273
- var init_bindingify_output_options = __esm({ "src/utils/bindingify-output-options.ts"() {
3274
- init_asset_source();
3275
- init_misc();
3276
- init_transform_rendered_chunk();
3277
- } });
3278
3177
 
3279
3178
  //#endregion
3280
3179
  //#region src/options/normalized-output-options.ts
3180
+ var NormalizedOutputOptionsImpl = class {
3181
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3182
+ this.inner = inner;
3183
+ this.outputOptions = outputOptions;
3184
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3185
+ }
3186
+ get dir() {
3187
+ return this.inner.dir ?? void 0;
3188
+ }
3189
+ get entryFileNames() {
3190
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3191
+ }
3192
+ get chunkFileNames() {
3193
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3194
+ }
3195
+ get assetFileNames() {
3196
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3197
+ }
3198
+ get format() {
3199
+ return this.inner.format;
3200
+ }
3201
+ get exports() {
3202
+ return this.inner.exports;
3203
+ }
3204
+ get sourcemap() {
3205
+ return this.inner.sourcemap;
3206
+ }
3207
+ get cssEntryFileNames() {
3208
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3209
+ }
3210
+ get cssChunkFileNames() {
3211
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3212
+ }
3213
+ get shimMissingExports() {
3214
+ return this.inner.shimMissingExports;
3215
+ }
3216
+ get name() {
3217
+ return this.inner.name ?? void 0;
3218
+ }
3219
+ get file() {
3220
+ return this.inner.file ?? void 0;
3221
+ }
3222
+ get inlineDynamicImports() {
3223
+ return this.inner.inlineDynamicImports;
3224
+ }
3225
+ get externalLiveBindings() {
3226
+ return this.inner.externalLiveBindings;
3227
+ }
3228
+ get banner() {
3229
+ return normalizeAddon(this.outputOptions.banner);
3230
+ }
3231
+ get footer() {
3232
+ return normalizeAddon(this.outputOptions.footer);
3233
+ }
3234
+ get intro() {
3235
+ return normalizeAddon(this.outputOptions.intro);
3236
+ }
3237
+ get outro() {
3238
+ return normalizeAddon(this.outputOptions.outro);
3239
+ }
3240
+ get esModule() {
3241
+ return this.inner.esModule;
3242
+ }
3243
+ get extend() {
3244
+ return this.inner.extend;
3245
+ }
3246
+ get globals() {
3247
+ return this.inner.globals || this.outputOptions.globals;
3248
+ }
3249
+ get hashCharacters() {
3250
+ return this.inner.hashCharacters;
3251
+ }
3252
+ get sourcemapDebugIds() {
3253
+ return this.inner.sourcemapDebugIds;
3254
+ }
3255
+ get sourcemapIgnoreList() {
3256
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3257
+ }
3258
+ get sourcemapPathTransform() {
3259
+ return this.outputOptions.sourcemapPathTransform;
3260
+ }
3261
+ get minify() {
3262
+ return this.inner.minify;
3263
+ }
3264
+ get legalComments() {
3265
+ return this.inner.legalComments;
3266
+ }
3267
+ get polyfillRequire() {
3268
+ return this.inner.polyfillRequire;
3269
+ }
3270
+ get plugins() {
3271
+ return this.normalizedOutputPlugins;
3272
+ }
3273
+ get preserveModules() {
3274
+ return this.inner.preserveModules;
3275
+ }
3276
+ get preserveModulesRoot() {
3277
+ return this.inner.preserveModulesRoot;
3278
+ }
3279
+ get virtualDirname() {
3280
+ return this.inner.virtualDirname;
3281
+ }
3282
+ };
3281
3283
  function normalizeAddon(value) {
3282
3284
  if (typeof value === "function") return value;
3283
3285
  return () => value || "";
3284
3286
  }
3285
- var NormalizedOutputOptionsImpl;
3286
- var init_normalized_output_options = __esm({ "src/options/normalized-output-options.ts"() {
3287
- init_bindingify_output_options();
3288
- NormalizedOutputOptionsImpl = class {
3289
- constructor(inner, outputOptions, normalizedOutputPlugins) {
3290
- this.inner = inner;
3291
- this.outputOptions = outputOptions;
3292
- this.normalizedOutputPlugins = normalizedOutputPlugins;
3293
- }
3294
- get dir() {
3295
- return this.inner.dir ?? void 0;
3296
- }
3297
- get entryFileNames() {
3298
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3299
- }
3300
- get chunkFileNames() {
3301
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3302
- }
3303
- get assetFileNames() {
3304
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3305
- }
3306
- get format() {
3307
- return this.inner.format;
3308
- }
3309
- get exports() {
3310
- return this.inner.exports;
3311
- }
3312
- get sourcemap() {
3313
- return this.inner.sourcemap;
3314
- }
3315
- get cssEntryFileNames() {
3316
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3317
- }
3318
- get cssChunkFileNames() {
3319
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3320
- }
3321
- get shimMissingExports() {
3322
- return this.inner.shimMissingExports;
3323
- }
3324
- get name() {
3325
- return this.inner.name ?? void 0;
3326
- }
3327
- get file() {
3328
- return this.inner.file ?? void 0;
3329
- }
3330
- get inlineDynamicImports() {
3331
- return this.inner.inlineDynamicImports;
3332
- }
3333
- get externalLiveBindings() {
3334
- return this.inner.externalLiveBindings;
3335
- }
3336
- get banner() {
3337
- return normalizeAddon(this.outputOptions.banner);
3338
- }
3339
- get footer() {
3340
- return normalizeAddon(this.outputOptions.footer);
3341
- }
3342
- get intro() {
3343
- return normalizeAddon(this.outputOptions.intro);
3344
- }
3345
- get outro() {
3346
- return normalizeAddon(this.outputOptions.outro);
3347
- }
3348
- get esModule() {
3349
- return this.inner.esModule;
3350
- }
3351
- get extend() {
3352
- return this.inner.extend;
3353
- }
3354
- get globals() {
3355
- return this.inner.globals || this.outputOptions.globals;
3356
- }
3357
- get hashCharacters() {
3358
- return this.inner.hashCharacters;
3359
- }
3360
- get sourcemapDebugIds() {
3361
- return this.inner.sourcemapDebugIds;
3362
- }
3363
- get sourcemapIgnoreList() {
3364
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3365
- }
3366
- get sourcemapPathTransform() {
3367
- return this.outputOptions.sourcemapPathTransform;
3368
- }
3369
- get minify() {
3370
- return this.inner.minify;
3371
- }
3372
- get legalComments() {
3373
- return this.inner.legalComments;
3374
- }
3375
- get polyfillRequire() {
3376
- return this.inner.polyfillRequire;
3377
- }
3378
- get plugins() {
3379
- return this.normalizedOutputPlugins;
3380
- }
3381
- get preserveModules() {
3382
- return this.inner.preserveModules;
3383
- }
3384
- get preserveModulesRoot() {
3385
- return this.inner.preserveModulesRoot;
3386
- }
3387
- get virtualDirname() {
3388
- return this.inner.virtualDirname;
3389
- }
3390
- };
3391
- } });
3392
3287
 
3393
3288
  //#endregion
3394
3289
  //#region src/utils/transform-to-rollup-output.ts
@@ -3546,12 +3441,6 @@ function collectChangedBundle(changed, bundle) {
3546
3441
  deleted: Array.from(changed.deleted)
3547
3442
  };
3548
3443
  }
3549
- var init_transform_to_rollup_output = __esm({ "src/utils/transform-to-rollup-output.ts"() {
3550
- init_sourcemap();
3551
- init_asset_source();
3552
- init_error();
3553
- init_transform_rendered_chunk();
3554
- } });
3555
3444
 
3556
3445
  //#endregion
3557
3446
  //#region src/plugin/bindingify-output-hooks.ts
@@ -3703,18 +3592,6 @@ function bindingifyOutro(args$1) {
3703
3592
  meta: bindingifyPluginHookMeta(meta)
3704
3593
  };
3705
3594
  }
3706
- var init_bindingify_output_hooks = __esm({ "src/plugin/bindingify-output-hooks.ts"() {
3707
- init_normalized_input_options();
3708
- init_normalized_output_options();
3709
- init_sourcemap();
3710
- init_error();
3711
- init_normalize_hook();
3712
- init_transform_rendered_chunk();
3713
- init_transform_to_rollup_output();
3714
- init_bindingify_hook_filter();
3715
- init_bindingify_plugin_hook_meta();
3716
- init_plugin_context();
3717
- } });
3718
3595
 
3719
3596
  //#endregion
3720
3597
  //#region src/plugin/bindingify-watch-hooks.ts
@@ -3740,14 +3617,43 @@ function bindingifyCloseWatcher(args$1) {
3740
3617
  meta: bindingifyPluginHookMeta(meta)
3741
3618
  };
3742
3619
  }
3743
- var init_bindingify_watch_hooks = __esm({ "src/plugin/bindingify-watch-hooks.ts"() {
3744
- init_normalize_hook();
3745
- init_bindingify_plugin_hook_meta();
3746
- init_plugin_context();
3747
- } });
3748
3620
 
3749
3621
  //#endregion
3750
3622
  //#region src/plugin/generated/hook-usage.ts
3623
+ let HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3624
+ HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3625
+ HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3626
+ HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3627
+ HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3628
+ HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3629
+ HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3630
+ HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3631
+ HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3632
+ HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3633
+ HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3634
+ HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3635
+ HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3636
+ HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3637
+ HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3638
+ HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3639
+ HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3640
+ HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3641
+ HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3642
+ HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3643
+ HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3644
+ HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3645
+ return HookUsageKind$1;
3646
+ }({});
3647
+ var HookUsage = class {
3648
+ bitflag = BigInt(0);
3649
+ constructor() {}
3650
+ union(kind) {
3651
+ this.bitflag |= BigInt(kind);
3652
+ }
3653
+ inner() {
3654
+ return Number(this.bitflag);
3655
+ }
3656
+ };
3751
3657
  function extractHookUsage(plugin) {
3752
3658
  let hookUsage = new HookUsage();
3753
3659
  if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
@@ -3772,43 +3678,6 @@ function extractHookUsage(plugin) {
3772
3678
  if (plugin.outro) hookUsage.union(HookUsageKind.outro);
3773
3679
  return hookUsage;
3774
3680
  }
3775
- var HookUsageKind, HookUsage;
3776
- var init_hook_usage = __esm({ "src/plugin/generated/hook-usage.ts"() {
3777
- HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3778
- HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3779
- HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3780
- HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3781
- HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3782
- HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3783
- HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3784
- HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3785
- HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3786
- HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3787
- HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3788
- HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3789
- HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3790
- HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3791
- HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3792
- HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3793
- HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3794
- HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3795
- HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3796
- HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3797
- HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3798
- HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3799
- return HookUsageKind$1;
3800
- }({});
3801
- HookUsage = class {
3802
- bitflag = BigInt(0);
3803
- constructor() {}
3804
- union(kind) {
3805
- this.bitflag |= BigInt(kind);
3806
- }
3807
- inner() {
3808
- return Number(this.bitflag);
3809
- }
3810
- };
3811
- } });
3812
3681
 
3813
3682
  //#endregion
3814
3683
  //#region src/plugin/bindingify-plugin.ts
@@ -3931,106 +3800,95 @@ function wrapHandlers(plugin) {
3931
3800
  }
3932
3801
  return plugin;
3933
3802
  }
3934
- var init_bindingify_plugin = __esm({ "src/plugin/bindingify-plugin.ts"() {
3935
- init_bindingify_build_hooks();
3936
- init_bindingify_output_hooks();
3937
- init_logs();
3938
- init_bindingify_watch_hooks();
3939
- init_hook_usage();
3940
- } });
3941
3803
 
3942
3804
  //#endregion
3943
3805
  //#region src/plugin/plugin-context-data.ts
3944
- var PluginContextData;
3945
- var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
3946
- init_transform_module_info();
3947
- PluginContextData = class {
3948
- moduleOptionMap = /* @__PURE__ */ new Map();
3949
- resolveOptionsMap = /* @__PURE__ */ new Map();
3950
- loadModulePromiseMap = /* @__PURE__ */ new Map();
3951
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3952
- renderedChunkMeta = null;
3953
- updateModuleOption(id$1, option) {
3954
- const existing = this.moduleOptionMap.get(id$1);
3955
- if (existing) {
3956
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3957
- if (option.meta != null) Object.assign(existing.meta, option.meta);
3958
- if (option.invalidate != null) existing.invalidate = option.invalidate;
3959
- } else {
3960
- this.moduleOptionMap.set(id$1, option);
3961
- return option;
3962
- }
3963
- return existing;
3964
- }
3965
- getModuleOption(id$1) {
3966
- const option = this.moduleOptionMap.get(id$1);
3967
- if (!option) {
3968
- const raw = {
3969
- moduleSideEffects: null,
3970
- meta: {}
3971
- };
3972
- this.moduleOptionMap.set(id$1, raw);
3973
- return raw;
3974
- }
3806
+ var PluginContextData = class {
3807
+ moduleOptionMap = /* @__PURE__ */ new Map();
3808
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3809
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3810
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3811
+ renderedChunkMeta = null;
3812
+ updateModuleOption(id$1, option) {
3813
+ const existing = this.moduleOptionMap.get(id$1);
3814
+ if (existing) {
3815
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3816
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3817
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3818
+ } else {
3819
+ this.moduleOptionMap.set(id$1, option);
3975
3820
  return option;
3976
3821
  }
3977
- getModuleInfo(id$1, context) {
3978
- const bindingInfo = context.getModuleInfo(id$1);
3979
- if (bindingInfo) {
3980
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id$1));
3981
- return this.proxyModuleInfo(id$1, info);
3982
- }
3983
- return null;
3984
- }
3985
- proxyModuleInfo(id$1, info) {
3986
- let moduleSideEffects = info.moduleSideEffects;
3987
- Object.defineProperty(info, "moduleSideEffects", {
3988
- get() {
3989
- return moduleSideEffects;
3990
- },
3991
- set: (v) => {
3992
- this.updateModuleOption(id$1, {
3993
- moduleSideEffects: v,
3994
- meta: info.meta,
3995
- invalidate: true
3996
- });
3997
- moduleSideEffects = v;
3998
- }
3999
- });
4000
- return info;
4001
- }
4002
- getModuleIds(context) {
4003
- const moduleIds = context.getModuleIds();
4004
- return moduleIds.values();
4005
- }
4006
- saveResolveOptions(options) {
4007
- const index = this.resolveOptionsMap.size;
4008
- this.resolveOptionsMap.set(index, options);
4009
- return index;
4010
- }
4011
- getSavedResolveOptions(receipt) {
4012
- return this.resolveOptionsMap.get(receipt);
4013
- }
4014
- removeSavedResolveOptions(receipt) {
4015
- this.resolveOptionsMap.delete(receipt);
4016
- }
4017
- setRenderChunkMeta(meta) {
4018
- this.renderedChunkMeta = meta;
4019
- }
4020
- getRenderChunkMeta() {
4021
- return this.renderedChunkMeta;
4022
- }
4023
- markModuleLoaded(id$1, _success) {
4024
- const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
4025
- if (resolve) resolve();
3822
+ return existing;
3823
+ }
3824
+ getModuleOption(id$1) {
3825
+ const option = this.moduleOptionMap.get(id$1);
3826
+ if (!option) {
3827
+ const raw = {
3828
+ moduleSideEffects: null,
3829
+ meta: {}
3830
+ };
3831
+ this.moduleOptionMap.set(id$1, raw);
3832
+ return raw;
4026
3833
  }
4027
- clear() {
4028
- this.renderedChunkMeta = null;
4029
- this.loadModulePromiseMap.clear();
4030
- this.loadModulePromiseResolveFnMap.clear();
3834
+ return option;
3835
+ }
3836
+ getModuleInfo(id$1, context) {
3837
+ const bindingInfo = context.getModuleInfo(id$1);
3838
+ if (bindingInfo) {
3839
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id$1));
3840
+ return this.proxyModuleInfo(id$1, info);
4031
3841
  }
4032
- };
4033
- } });
3842
+ return null;
3843
+ }
3844
+ proxyModuleInfo(id$1, info) {
3845
+ let moduleSideEffects = info.moduleSideEffects;
3846
+ Object.defineProperty(info, "moduleSideEffects", {
3847
+ get() {
3848
+ return moduleSideEffects;
3849
+ },
3850
+ set: (v) => {
3851
+ this.updateModuleOption(id$1, {
3852
+ moduleSideEffects: v,
3853
+ meta: info.meta,
3854
+ invalidate: true
3855
+ });
3856
+ moduleSideEffects = v;
3857
+ }
3858
+ });
3859
+ return info;
3860
+ }
3861
+ getModuleIds(context) {
3862
+ const moduleIds = context.getModuleIds();
3863
+ return moduleIds.values();
3864
+ }
3865
+ saveResolveOptions(options) {
3866
+ const index = this.resolveOptionsMap.size;
3867
+ this.resolveOptionsMap.set(index, options);
3868
+ return index;
3869
+ }
3870
+ getSavedResolveOptions(receipt) {
3871
+ return this.resolveOptionsMap.get(receipt);
3872
+ }
3873
+ removeSavedResolveOptions(receipt) {
3874
+ this.resolveOptionsMap.delete(receipt);
3875
+ }
3876
+ setRenderChunkMeta(meta) {
3877
+ this.renderedChunkMeta = meta;
3878
+ }
3879
+ getRenderChunkMeta() {
3880
+ return this.renderedChunkMeta;
3881
+ }
3882
+ markModuleLoaded(id$1, _success) {
3883
+ const resolve = this.loadModulePromiseResolveFnMap.get(id$1);
3884
+ if (resolve) resolve();
3885
+ }
3886
+ clear() {
3887
+ this.renderedChunkMeta = null;
3888
+ this.loadModulePromiseMap.clear();
3889
+ this.loadModulePromiseResolveFnMap.clear();
3890
+ }
3891
+ };
4034
3892
 
4035
3893
  //#endregion
4036
3894
  //#region src/utils/normalize-string-or-regex.ts
@@ -4042,7 +3900,6 @@ function normalizedStringOrRegex(pattern) {
4042
3900
  function isReadonlyArray(input) {
4043
3901
  return Array.isArray(input);
4044
3902
  }
4045
- var init_normalize_string_or_regex = __esm({ "src/utils/normalize-string-or-regex.ts"() {} });
4046
3903
 
4047
3904
  //#endregion
4048
3905
  //#region src/utils/bindingify-input-options.ts
@@ -4253,31 +4110,31 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
4253
4110
  field0: preserveEntrySignatures
4254
4111
  };
4255
4112
  }
4256
- var init_bindingify_input_options = __esm({ "src/utils/bindingify-input-options.ts"() {
4257
- init_constructors();
4258
- init_utils();
4259
- init_bindingify_plugin();
4260
- init_plugin_context_data();
4261
- init_misc();
4262
- init_normalize_string_or_regex();
4263
- init_transform_side_effects();
4264
- } });
4265
4113
 
4266
4114
  //#endregion
4267
4115
  //#region src/utils/plugin/index.ts
4268
- var isPluginHookName;
4269
- var init_plugin = __esm({ "src/utils/plugin/index.ts"() {
4270
- init_plugin$1();
4271
- isPluginHookName = function() {
4272
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4273
- return function isPluginHookName$1(hookName) {
4274
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
4275
- };
4276
- }();
4277
- } });
4116
+ const isPluginHookName = function() {
4117
+ const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4118
+ return function isPluginHookName$1(hookName) {
4119
+ return PLUGIN_HOOK_NAMES_SET.has(hookName);
4120
+ };
4121
+ }();
4278
4122
 
4279
4123
  //#endregion
4280
4124
  //#region src/utils/compose-js-plugins.ts
4125
+ const unsupportedHookName = [
4126
+ "augmentChunkHash",
4127
+ "generateBundle",
4128
+ "moduleParsed",
4129
+ "onLog",
4130
+ "options",
4131
+ "outputOptions",
4132
+ "renderError",
4133
+ "renderStart",
4134
+ "resolveDynamicImport",
4135
+ "writeBundle"
4136
+ ];
4137
+ const unsupportedHooks = new Set(unsupportedHookName);
4281
4138
  function isUnsupportedHooks(hookName) {
4282
4139
  return unsupportedHooks.has(hookName);
4283
4140
  }
@@ -4570,28 +4427,6 @@ function composeJsPlugins(plugins) {
4570
4427
  }
4571
4428
  return newPlugins;
4572
4429
  }
4573
- var unsupportedHookName, unsupportedHooks;
4574
- var init_compose_js_plugins = __esm({ "src/utils/compose-js-plugins.ts"() {
4575
- init_dist$1();
4576
- init_constructors();
4577
- init_plugin_context$1();
4578
- init_misc();
4579
- init_normalize_hook();
4580
- init_plugin();
4581
- unsupportedHookName = [
4582
- "augmentChunkHash",
4583
- "generateBundle",
4584
- "moduleParsed",
4585
- "onLog",
4586
- "options",
4587
- "outputOptions",
4588
- "renderError",
4589
- "renderStart",
4590
- "resolveDynamicImport",
4591
- "writeBundle"
4592
- ];
4593
- unsupportedHooks = new Set(unsupportedHookName);
4594
- } });
4595
4430
 
4596
4431
  //#endregion
4597
4432
  //#region src/utils/initialize-parallel-plugins.ts
@@ -4644,19 +4479,16 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
4644
4479
  throw e$1;
4645
4480
  }
4646
4481
  }
4647
- var availableParallelism;
4648
- var init_initialize_parallel_plugins = __esm({ "src/utils/initialize-parallel-plugins.ts"() {
4649
- availableParallelism = () => {
4650
- let availableParallelism$1 = 1;
4651
- try {
4652
- availableParallelism$1 = os.availableParallelism();
4653
- } catch {
4654
- const cpus = os.cpus();
4655
- if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4656
- }
4657
- return Math.min(availableParallelism$1, 8);
4658
- };
4659
- } });
4482
+ const availableParallelism = () => {
4483
+ let availableParallelism$1 = 1;
4484
+ try {
4485
+ availableParallelism$1 = os.availableParallelism();
4486
+ } catch {
4487
+ const cpus = os.cpus();
4488
+ if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4489
+ }
4490
+ return Math.min(availableParallelism$1, 8);
4491
+ };
4660
4492
 
4661
4493
  //#endregion
4662
4494
  //#region src/utils/create-bundler-option.ts
@@ -4692,25 +4524,16 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4692
4524
  throw e$1;
4693
4525
  }
4694
4526
  }
4695
- var init_create_bundler_option = __esm({ "src/utils/create-bundler-option.ts"() {
4696
- init_logger();
4697
- init_logging();
4698
- init_plugin_driver();
4699
- init_bindingify_input_options();
4700
- init_bindingify_output_options();
4701
- init_compose_js_plugins();
4702
- init_initialize_parallel_plugins();
4703
- init_normalize_plugin_option();
4704
- } });
4705
4527
 
4706
4528
  //#endregion
4707
4529
  //#region src/utils/create-bundler.ts
4708
- async function createBundler(inputOptions, outputOptions, isClose) {
4530
+ let asyncRuntimeShutdown = false;
4531
+ async function createBundlerImpl(bundler, inputOptions, outputOptions, isClose) {
4709
4532
  const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
4710
4533
  if (asyncRuntimeShutdown) startAsyncRuntime();
4711
4534
  try {
4712
4535
  return {
4713
- bundler: new Bundler(option.bundlerOptions),
4536
+ impl: bundler.createImpl(option.bundlerOptions),
4714
4537
  stopWorkers: option.stopWorkers,
4715
4538
  shutdown: () => {
4716
4539
  shutdownAsyncRuntime();
@@ -4722,11 +4545,6 @@ async function createBundler(inputOptions, outputOptions, isClose) {
4722
4545
  throw e$1;
4723
4546
  }
4724
4547
  }
4725
- var asyncRuntimeShutdown;
4726
- var init_create_bundler = __esm({ "src/utils/create-bundler.ts"() {
4727
- init_create_bundler_option();
4728
- asyncRuntimeShutdown = false;
4729
- } });
4730
4548
 
4731
4549
  //#endregion
4732
4550
  //#region src/utils/transform-hmr-patch-output.ts
@@ -4739,80 +4557,66 @@ function handleHmrPatchOutputErrors(output) {
4739
4557
  const rawErrors = output.errors;
4740
4558
  if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
4741
4559
  }
4742
- var init_transform_hmr_patch_output = __esm({ "src/utils/transform-hmr-patch-output.ts"() {
4743
- init_error();
4744
- } });
4745
4560
 
4746
4561
  //#endregion
4747
4562
  //#region src/api/rolldown/rolldown-build.ts
4748
- var RolldownBuild;
4749
- var init_rolldown_build = __esm({ "src/api/rolldown/rolldown-build.ts"() {
4750
- init_create_bundler();
4751
- init_transform_to_rollup_output();
4752
- init_transform_hmr_patch_output();
4753
- init_validator();
4754
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4755
- RolldownBuild = class {
4756
- #inputOptions;
4757
- #bundler;
4758
- constructor(inputOptions) {
4759
- this.#inputOptions = inputOptions;
4760
- }
4761
- get closed() {
4762
- return this.#bundler?.bundler.closed ?? false;
4763
- }
4764
- async #getBundlerWithStopWorker(outputOptions, isClose) {
4765
- if (this.#bundler) await this.#bundler.stopWorkers?.();
4766
- return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
4767
- }
4768
- async generate(outputOptions = {}) {
4769
- validateOption("output", outputOptions);
4770
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4771
- const output = await bundler.generate();
4772
- return transformToRollupOutput(output);
4773
- }
4774
- async write(outputOptions = {}) {
4775
- validateOption("output", outputOptions);
4776
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4777
- const output = await bundler.write();
4778
- return transformToRollupOutput(output);
4779
- }
4780
- async close() {
4781
- const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4782
- await stopWorkers?.();
4783
- await bundler.close();
4784
- shutdown();
4785
- }
4786
- async [Symbol.asyncDispose]() {
4787
- await this.close();
4788
- }
4789
- async generateHmrPatch(changedFiles) {
4790
- const output = await this.#bundler.bundler.generateHmrPatch(changedFiles);
4791
- return transformHmrPatchOutput(output);
4792
- }
4793
- async hmrInvalidate(file, firstInvalidatedBy) {
4794
- const output = await this.#bundler.bundler.hmrInvalidate(file, firstInvalidatedBy);
4795
- return transformHmrPatchOutput(output);
4796
- }
4797
- get watchFiles() {
4798
- return this.#bundler?.bundler.getWatchFiles() ?? Promise.resolve([]);
4799
- }
4800
- };
4801
- } });
4563
+ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4564
+ var RolldownBuild = class {
4565
+ #inputOptions;
4566
+ #bundler;
4567
+ #bundlerImpl;
4568
+ constructor(inputOptions) {
4569
+ this.#inputOptions = inputOptions;
4570
+ this.#bundler = new BindingBundler();
4571
+ }
4572
+ get closed() {
4573
+ return this.#bundlerImpl?.impl.closed ?? false;
4574
+ }
4575
+ async #getBundlerWithStopWorker(outputOptions, isClose) {
4576
+ if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4577
+ return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions, isClose);
4578
+ }
4579
+ async generate(outputOptions = {}) {
4580
+ validateOption("output", outputOptions);
4581
+ const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4582
+ const output = await impl.generate();
4583
+ return transformToRollupOutput(output);
4584
+ }
4585
+ async write(outputOptions = {}) {
4586
+ validateOption("output", outputOptions);
4587
+ const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4588
+ const output = await impl.write();
4589
+ return transformToRollupOutput(output);
4590
+ }
4591
+ async close() {
4592
+ const { impl, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4593
+ await stopWorkers?.();
4594
+ await impl.close();
4595
+ shutdown();
4596
+ }
4597
+ async [Symbol.asyncDispose]() {
4598
+ await this.close();
4599
+ }
4600
+ async generateHmrPatch(changedFiles) {
4601
+ const output = await this.#bundlerImpl.impl.generateHmrPatch(changedFiles);
4602
+ return transformHmrPatchOutput(output);
4603
+ }
4604
+ async hmrInvalidate(file, firstInvalidatedBy) {
4605
+ const output = await this.#bundlerImpl.impl.hmrInvalidate(file, firstInvalidatedBy);
4606
+ return transformHmrPatchOutput(output);
4607
+ }
4608
+ get watchFiles() {
4609
+ return this.#bundlerImpl?.impl.getWatchFiles() ?? Promise.resolve([]);
4610
+ }
4611
+ };
4802
4612
 
4803
4613
  //#endregion
4804
4614
  //#region src/api/rolldown/index.ts
4805
- var rolldown;
4806
- var init_rolldown = __esm({ "src/api/rolldown/index.ts"() {
4807
- init_plugin_driver();
4808
- init_validator();
4809
- init_rolldown_build();
4810
- rolldown = async (input) => {
4811
- validateOption("input", input);
4812
- const inputOptions = await PluginDriver.callOptionsHook(input);
4813
- return new RolldownBuild(inputOptions);
4814
- };
4815
- } });
4615
+ const rolldown = async (input) => {
4616
+ validateOption("input", input);
4617
+ const inputOptions = await PluginDriver.callOptionsHook(input);
4618
+ return new RolldownBuild(inputOptions);
4619
+ };
4816
4620
 
4817
4621
  //#endregion
4818
4622
  //#region src/api/build.ts
@@ -4829,86 +4633,106 @@ async function build(options) {
4829
4633
  }
4830
4634
  }
4831
4635
  }
4832
- var init_build = __esm({ "src/api/build.ts"() {
4833
- init_rolldown();
4834
- } });
4835
4636
 
4836
4637
  //#endregion
4837
4638
  //#region src/api/watch/watch-emitter.ts
4838
- var WatcherEmitter;
4839
- var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
4840
- init_error();
4841
- WatcherEmitter = class {
4842
- listeners = /* @__PURE__ */ new Map();
4843
- timer;
4844
- constructor() {
4845
- this.timer = setInterval(() => {}, 1e9);
4846
- }
4847
- on(event, listener) {
4848
- const listeners = this.listeners.get(event);
4849
- if (listeners) listeners.push(listener);
4850
- else this.listeners.set(event, [listener]);
4851
- return this;
4852
- }
4853
- off(event, listener) {
4854
- const listeners = this.listeners.get(event);
4855
- if (listeners) {
4856
- const index = listeners.indexOf(listener);
4857
- if (index !== -1) listeners.splice(index, 1);
4858
- }
4859
- return this;
4639
+ var WatcherEmitter = class {
4640
+ listeners = /* @__PURE__ */ new Map();
4641
+ timer;
4642
+ constructor() {
4643
+ this.timer = setInterval(() => {}, 1e9);
4644
+ }
4645
+ on(event, listener) {
4646
+ const listeners = this.listeners.get(event);
4647
+ if (listeners) listeners.push(listener);
4648
+ else this.listeners.set(event, [listener]);
4649
+ return this;
4650
+ }
4651
+ off(event, listener) {
4652
+ const listeners = this.listeners.get(event);
4653
+ if (listeners) {
4654
+ const index = listeners.indexOf(listener);
4655
+ if (index !== -1) listeners.splice(index, 1);
4860
4656
  }
4861
- async onEvent(event) {
4862
- const listeners = this.listeners.get(event.eventKind());
4863
- if (listeners) switch (event.eventKind()) {
4864
- case "close":
4865
- case "restart":
4866
- for (const listener of listeners) await listener();
4867
- break;
4868
- case "event":
4869
- for (const listener of listeners) {
4870
- const code$1 = event.bundleEventKind();
4871
- switch (code$1) {
4872
- case "BUNDLE_END":
4873
- const { duration, output, result } = event.bundleEndData();
4874
- await listener({
4875
- code: "BUNDLE_END",
4876
- duration,
4877
- output: [output],
4878
- result
4879
- });
4880
- break;
4881
- case "ERROR":
4882
- const data = event.bundleErrorData();
4883
- await listener({
4884
- code: "ERROR",
4885
- error: normalizeErrors(data.error),
4886
- result: data.result
4887
- });
4888
- break;
4889
- default:
4890
- await listener({ code: code$1 });
4891
- break;
4892
- }
4893
- }
4894
- break;
4895
- case "change":
4896
- for (const listener of listeners) {
4897
- const { path: path$1, kind } = event.watchChangeData();
4898
- await listener(path$1, { event: kind });
4657
+ return this;
4658
+ }
4659
+ async onEvent(event) {
4660
+ const listeners = this.listeners.get(event.eventKind());
4661
+ if (listeners) switch (event.eventKind()) {
4662
+ case "close":
4663
+ case "restart":
4664
+ for (const listener of listeners) await listener();
4665
+ break;
4666
+ case "event":
4667
+ for (const listener of listeners) {
4668
+ const code$1 = event.bundleEventKind();
4669
+ switch (code$1) {
4670
+ case "BUNDLE_END":
4671
+ const { duration, output, result } = event.bundleEndData();
4672
+ await listener({
4673
+ code: "BUNDLE_END",
4674
+ duration,
4675
+ output: [output],
4676
+ result
4677
+ });
4678
+ break;
4679
+ case "ERROR":
4680
+ const data = event.bundleErrorData();
4681
+ await listener({
4682
+ code: "ERROR",
4683
+ error: normalizeErrors(data.error),
4684
+ result: data.result
4685
+ });
4686
+ break;
4687
+ default:
4688
+ await listener({ code: code$1 });
4689
+ break;
4899
4690
  }
4900
- break;
4901
- default: throw new Error(`Unknown event: ${event}`);
4902
- }
4903
- }
4904
- async close() {
4905
- clearInterval(this.timer);
4691
+ }
4692
+ break;
4693
+ case "change":
4694
+ for (const listener of listeners) {
4695
+ const { path: path$1, kind } = event.watchChangeData();
4696
+ await listener(path$1, { event: kind });
4697
+ }
4698
+ break;
4699
+ default: throw new Error(`Unknown event: ${event}`);
4906
4700
  }
4907
- };
4908
- } });
4701
+ }
4702
+ async close() {
4703
+ clearInterval(this.timer);
4704
+ }
4705
+ };
4909
4706
 
4910
4707
  //#endregion
4911
4708
  //#region src/api/watch/watcher.ts
4709
+ var Watcher = class {
4710
+ closed;
4711
+ inner;
4712
+ emitter;
4713
+ stopWorkers;
4714
+ constructor(emitter, inner, stopWorkers) {
4715
+ this.closed = false;
4716
+ this.inner = inner;
4717
+ this.emitter = emitter;
4718
+ const originClose = emitter.close.bind(emitter);
4719
+ emitter.close = async () => {
4720
+ await this.close();
4721
+ originClose();
4722
+ };
4723
+ this.stopWorkers = stopWorkers;
4724
+ }
4725
+ async close() {
4726
+ if (this.closed) return;
4727
+ this.closed = true;
4728
+ for (const stop of this.stopWorkers) await stop?.();
4729
+ await this.inner.close();
4730
+ shutdownAsyncRuntime();
4731
+ }
4732
+ start() {
4733
+ process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4734
+ }
4735
+ };
4912
4736
  async function createWatcher(emitter, input) {
4913
4737
  const options = arraify(input);
4914
4738
  const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
@@ -4930,72 +4754,24 @@ function getValidNotifyOption(bundlerOptions) {
4930
4754
  } else result = notifyOption;
4931
4755
  }
4932
4756
  }
4933
- var Watcher;
4934
- var init_watcher = __esm({ "src/api/watch/watcher.ts"() {
4935
- init_logging();
4936
- init_logs();
4937
- init_plugin_driver();
4938
- init_create_bundler_option();
4939
- init_misc();
4940
- Watcher = class {
4941
- closed;
4942
- inner;
4943
- emitter;
4944
- stopWorkers;
4945
- constructor(emitter, inner, stopWorkers) {
4946
- this.closed = false;
4947
- this.inner = inner;
4948
- this.emitter = emitter;
4949
- const originClose = emitter.close.bind(emitter);
4950
- emitter.close = async () => {
4951
- await this.close();
4952
- originClose();
4953
- };
4954
- this.stopWorkers = stopWorkers;
4955
- }
4956
- async close() {
4957
- if (this.closed) return;
4958
- this.closed = true;
4959
- for (const stop of this.stopWorkers) await stop?.();
4960
- await this.inner.close();
4961
- shutdownAsyncRuntime();
4962
- }
4963
- start() {
4964
- process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4965
- }
4966
- };
4967
- } });
4968
4757
 
4969
4758
  //#endregion
4970
4759
  //#region src/api/watch/index.ts
4971
- var watch;
4972
- var init_watch = __esm({ "src/api/watch/index.ts"() {
4973
- init_watch_emitter();
4974
- init_watcher();
4975
- watch = (input) => {
4976
- const emitter = new WatcherEmitter();
4977
- createWatcher(emitter, input);
4978
- return emitter;
4979
- };
4980
- } });
4760
+ const watch = (input) => {
4761
+ const emitter = new WatcherEmitter();
4762
+ createWatcher(emitter, input);
4763
+ return emitter;
4764
+ };
4981
4765
 
4982
4766
  //#endregion
4983
4767
  //#region src/utils/define-config.ts
4984
4768
  function defineConfig(config) {
4985
4769
  return config;
4986
4770
  }
4987
- var init_define_config = __esm({ "src/utils/define-config.ts"() {} });
4988
4771
 
4989
4772
  //#endregion
4990
4773
  //#region src/index.ts
4991
- var VERSION;
4992
- var init_src = __esm({ "src/index.ts"() {
4993
- init_build();
4994
- init_rolldown();
4995
- init_watch();
4996
- init_define_config();
4997
- VERSION = version;
4998
- } });
4774
+ const VERSION = version;
4999
4775
 
5000
4776
  //#endregion
5001
- export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, ansis_default, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, init_ansis, 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 };
4777
+ export { BuiltinPlugin, PluginContextData, PluginDriver, VERSION, __commonJS, __toESM, ansis_default, 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 };