rolldown 1.0.0-beta.10-commit.885ee53 → 1.0.0-beta.10-commit.bf212da

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 (32) hide show
  1. package/dist/cli.cjs +5 -5
  2. package/dist/cli.mjs +1075 -1036
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.mts +2 -2
  5. package/dist/config.mjs +5 -4
  6. package/dist/experimental-index.cjs +2 -2
  7. package/dist/experimental-index.d.mts +2 -2
  8. package/dist/experimental-index.mjs +12 -3
  9. package/dist/filter-index.d.mts +2 -2
  10. package/dist/filter-index.mjs +2 -1
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.d.mts +2 -2
  13. package/dist/index.mjs +4 -3
  14. package/dist/parallel-plugin-worker.cjs +2 -2
  15. package/dist/parallel-plugin-worker.mjs +34 -28
  16. package/dist/parallel-plugin.d.mts +2 -2
  17. package/dist/parse-ast-index.cjs +1 -1
  18. package/dist/parse-ast-index.d.mts +1 -1
  19. package/dist/parse-ast-index.mjs +2 -1
  20. package/dist/shared/chunk--iN_1bjD.mjs +33 -0
  21. package/dist/shared/{define-config-CpexVifn.d.mts → define-config-BL025qn5.d.mts} +1 -1
  22. package/dist/shared/{load-config-DTXGCmId.cjs → load-config-DEyy-phc.cjs} +1 -1
  23. package/dist/shared/{load-config-WuIFSl0A.mjs → load-config-ZOGX0N6a.mjs} +19 -14
  24. package/dist/shared/{misc-BN0nse6C.mjs → misc-DGAe2XOW.mjs} +4 -1
  25. package/dist/shared/{parse-ast-index-PSQWLeSo.mjs → parse-ast-index-BkTjw5qC.mjs} +30 -40
  26. package/dist/shared/{parse-ast-index-BvK1MT-L.cjs → parse-ast-index-D7OUxwJp.cjs} +1 -1
  27. package/dist/shared/prompt-Dc0i9ubg.mjs +854 -0
  28. package/dist/shared/{src-DrHV5x1X.cjs → src-BOhIOXwi.cjs} +86 -16
  29. package/dist/shared/{src-BB5r5vkG.mjs → src-aebl8_bs.mjs} +1428 -1110
  30. package/package.json +20 -20
  31. package/dist/shared/prompt-C3zHEaSG.mjs +0 -852
  32. /package/dist/shared/{binding-Dod8fhx9.d.mts → binding-CHPrEDXp.d.mts} +0 -0
@@ -1,5 +1,6 @@
1
- import { __toESM, augmentCodeLocation, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, require_binding } from "./parse-ast-index-PSQWLeSo.mjs";
2
- import { arraify, isNullish, noop, unimplemented, unreachable, unsupported } from "./misc-BN0nse6C.mjs";
1
+ import { __esm, __toESM } from "./chunk--iN_1bjD.mjs";
2
+ import { augmentCodeLocation, error, init_logs, init_parse_ast_index, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, require_binding } from "./parse-ast-index-BkTjw5qC.mjs";
3
+ import { arraify, init_misc, isNullish, noop, unimplemented, unreachable, unsupported } from "./misc-DGAe2XOW.mjs";
3
4
  import path from "node:path";
4
5
  import { fileURLToPath } from "node:url";
5
6
  import colors from "ansis";
@@ -8,12 +9,11 @@ import os from "node:os";
8
9
  import { Worker } from "node:worker_threads";
9
10
 
10
11
  //#region package.json
11
- var version = "1.0.0-beta.10-commit.885ee53";
12
+ var version = "1.0.0-beta.10-commit.bf212da";
12
13
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
14
 
14
15
  //#endregion
15
16
  //#region src/builtin-plugin/utils.ts
16
- var import_binding$6 = __toESM(require_binding());
17
17
  function makeBuiltinPluginCallable(plugin) {
18
18
  let callablePlugin = new import_binding$6.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
19
19
  const wrappedPlugin = plugin;
@@ -28,15 +28,13 @@ function bindingifyBuiltInPlugin(plugin) {
28
28
  options: plugin._options
29
29
  };
30
30
  }
31
+ var import_binding$6;
32
+ var init_utils = __esm({ "src/builtin-plugin/utils.ts"() {
33
+ import_binding$6 = __toESM(require_binding());
34
+ } });
31
35
 
32
36
  //#endregion
33
37
  //#region src/builtin-plugin/constructors.ts
34
- var BuiltinPlugin = class {
35
- constructor(name, _options) {
36
- this.name = name;
37
- this._options = _options;
38
- }
39
- };
40
38
  function modulePreloadPolyfillPlugin() {
41
39
  return new BuiltinPlugin("builtin:module-preload-polyfill");
42
40
  }
@@ -104,24 +102,36 @@ function webWorkerPostPlugin() {
104
102
  function oxcRuntimePlugin(config) {
105
103
  return new BuiltinPlugin("builtin:oxc-runtime", config);
106
104
  }
105
+ var BuiltinPlugin;
106
+ var init_constructors = __esm({ "src/builtin-plugin/constructors.ts"() {
107
+ init_utils();
108
+ BuiltinPlugin = class {
109
+ constructor(name, _options) {
110
+ this.name = name;
111
+ this._options = _options;
112
+ }
113
+ };
114
+ } });
107
115
 
108
116
  //#endregion
109
117
  //#region src/log/logging.ts
110
- const LOG_LEVEL_SILENT = "silent";
111
- const LOG_LEVEL_ERROR = "error";
112
- const LOG_LEVEL_WARN = "warn";
113
- const LOG_LEVEL_INFO = "info";
114
- const LOG_LEVEL_DEBUG = "debug";
115
- const logLevelPriority = {
116
- [LOG_LEVEL_DEBUG]: 0,
117
- [LOG_LEVEL_INFO]: 1,
118
- [LOG_LEVEL_WARN]: 2,
119
- [LOG_LEVEL_SILENT]: 3
120
- };
118
+ var LOG_LEVEL_SILENT, LOG_LEVEL_ERROR, LOG_LEVEL_WARN, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, logLevelPriority;
119
+ var init_logging = __esm({ "src/log/logging.ts"() {
120
+ LOG_LEVEL_SILENT = "silent";
121
+ LOG_LEVEL_ERROR = "error";
122
+ LOG_LEVEL_WARN = "warn";
123
+ LOG_LEVEL_INFO = "info";
124
+ LOG_LEVEL_DEBUG = "debug";
125
+ logLevelPriority = {
126
+ [LOG_LEVEL_DEBUG]: 0,
127
+ [LOG_LEVEL_INFO]: 1,
128
+ [LOG_LEVEL_WARN]: 2,
129
+ [LOG_LEVEL_SILENT]: 3
130
+ };
131
+ } });
121
132
 
122
133
  //#endregion
123
134
  //#region src/log/log-handler.ts
124
- const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
125
135
  function getLogHandler(level, code, logger, pluginName, logLevel) {
126
136
  if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
127
137
  return (log, pos) => {
@@ -133,6 +143,13 @@ function getLogHandler(level, code, logger, pluginName, logLevel) {
133
143
  logger(level, log);
134
144
  };
135
145
  }
146
+ var normalizeLog;
147
+ var init_log_handler = __esm({ "src/log/log-handler.ts"() {
148
+ init_misc();
149
+ init_logging();
150
+ init_logs();
151
+ normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
152
+ } });
136
153
 
137
154
  //#endregion
138
155
  //#region src/log/logger.ts
@@ -168,47 +185,55 @@ function getLogger(plugins, onLog, logLevel, watchMode) {
168
185
  };
169
186
  return logger;
170
187
  }
171
- const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
172
- const { onwarn, onLog } = config;
173
- const defaultOnLog = getDefaultOnLog(printLog, onwarn);
174
- if (onLog) {
175
- const minimalPriority = logLevelPriority[logLevel];
176
- return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
177
- if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
178
- if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
179
- });
180
- }
181
- return defaultOnLog;
182
- };
183
- const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
184
- if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
185
- else printLog(level, log);
186
- } : printLog;
187
- const addLogToString = (log) => {
188
- Object.defineProperty(log, "toString", {
189
- value: () => getExtendedLogMessage(log),
190
- writable: true
191
- });
192
- return log;
193
- };
194
- const defaultPrintLog = (level, log) => {
195
- const message = getExtendedLogMessage(log);
196
- switch (level) {
197
- case LOG_LEVEL_WARN: return console.warn(message);
198
- case LOG_LEVEL_DEBUG: return console.debug(message);
199
- default: return console.info(message);
200
- }
201
- };
202
- const getExtendedLogMessage = (log) => {
203
- let prefix = "";
204
- if (log.plugin) prefix += `(${log.plugin} plugin) `;
205
- if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
206
- return prefix + log.message;
207
- };
208
188
  function relativeId(id) {
209
189
  if (!path.isAbsolute(id)) return id;
210
190
  return path.relative(path.resolve(), id);
211
191
  }
192
+ var getOnLog, getDefaultOnLog, addLogToString, defaultPrintLog, getExtendedLogMessage;
193
+ var init_logger = __esm({ "src/log/logger.ts"() {
194
+ init_src();
195
+ init_plugin_driver();
196
+ init_log_handler();
197
+ init_logging();
198
+ init_logs();
199
+ getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
200
+ const { onwarn, onLog } = config;
201
+ const defaultOnLog = getDefaultOnLog(printLog, onwarn);
202
+ if (onLog) {
203
+ const minimalPriority = logLevelPriority[logLevel];
204
+ return (level, log) => onLog(level, addLogToString(log), (level$1, handledLog) => {
205
+ if (level$1 === LOG_LEVEL_ERROR) return error(normalizeLog(handledLog));
206
+ if (logLevelPriority[level$1] >= minimalPriority) defaultOnLog(level$1, normalizeLog(handledLog));
207
+ });
208
+ }
209
+ return defaultOnLog;
210
+ };
211
+ getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
212
+ if (level === LOG_LEVEL_WARN) onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
213
+ else printLog(level, log);
214
+ } : printLog;
215
+ addLogToString = (log) => {
216
+ Object.defineProperty(log, "toString", {
217
+ value: () => getExtendedLogMessage(log),
218
+ writable: true
219
+ });
220
+ return log;
221
+ };
222
+ defaultPrintLog = (level, log) => {
223
+ const message = getExtendedLogMessage(log);
224
+ switch (level) {
225
+ case LOG_LEVEL_WARN: return console.warn(message);
226
+ case LOG_LEVEL_DEBUG: return console.debug(message);
227
+ default: return console.info(message);
228
+ }
229
+ };
230
+ getExtendedLogMessage = (log) => {
231
+ let prefix = "";
232
+ if (log.plugin) prefix += `(${log.plugin} plugin) `;
233
+ if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
234
+ return prefix + log.message;
235
+ };
236
+ } });
212
237
 
213
238
  //#endregion
214
239
  //#region src/utils/normalize-hook.ts
@@ -228,75 +253,71 @@ function normalizeHook(hook) {
228
253
  }
229
254
  unreachable("Invalid hook type");
230
255
  }
256
+ var init_normalize_hook = __esm({ "src/utils/normalize-hook.ts"() {
257
+ init_misc();
258
+ } });
231
259
 
232
260
  //#endregion
233
261
  //#region src/constants/plugin.ts
234
- const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
235
- "options",
236
- "buildStart",
237
- "resolveId",
238
- "load",
239
- "transform",
240
- "moduleParsed",
241
- "buildEnd",
242
- "onLog",
243
- "resolveDynamicImport",
244
- "closeBundle",
245
- "closeWatcher",
246
- "watchChange"
247
- ];
248
- const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
249
- "augmentChunkHash",
250
- "outputOptions",
251
- "renderChunk",
252
- "renderStart",
253
- "renderError",
254
- "writeBundle",
255
- "generateBundle"
256
- ];
257
- const ENUMERATED_PLUGIN_HOOK_NAMES = [
258
- ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
259
- ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
260
- "footer",
261
- "banner",
262
- "intro",
263
- "outro"
264
- ];
265
- /**
266
- * Names of all defined hooks. It's like
267
- * ```js
268
- * const DEFINED_HOOK_NAMES ={
269
- * options: 'options',
270
- * buildStart: 'buildStart',
271
- * ...
272
- * }
273
- * ```
274
- */
275
- const DEFINED_HOOK_NAMES = {
276
- [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
277
- [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
278
- [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
279
- [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
280
- [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
281
- [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
282
- [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
283
- [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
284
- [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
285
- [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
286
- [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
287
- [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
288
- [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
289
- [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
290
- [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
291
- [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
292
- [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
293
- [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
294
- [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
295
- [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
296
- [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
297
- [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
298
- [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
299
- };
262
+ var ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, ENUMERATED_PLUGIN_HOOK_NAMES, DEFINED_HOOK_NAMES;
263
+ var init_plugin$1 = __esm({ "src/constants/plugin.ts"() {
264
+ ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
265
+ "options",
266
+ "buildStart",
267
+ "resolveId",
268
+ "load",
269
+ "transform",
270
+ "moduleParsed",
271
+ "buildEnd",
272
+ "onLog",
273
+ "resolveDynamicImport",
274
+ "closeBundle",
275
+ "closeWatcher",
276
+ "watchChange"
277
+ ];
278
+ ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
279
+ "augmentChunkHash",
280
+ "outputOptions",
281
+ "renderChunk",
282
+ "renderStart",
283
+ "renderError",
284
+ "writeBundle",
285
+ "generateBundle"
286
+ ];
287
+ ENUMERATED_PLUGIN_HOOK_NAMES = [
288
+ ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
289
+ ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
290
+ "footer",
291
+ "banner",
292
+ "intro",
293
+ "outro"
294
+ ];
295
+ DEFINED_HOOK_NAMES = {
296
+ [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
297
+ [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
298
+ [ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
299
+ [ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
300
+ [ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
301
+ [ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
302
+ [ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
303
+ [ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
304
+ [ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
305
+ [ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
306
+ [ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
307
+ [ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
308
+ [ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
309
+ [ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
310
+ [ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
311
+ [ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
312
+ [ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
313
+ [ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
314
+ [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
315
+ [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
316
+ [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
317
+ [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
318
+ [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
319
+ };
320
+ } });
300
321
 
301
322
  //#endregion
302
323
  //#region src/utils/async-flatten.ts
@@ -306,10 +327,10 @@ async function asyncFlatten(array$1) {
306
327
  while (array$1.some((v) => v?.then));
307
328
  return array$1;
308
329
  }
330
+ var init_async_flatten = __esm({ "src/utils/async-flatten.ts"() {} });
309
331
 
310
332
  //#endregion
311
333
  //#region src/utils/normalize-plugin-option.ts
312
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
313
334
  function checkOutputPluginOption(plugins, onLog) {
314
335
  for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
315
336
  delete plugin[hook];
@@ -325,66 +346,52 @@ function normalizePlugins(plugins, anonymousPrefix) {
325
346
  }
326
347
  return plugins;
327
348
  }
328
- const ANONYMOUS_PLUGIN_PREFIX = "at position ";
329
- const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
330
- const BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
349
+ var normalizePluginOption, ANONYMOUS_PLUGIN_PREFIX, ANONYMOUS_OUTPUT_PLUGIN_PREFIX, BUILTIN_PLUGINS;
350
+ var init_normalize_plugin_option = __esm({ "src/utils/normalize-plugin-option.ts"() {
351
+ init_constructors();
352
+ init_plugin$1();
353
+ init_logging();
354
+ init_logs();
355
+ init_async_flatten();
356
+ normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
357
+ ANONYMOUS_PLUGIN_PREFIX = "at position ";
358
+ ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
359
+ BUILTIN_PLUGINS = [oxcRuntimePlugin({ resolveBase: fileURLToPath(import.meta.url) })];
360
+ } });
331
361
 
332
362
  //#endregion
333
363
  //#region src/plugin/minimal-plugin-context.ts
334
- var MinimalPluginContextImpl = class {
335
- info;
336
- warn;
337
- debug;
338
- meta;
339
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
340
- this.pluginName = pluginName;
341
- this.hookName = hookName;
342
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
343
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
344
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
345
- this.meta = {
346
- rollupVersion: "4.23.0",
347
- rolldownVersion: VERSION,
348
- watchMode
349
- };
350
- }
351
- error(e) {
352
- return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
353
- }
354
- };
364
+ var MinimalPluginContextImpl;
365
+ var init_minimal_plugin_context = __esm({ "src/plugin/minimal-plugin-context.ts"() {
366
+ init_src();
367
+ init_log_handler();
368
+ init_logging();
369
+ init_logs();
370
+ MinimalPluginContextImpl = class {
371
+ info;
372
+ warn;
373
+ debug;
374
+ meta;
375
+ constructor(onLog, logLevel, pluginName, watchMode, hookName) {
376
+ this.pluginName = pluginName;
377
+ this.hookName = hookName;
378
+ this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
379
+ this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
380
+ this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
381
+ this.meta = {
382
+ rollupVersion: "4.23.0",
383
+ rolldownVersion: VERSION,
384
+ watchMode
385
+ };
386
+ }
387
+ error(e) {
388
+ return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
389
+ }
390
+ };
391
+ } });
355
392
 
356
393
  //#endregion
357
394
  //#region src/plugin/plugin-driver.ts
358
- var PluginDriver = class {
359
- static async callOptionsHook(inputOptions, watchMode = false) {
360
- const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
361
- const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
362
- const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
363
- for (const plugin of plugins) {
364
- const name = plugin.name || "unknown";
365
- const options = plugin.options;
366
- if (options) {
367
- const { handler } = normalizeHook(options);
368
- const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
369
- if (result) inputOptions = result;
370
- }
371
- }
372
- return inputOptions;
373
- }
374
- static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
375
- const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
376
- for (const plugin of sortedPlugins) {
377
- const name = plugin.name || "unknown";
378
- const options = plugin.outputOptions;
379
- if (options) {
380
- const { handler } = normalizeHook(options);
381
- const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
382
- if (result) outputOptions = result;
383
- }
384
- }
385
- return outputOptions;
386
- }
387
- };
388
395
  function getObjectPlugins(plugins) {
389
396
  return plugins.filter((plugin) => {
390
397
  if (!plugin) return void 0;
@@ -419,10 +426,48 @@ function getSortedPlugins(hookName, plugins) {
419
426
  ...post
420
427
  ];
421
428
  }
429
+ var PluginDriver;
430
+ var init_plugin_driver = __esm({ "src/plugin/plugin-driver.ts"() {
431
+ init_constructors();
432
+ init_logger();
433
+ init_logging();
434
+ init_normalize_hook();
435
+ init_normalize_plugin_option();
436
+ init_minimal_plugin_context();
437
+ PluginDriver = class {
438
+ static async callOptionsHook(inputOptions, watchMode = false) {
439
+ const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
440
+ const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
441
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
442
+ for (const plugin of plugins) {
443
+ const name = plugin.name || "unknown";
444
+ const options = plugin.options;
445
+ if (options) {
446
+ const { handler } = normalizeHook(options);
447
+ const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
448
+ if (result) inputOptions = result;
449
+ }
450
+ }
451
+ return inputOptions;
452
+ }
453
+ static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
454
+ const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
455
+ for (const plugin of sortedPlugins) {
456
+ const name = plugin.name || "unknown";
457
+ const options = plugin.outputOptions;
458
+ if (options) {
459
+ const { handler } = normalizeHook(options);
460
+ const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
461
+ if (result) outputOptions = result;
462
+ }
463
+ }
464
+ return outputOptions;
465
+ }
466
+ };
467
+ } });
422
468
 
423
469
  //#endregion
424
470
  //#region ../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js
425
- var store$1;
426
471
  /* @__NO_SIDE_EFFECTS__ */
427
472
  function getGlobalConfig(config2) {
428
473
  return {
@@ -432,17 +477,14 @@ function getGlobalConfig(config2) {
432
477
  abortPipeEarly: config2?.abortPipeEarly ?? store$1?.abortPipeEarly
433
478
  };
434
479
  }
435
- var store2;
436
480
  /* @__NO_SIDE_EFFECTS__ */
437
481
  function getGlobalMessage(lang) {
438
482
  return store2?.get(lang);
439
483
  }
440
- var store3;
441
484
  /* @__NO_SIDE_EFFECTS__ */
442
485
  function getSchemaMessage(lang) {
443
486
  return store3?.get(lang);
444
487
  }
445
- var store4;
446
488
  /* @__NO_SIDE_EFFECTS__ */
447
489
  function getSpecificMessage(reference, lang) {
448
490
  return store4?.get(reference)?.get(lang);
@@ -500,18 +542,6 @@ function _joinExpects(values2, separator) {
500
542
  if (list.length > 1) return `(${list.join(` ${separator} `)})`;
501
543
  return list[0] ?? "never";
502
544
  }
503
- var ValiError = class extends Error {
504
- /**
505
- * Creates a Valibot error with useful information.
506
- *
507
- * @param issues The error issues.
508
- */
509
- constructor(issues) {
510
- super(issues[0].message);
511
- this.name = "ValiError";
512
- this.issues = issues;
513
- }
514
- };
515
545
  /* @__NO_SIDE_EFFECTS__ */
516
546
  function args(schema) {
517
547
  return {
@@ -1408,13 +1438,32 @@ function safeParse(schema, input, config2) {
1408
1438
  issues: dataset.issues
1409
1439
  };
1410
1440
  }
1441
+ var store$1, store2, store3, store4, ValiError;
1442
+ var init_dist$2 = __esm({ "../../node_modules/.pnpm/valibot@1.1.0_typescript@5.8.3/node_modules/valibot/dist/index.js"() {
1443
+ ValiError = class extends Error {
1444
+ /**
1445
+ * Creates a Valibot error with useful information.
1446
+ *
1447
+ * @param issues The error issues.
1448
+ */
1449
+ constructor(issues) {
1450
+ super(issues[0].message);
1451
+ this.name = "ValiError";
1452
+ this.issues = issues;
1453
+ }
1454
+ };
1455
+ } });
1411
1456
 
1412
1457
  //#endregion
1413
- //#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.2.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js
1414
- var store;
1415
- function getGlobalDefs() {
1416
- return store;
1417
- }
1458
+ //#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
1459
+ /**
1460
+ * Adds an error message to the errors array.
1461
+ *
1462
+ * @param errors The array of error messages.
1463
+ * @param message The error message to add.
1464
+ *
1465
+ * @returns The new errors.
1466
+ */
1418
1467
  function addError(errors, message) {
1419
1468
  if (errors) {
1420
1469
  errors.push(message);
@@ -1422,6 +1471,12 @@ function addError(errors, message) {
1422
1471
  }
1423
1472
  return [message];
1424
1473
  }
1474
+ /**
1475
+ * Throws an error or logs a warning based on the configuration.
1476
+ *
1477
+ * @param message The message to throw or log.
1478
+ * @param config The conversion configuration.
1479
+ */
1425
1480
  function handleError(message, config) {
1426
1481
  switch (config?.errorMode) {
1427
1482
  case "ignore": break;
@@ -1432,7 +1487,17 @@ function handleError(message, config) {
1432
1487
  default: throw new Error(message);
1433
1488
  }
1434
1489
  }
1490
+ /**
1491
+ * Converts any supported Valibot action to the JSON Schema format.
1492
+ *
1493
+ * @param jsonSchema The JSON Schema object.
1494
+ * @param valibotAction The Valibot action object.
1495
+ * @param config The conversion configuration.
1496
+ *
1497
+ * @returns The converted JSON Schema.
1498
+ */
1435
1499
  function convertAction(jsonSchema, valibotAction, config) {
1500
+ if (config?.ignoreActions?.includes(valibotAction.type)) return jsonSchema;
1436
1501
  let errors;
1437
1502
  switch (valibotAction.type) {
1438
1503
  case "base64": {
@@ -1595,7 +1660,27 @@ function convertAction(jsonSchema, valibotAction, config) {
1595
1660
  if (errors) for (const message of errors) handleError(message, config);
1596
1661
  return jsonSchema;
1597
1662
  }
1598
- var refCount = 0;
1663
+ /**
1664
+ * Flattens a Valibot pipe by recursively expanding nested pipes.
1665
+ *
1666
+ * @param pipe The pipeline to flatten.
1667
+ *
1668
+ * @returns A flat pipeline.
1669
+ */
1670
+ function flattenPipe(pipe$1) {
1671
+ return pipe$1.flatMap((item) => "pipe" in item ? flattenPipe(item.pipe) : item);
1672
+ }
1673
+ /**
1674
+ * Converts any supported Valibot schema to the JSON Schema format.
1675
+ *
1676
+ * @param jsonSchema The JSON Schema object.
1677
+ * @param valibotSchema The Valibot schema object.
1678
+ * @param config The conversion configuration.
1679
+ * @param context The conversion context.
1680
+ * @param skipRef Whether to skip using a reference.
1681
+ *
1682
+ * @returns The converted JSON Schema.
1683
+ */
1599
1684
  function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = false) {
1600
1685
  if (!skipRef) {
1601
1686
  const referenceId = context.referenceMap.get(valibotSchema);
@@ -1614,10 +1699,20 @@ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = fal
1614
1699
  }
1615
1700
  }
1616
1701
  if ("pipe" in valibotSchema) {
1617
- for (let index = 0; index < valibotSchema.pipe.length; index++) {
1618
- const valibotPipeItem = valibotSchema.pipe[index];
1702
+ const flatPipe = flattenPipe(valibotSchema.pipe);
1703
+ let startIndex = 0;
1704
+ let stopIndex = flatPipe.length - 1;
1705
+ if (config?.typeMode === "input") {
1706
+ const inputStopIndex = flatPipe.slice(1).findIndex((item) => item.kind === "schema" || item.kind === "transformation" && (item.type === "find_item" || item.type === "parse_json" || item.type === "raw_transform" || item.type === "reduce_items" || item.type === "stringify_json" || item.type === "transform"));
1707
+ if (inputStopIndex !== -1) stopIndex = inputStopIndex;
1708
+ } else if (config?.typeMode === "output") {
1709
+ const outputStartIndex = flatPipe.findLastIndex((item) => item.kind === "schema");
1710
+ if (outputStartIndex !== -1) startIndex = outputStartIndex;
1711
+ }
1712
+ for (let index = startIndex; index <= stopIndex; index++) {
1713
+ const valibotPipeItem = flatPipe[index];
1619
1714
  if (valibotPipeItem.kind === "schema") {
1620
- if (index > 0) handleError("A \"pipe\" with multiple schemas cannot be converted to JSON Schema.", config);
1715
+ if (index > startIndex) handleError("Set the \"typeMode\" config to \"input\" or \"output\" to convert pipelines with multiple schemas.", config);
1621
1716
  jsonSchema = convertSchema(jsonSchema, valibotPipeItem, config, context, true);
1622
1717
  } else jsonSchema = convertAction(jsonSchema, valibotPipeItem, config);
1623
1718
  }
@@ -1736,7 +1831,7 @@ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = fal
1736
1831
  const refOverride = config.overrideRef({
1737
1832
  ...context,
1738
1833
  referenceId,
1739
- valibotSchema,
1834
+ valibotSchema: wrappedValibotSchema,
1740
1835
  jsonSchema
1741
1836
  });
1742
1837
  if (refOverride) jsonSchema.$ref = refOverride;
@@ -1758,6 +1853,24 @@ function convertSchema(jsonSchema, valibotSchema, config, context, skipRef = fal
1758
1853
  if (errors) for (const message of errors) handleError(message, config);
1759
1854
  return jsonSchema;
1760
1855
  }
1856
+ /**
1857
+ * Returns the current global schema definitions.
1858
+ *
1859
+ * @returns The schema definitions.
1860
+ *
1861
+ * @beta
1862
+ */
1863
+ function getGlobalDefs() {
1864
+ return store;
1865
+ }
1866
+ /**
1867
+ * Converts a Valibot schema to the JSON Schema format.
1868
+ *
1869
+ * @param schema The Valibot schema object.
1870
+ * @param config The JSON Schema configuration.
1871
+ *
1872
+ * @returns The converted JSON Schema.
1873
+ */
1761
1874
  function toJsonSchema(schema, config) {
1762
1875
  const context = {
1763
1876
  definitions: {},
@@ -1773,360 +1886,14 @@ function toJsonSchema(schema, config) {
1773
1886
  if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
1774
1887
  return jsonSchema;
1775
1888
  }
1889
+ var refCount, store;
1890
+ var init_dist$1 = __esm({ "../../node_modules/.pnpm/@valibot+to-json-schema@1.3.0_valibot@1.1.0_typescript@5.8.3_/node_modules/@valibot/to-json-schema/dist/index.js"() {
1891
+ init_dist$2();
1892
+ refCount = 0;
1893
+ } });
1776
1894
 
1777
1895
  //#endregion
1778
1896
  //#region src/utils/validator.ts
1779
- const StringOrRegExpSchema = union([string(), instance(RegExp)]);
1780
- const LogLevelSchema = union([
1781
- literal("debug"),
1782
- literal("info"),
1783
- literal("warn")
1784
- ]);
1785
- const LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
1786
- const LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
1787
- const RollupLogSchema = any();
1788
- const RollupLogWithStringSchema = union([RollupLogSchema, string()]);
1789
- const InputOptionSchema = union([
1790
- string(),
1791
- array(string()),
1792
- record(string(), string())
1793
- ]);
1794
- const ExternalSchema = union([
1795
- StringOrRegExpSchema,
1796
- array(StringOrRegExpSchema),
1797
- pipe(function_(), args(tuple([
1798
- string(),
1799
- optional(string()),
1800
- boolean()
1801
- ])), returns(nullish(boolean())))
1802
- ]);
1803
- const ModuleTypesSchema = record(string(), union([
1804
- literal("asset"),
1805
- literal("base64"),
1806
- literal("binary"),
1807
- literal("css"),
1808
- literal("dataurl"),
1809
- literal("empty"),
1810
- literal("js"),
1811
- literal("json"),
1812
- literal("jsx"),
1813
- literal("text"),
1814
- literal("ts"),
1815
- literal("tsx")
1816
- ]));
1817
- const JsxOptionsSchema = strictObject({
1818
- runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
1819
- development: pipe(optional(boolean()), description("Development specific information")),
1820
- throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1821
- importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1822
- pragma: pipe(optional(string()), description("Jsx element transformation")),
1823
- pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1824
- refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1825
- });
1826
- const RollupJsxOptionsSchema = strictObject({
1827
- mode: optional(union([
1828
- literal("classic"),
1829
- literal("automatic"),
1830
- literal("preserve")
1831
- ])),
1832
- factory: optional(string()),
1833
- fragment: optional(string()),
1834
- importSource: optional(string()),
1835
- jsxImportSource: optional(string())
1836
- });
1837
- const HelperModeSchema = union([literal("Runtime"), literal("External")]);
1838
- const DecoratorOptionSchema = object({
1839
- legacy: optional(boolean()),
1840
- emitDecoratorMetadata: optional(boolean())
1841
- });
1842
- const HelpersSchema = object({ mode: optional(HelperModeSchema) });
1843
- const RewriteImportExtensionsSchema = union([
1844
- literal("rewrite"),
1845
- literal("remove"),
1846
- boolean()
1847
- ]);
1848
- const TypescriptSchema = object({
1849
- jsxPragma: optional(string()),
1850
- jsxPragmaFrag: optional(string()),
1851
- onlyRemoveTypeImports: optional(boolean()),
1852
- allowNamespaces: optional(boolean()),
1853
- allowDeclareFields: optional(boolean()),
1854
- declaration: optional(object({
1855
- stripInternal: optional(boolean()),
1856
- sourcemap: optional(boolean())
1857
- })),
1858
- rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
1859
- });
1860
- const AssumptionsSchema = object({
1861
- ignoreFunctionLength: optional(boolean()),
1862
- noDocumentAll: optional(boolean()),
1863
- objectRestNoSymbols: optional(boolean()),
1864
- pureGetters: optional(boolean()),
1865
- setPublicClassFields: optional(boolean())
1866
- });
1867
- const TransformOptionsSchema = object({
1868
- assumptions: optional(AssumptionsSchema),
1869
- typescript: optional(TypescriptSchema),
1870
- helpers: optional(HelpersSchema),
1871
- decorators: optional(DecoratorOptionSchema),
1872
- jsx: optional(JsxOptionsSchema),
1873
- target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
1874
- });
1875
- const WatchOptionsSchema = strictObject({
1876
- chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
1877
- exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
1878
- include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
1879
- notify: pipe(optional(strictObject({
1880
- compareContents: optional(boolean()),
1881
- pollInterval: optional(number())
1882
- })), description("Notify options")),
1883
- skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
1884
- buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
1885
- });
1886
- const ChecksOptionsSchema = strictObject({
1887
- circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
1888
- eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
1889
- missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
1890
- missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
1891
- mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
1892
- unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
1893
- unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
1894
- filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
1895
- commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
1896
- importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
1897
- configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
1898
- });
1899
- const MinifyOptionsSchema = strictObject({
1900
- mangle: optional(boolean()),
1901
- compress: optional(boolean()),
1902
- removeWhitespace: optional(boolean())
1903
- });
1904
- const ResolveOptionsSchema = strictObject({
1905
- alias: optional(record(string(), union([string(), array(string())]))),
1906
- aliasFields: optional(array(array(string()))),
1907
- conditionNames: optional(array(string())),
1908
- extensionAlias: optional(record(string(), array(string()))),
1909
- exportsFields: optional(array(array(string()))),
1910
- extensions: optional(array(string())),
1911
- mainFields: optional(array(string())),
1912
- mainFiles: optional(array(string())),
1913
- modules: optional(array(string())),
1914
- symlinks: optional(boolean()),
1915
- tsconfigFilename: optional(string())
1916
- });
1917
- const TreeshakingOptionsSchema = union([boolean(), looseObject({
1918
- annotations: optional(boolean()),
1919
- manualPureFunctions: optional(array(string())),
1920
- unknownGlobalSideEffects: optional(boolean())
1921
- })]);
1922
- const OnLogSchema = pipe(function_(), args(tuple([
1923
- LogLevelSchema,
1924
- RollupLogSchema,
1925
- pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
1926
- ])));
1927
- const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
1928
- const HmrSchema = union([boolean(), strictObject({
1929
- port: optional(number()),
1930
- host: optional(string()),
1931
- implement: optional(string())
1932
- })]);
1933
- const InputOptionsSchema = strictObject({
1934
- input: optional(InputOptionSchema),
1935
- plugins: optional(custom(() => true)),
1936
- external: optional(ExternalSchema),
1937
- resolve: optional(ResolveOptionsSchema),
1938
- cwd: pipe(optional(string()), description("Current working directory")),
1939
- platform: pipe(optional(union([
1940
- literal("browser"),
1941
- literal("neutral"),
1942
- literal("node")
1943
- ])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
1944
- shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
1945
- treeshake: optional(TreeshakingOptionsSchema),
1946
- logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
1947
- onLog: optional(OnLogSchema),
1948
- onwarn: optional(OnwarnSchema),
1949
- moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
1950
- experimental: optional(strictObject({
1951
- disableLiveBindings: optional(boolean()),
1952
- enableComposingJsPlugins: optional(boolean()),
1953
- resolveNewUrlToAsset: optional(boolean()),
1954
- strictExecutionOrder: optional(boolean()),
1955
- hmr: optional(HmrSchema),
1956
- attachDebugInfo: optional(boolean())
1957
- })),
1958
- define: pipe(optional(record(string(), string())), description("Define global variables")),
1959
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
1960
- profilerNames: optional(boolean()),
1961
- jsx: optional(union([
1962
- literal(false),
1963
- literal("react"),
1964
- literal("react-jsx"),
1965
- literal("preserve"),
1966
- RollupJsxOptionsSchema
1967
- ])),
1968
- transform: optional(TransformOptionsSchema),
1969
- watch: optional(union([WatchOptionsSchema, literal(false)])),
1970
- dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
1971
- checks: optional(ChecksOptionsSchema),
1972
- keepNames: pipe(optional(boolean()), description("Keep function/class name")),
1973
- 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."))
1974
- });
1975
- const InputCliOverrideSchema = strictObject({
1976
- input: pipe(optional(array(string())), description("Entry file")),
1977
- external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
1978
- inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
1979
- treeshake: pipe(optional(boolean()), description("enable treeshaking")),
1980
- jsx: pipe(optional(union([
1981
- literal(false),
1982
- literal("react"),
1983
- literal("react-jsx"),
1984
- literal("preserve")
1985
- ])), description("Jsx options preset"))
1986
- });
1987
- const InputCliOptionsSchema = omit(strictObject({
1988
- ...InputOptionsSchema.entries,
1989
- ...InputCliOverrideSchema.entries
1990
- }), [
1991
- "plugins",
1992
- "onwarn",
1993
- "onLog",
1994
- "resolve",
1995
- "experimental",
1996
- "profilerNames",
1997
- "watch"
1998
- ]);
1999
- const ModuleFormatSchema = union([
2000
- literal("es"),
2001
- literal("cjs"),
2002
- literal("esm"),
2003
- literal("module"),
2004
- literal("commonjs"),
2005
- literal("iife"),
2006
- literal("umd")
2007
- ]);
2008
- const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2009
- const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2010
- const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2011
- const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2012
- const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2013
- const AdvancedChunksSchema = strictObject({
2014
- minSize: optional(number()),
2015
- maxSize: optional(number()),
2016
- minModuleSize: optional(number()),
2017
- maxModuleSize: optional(number()),
2018
- minShareCount: optional(number()),
2019
- groups: optional(array(strictObject({
2020
- name: string(),
2021
- test: optional(union([
2022
- string(),
2023
- instance(RegExp),
2024
- pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2025
- ])),
2026
- priority: optional(number()),
2027
- minSize: optional(number()),
2028
- minShareCount: optional(number()),
2029
- maxSize: optional(number()),
2030
- minModuleSize: optional(number()),
2031
- maxModuleSize: optional(number())
2032
- })))
2033
- });
2034
- const OutputOptionsSchema = strictObject({
2035
- dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2036
- file: pipe(optional(string()), description("Single output file")),
2037
- exports: pipe(optional(union([
2038
- literal("auto"),
2039
- literal("named"),
2040
- literal("default"),
2041
- literal("none")
2042
- ])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
2043
- hashCharacters: pipe(optional(union([
2044
- literal("base64"),
2045
- literal("base36"),
2046
- literal("hex")
2047
- ])), description("Use the specified character set for file hashes")),
2048
- format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
2049
- sourcemap: pipe(optional(union([
2050
- boolean(),
2051
- literal("inline"),
2052
- literal("hidden")
2053
- ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2054
- sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2055
- sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2056
- sourcemapPathTransform: optional(custom(() => true)),
2057
- banner: optional(union([string(), AddonFunctionSchema])),
2058
- footer: optional(union([string(), AddonFunctionSchema])),
2059
- intro: optional(union([string(), AddonFunctionSchema])),
2060
- outro: optional(union([string(), AddonFunctionSchema])),
2061
- extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2062
- esModule: optional(union([boolean(), literal("if-default-prop")])),
2063
- assetFileNames: optional(AssetFileNamesSchema),
2064
- entryFileNames: optional(ChunkFileNamesSchema),
2065
- chunkFileNames: optional(ChunkFileNamesSchema),
2066
- cssEntryFileNames: optional(ChunkFileNamesSchema),
2067
- cssChunkFileNames: optional(ChunkFileNamesSchema),
2068
- sanitizeFileName: optional(SanitizeFileNameSchema),
2069
- minify: pipe(optional(union([
2070
- boolean(),
2071
- string("dce-only"),
2072
- MinifyOptionsSchema
2073
- ])), description("Minify the bundled file")),
2074
- name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2075
- globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2076
- externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2077
- inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2078
- manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2079
- advancedChunks: optional(AdvancedChunksSchema),
2080
- legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2081
- plugins: optional(custom(() => true)),
2082
- polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2083
- hoistTransitiveImports: optional(custom((input) => {
2084
- if (input) return false;
2085
- return true;
2086
- }, () => `The 'true' value is not supported`)),
2087
- preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2088
- preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2089
- virtualDirname: optional(string())
2090
- });
2091
- const getAddonDescription = (placement, wrapper) => {
2092
- return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
2093
- };
2094
- const OutputCliOverrideSchema = strictObject({
2095
- assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2096
- entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2097
- chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2098
- cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2099
- cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2100
- sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2101
- banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2102
- footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2103
- intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2104
- outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2105
- esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2106
- globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2107
- advancedChunks: pipe(optional(strictObject({
2108
- minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2109
- minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2110
- })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2111
- minify: pipe(optional(boolean()), description("Minify the bundled file"))
2112
- });
2113
- const OutputCliOptionsSchema = omit(strictObject({
2114
- ...OutputOptionsSchema.entries,
2115
- ...OutputCliOverrideSchema.entries
2116
- }), [
2117
- "sourcemapIgnoreList",
2118
- "sourcemapPathTransform",
2119
- "plugins",
2120
- "hoistTransitiveImports"
2121
- ]);
2122
- const CliOptionsSchema = strictObject({
2123
- config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2124
- help: pipe(optional(boolean()), description("Show help")),
2125
- version: pipe(optional(boolean()), description("Show version number")),
2126
- watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2127
- ...InputCliOptionsSchema.entries,
2128
- ...OutputCliOptionsSchema.entries
2129
- });
2130
1897
  function validateCliOptions(options) {
2131
1898
  let parsed = safeParse(CliOptionsSchema, options);
2132
1899
  return [parsed.output, parsed.issues?.map((issue) => {
@@ -2134,8 +1901,6 @@ function validateCliOptions(options) {
2134
1901
  return `Invalid value for option ${option}: ${issue.message}`;
2135
1902
  })];
2136
1903
  }
2137
- const inputHelperMsgRecord = { output: { ignored: true } };
2138
- const outputHelperMsgRecord = {};
2139
1904
  function validateOption(key, options) {
2140
1905
  if (globalThis.process?.env?.ROLLUP_TEST) return;
2141
1906
  let parsed = safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
@@ -2167,38 +1932,396 @@ function getOutputCliKeys() {
2167
1932
  function getJsonSchema() {
2168
1933
  return toJsonSchema(CliOptionsSchema, { errorMode: "ignore" });
2169
1934
  }
1935
+ 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;
1936
+ var init_validator = __esm({ "src/utils/validator.ts"() {
1937
+ init_dist$1();
1938
+ init_dist$2();
1939
+ StringOrRegExpSchema = union([string(), instance(RegExp)]);
1940
+ LogLevelSchema = union([
1941
+ literal("debug"),
1942
+ literal("info"),
1943
+ literal("warn")
1944
+ ]);
1945
+ LogLevelOptionSchema = union([LogLevelSchema, literal("silent")]);
1946
+ LogLevelWithErrorSchema = union([LogLevelSchema, literal("error")]);
1947
+ RollupLogSchema = any();
1948
+ RollupLogWithStringSchema = union([RollupLogSchema, string()]);
1949
+ InputOptionSchema = union([
1950
+ string(),
1951
+ array(string()),
1952
+ record(string(), string())
1953
+ ]);
1954
+ ExternalSchema = union([
1955
+ StringOrRegExpSchema,
1956
+ array(StringOrRegExpSchema),
1957
+ pipe(function_(), args(tuple([
1958
+ string(),
1959
+ optional(string()),
1960
+ boolean()
1961
+ ])), returns(nullish(boolean())))
1962
+ ]);
1963
+ ModuleTypesSchema = record(string(), union([
1964
+ literal("asset"),
1965
+ literal("base64"),
1966
+ literal("binary"),
1967
+ literal("css"),
1968
+ literal("dataurl"),
1969
+ literal("empty"),
1970
+ literal("js"),
1971
+ literal("json"),
1972
+ literal("jsx"),
1973
+ literal("text"),
1974
+ literal("ts"),
1975
+ literal("tsx")
1976
+ ]));
1977
+ JsxOptionsSchema = strictObject({
1978
+ runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
1979
+ development: pipe(optional(boolean()), description("Development specific information")),
1980
+ throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
1981
+ importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
1982
+ pragma: pipe(optional(string()), description("Jsx element transformation")),
1983
+ pragmaFlag: pipe(optional(string()), description("Jsx fragment transformation")),
1984
+ refresh: pipe(optional(boolean()), description("Enable react fast refresh"))
1985
+ });
1986
+ RollupJsxOptionsSchema = strictObject({
1987
+ mode: optional(union([
1988
+ literal("classic"),
1989
+ literal("automatic"),
1990
+ literal("preserve")
1991
+ ])),
1992
+ factory: optional(string()),
1993
+ fragment: optional(string()),
1994
+ importSource: optional(string()),
1995
+ jsxImportSource: optional(string())
1996
+ });
1997
+ HelperModeSchema = union([literal("Runtime"), literal("External")]);
1998
+ DecoratorOptionSchema = object({
1999
+ legacy: optional(boolean()),
2000
+ emitDecoratorMetadata: optional(boolean())
2001
+ });
2002
+ HelpersSchema = object({ mode: optional(HelperModeSchema) });
2003
+ RewriteImportExtensionsSchema = union([
2004
+ literal("rewrite"),
2005
+ literal("remove"),
2006
+ boolean()
2007
+ ]);
2008
+ TypescriptSchema = object({
2009
+ jsxPragma: optional(string()),
2010
+ jsxPragmaFrag: optional(string()),
2011
+ onlyRemoveTypeImports: optional(boolean()),
2012
+ allowNamespaces: optional(boolean()),
2013
+ allowDeclareFields: optional(boolean()),
2014
+ declaration: optional(object({
2015
+ stripInternal: optional(boolean()),
2016
+ sourcemap: optional(boolean())
2017
+ })),
2018
+ rewriteImportExtensions: optional(RewriteImportExtensionsSchema)
2019
+ });
2020
+ AssumptionsSchema = object({
2021
+ ignoreFunctionLength: optional(boolean()),
2022
+ noDocumentAll: optional(boolean()),
2023
+ objectRestNoSymbols: optional(boolean()),
2024
+ pureGetters: optional(boolean()),
2025
+ setPublicClassFields: optional(boolean())
2026
+ });
2027
+ TransformOptionsSchema = object({
2028
+ assumptions: optional(AssumptionsSchema),
2029
+ typescript: optional(TypescriptSchema),
2030
+ helpers: optional(HelpersSchema),
2031
+ decorators: optional(DecoratorOptionSchema),
2032
+ jsx: optional(JsxOptionsSchema),
2033
+ target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment"))
2034
+ });
2035
+ WatchOptionsSchema = strictObject({
2036
+ chokidar: optional(never(`The "watch.chokidar" option is deprecated, please use "watch.notify" instead of it`)),
2037
+ exclude: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2038
+ include: optional(union([StringOrRegExpSchema, array(StringOrRegExpSchema)])),
2039
+ notify: pipe(optional(strictObject({
2040
+ compareContents: optional(boolean()),
2041
+ pollInterval: optional(number())
2042
+ })), description("Notify options")),
2043
+ skipWrite: pipe(optional(boolean()), description("Skip the bundle.write() step")),
2044
+ buildDelay: pipe(optional(number()), description("Throttle watch rebuilds"))
2045
+ });
2046
+ ChecksOptionsSchema = strictObject({
2047
+ circularDependency: pipe(optional(boolean()), description("Whether to emit warning when detecting circular dependency")),
2048
+ eval: pipe(optional(boolean()), description("Whether to emit warning when detecting eval")),
2049
+ missingGlobalName: pipe(optional(boolean()), description("Whether to emit warning when detecting missing global name")),
2050
+ missingNameOptionForIifeExport: pipe(optional(boolean()), description("Whether to emit warning when detecting missing name option for iife export")),
2051
+ mixedExport: pipe(optional(boolean()), description("Whether to emit warning when detecting mixed export")),
2052
+ unresolvedEntry: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved entry")),
2053
+ unresolvedImport: pipe(optional(boolean()), description("Whether to emit warning when detecting unresolved import")),
2054
+ filenameConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting filename conflict")),
2055
+ commonJsVariableInEsm: pipe(optional(boolean()), description("Whether to emit warning when detecting common js variable in esm")),
2056
+ importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
2057
+ configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict"))
2058
+ });
2059
+ MinifyOptionsSchema = strictObject({
2060
+ mangle: optional(boolean()),
2061
+ compress: optional(boolean()),
2062
+ removeWhitespace: optional(boolean())
2063
+ });
2064
+ ResolveOptionsSchema = strictObject({
2065
+ alias: optional(record(string(), union([string(), array(string())]))),
2066
+ aliasFields: optional(array(array(string()))),
2067
+ conditionNames: optional(array(string())),
2068
+ extensionAlias: optional(record(string(), array(string()))),
2069
+ exportsFields: optional(array(array(string()))),
2070
+ extensions: optional(array(string())),
2071
+ mainFields: optional(array(string())),
2072
+ mainFiles: optional(array(string())),
2073
+ modules: optional(array(string())),
2074
+ symlinks: optional(boolean()),
2075
+ tsconfigFilename: optional(string())
2076
+ });
2077
+ TreeshakingOptionsSchema = union([boolean(), looseObject({
2078
+ annotations: optional(boolean()),
2079
+ manualPureFunctions: optional(array(string())),
2080
+ unknownGlobalSideEffects: optional(boolean())
2081
+ })]);
2082
+ OnLogSchema = pipe(function_(), args(tuple([
2083
+ LogLevelSchema,
2084
+ RollupLogSchema,
2085
+ pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
2086
+ ])));
2087
+ OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
2088
+ HmrSchema = union([boolean(), strictObject({
2089
+ port: optional(number()),
2090
+ host: optional(string()),
2091
+ implement: optional(string())
2092
+ })]);
2093
+ InputOptionsSchema = strictObject({
2094
+ input: optional(InputOptionSchema),
2095
+ plugins: optional(custom(() => true)),
2096
+ external: optional(ExternalSchema),
2097
+ resolve: optional(ResolveOptionsSchema),
2098
+ cwd: pipe(optional(string()), description("Current working directory")),
2099
+ platform: pipe(optional(union([
2100
+ literal("browser"),
2101
+ literal("neutral"),
2102
+ literal("node")
2103
+ ])), description(`Platform for which the code should be generated (node, ${colors.underline("browser")}, neutral)`)),
2104
+ shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
2105
+ treeshake: optional(TreeshakingOptionsSchema),
2106
+ logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${colors.dim("silent")}, ${colors.underline(colors.gray("info"))}, debug, ${colors.yellow("warn")})`)),
2107
+ onLog: optional(OnLogSchema),
2108
+ onwarn: optional(OnwarnSchema),
2109
+ moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
2110
+ experimental: optional(strictObject({
2111
+ disableLiveBindings: optional(boolean()),
2112
+ enableComposingJsPlugins: optional(boolean()),
2113
+ resolveNewUrlToAsset: optional(boolean()),
2114
+ strictExecutionOrder: optional(boolean()),
2115
+ hmr: optional(HmrSchema),
2116
+ attachDebugInfo: optional(boolean())
2117
+ })),
2118
+ define: pipe(optional(record(string(), string())), description("Define global variables")),
2119
+ inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2120
+ profilerNames: optional(boolean()),
2121
+ jsx: optional(union([
2122
+ literal(false),
2123
+ literal("react"),
2124
+ literal("react-jsx"),
2125
+ literal("preserve"),
2126
+ RollupJsxOptionsSchema
2127
+ ])),
2128
+ transform: optional(TransformOptionsSchema),
2129
+ watch: optional(union([WatchOptionsSchema, literal(false)])),
2130
+ dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2131
+ checks: optional(ChecksOptionsSchema),
2132
+ keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2133
+ 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."))
2134
+ });
2135
+ InputCliOverrideSchema = strictObject({
2136
+ input: pipe(optional(array(string())), description("Entry file")),
2137
+ external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2138
+ inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2139
+ treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2140
+ jsx: pipe(optional(union([
2141
+ literal(false),
2142
+ literal("react"),
2143
+ literal("react-jsx"),
2144
+ literal("preserve")
2145
+ ])), description("Jsx options preset"))
2146
+ });
2147
+ InputCliOptionsSchema = omit(strictObject({
2148
+ ...InputOptionsSchema.entries,
2149
+ ...InputCliOverrideSchema.entries
2150
+ }), [
2151
+ "plugins",
2152
+ "onwarn",
2153
+ "onLog",
2154
+ "resolve",
2155
+ "experimental",
2156
+ "profilerNames",
2157
+ "watch"
2158
+ ]);
2159
+ ModuleFormatSchema = union([
2160
+ literal("es"),
2161
+ literal("cjs"),
2162
+ literal("esm"),
2163
+ literal("module"),
2164
+ literal("commonjs"),
2165
+ literal("iife"),
2166
+ literal("umd")
2167
+ ]);
2168
+ AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2169
+ ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2170
+ AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2171
+ SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2172
+ GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2173
+ AdvancedChunksSchema = strictObject({
2174
+ minSize: optional(number()),
2175
+ maxSize: optional(number()),
2176
+ minModuleSize: optional(number()),
2177
+ maxModuleSize: optional(number()),
2178
+ minShareCount: optional(number()),
2179
+ groups: optional(array(strictObject({
2180
+ name: string(),
2181
+ test: optional(union([
2182
+ string(),
2183
+ instance(RegExp),
2184
+ pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2185
+ ])),
2186
+ priority: optional(number()),
2187
+ minSize: optional(number()),
2188
+ minShareCount: optional(number()),
2189
+ maxSize: optional(number()),
2190
+ minModuleSize: optional(number()),
2191
+ maxModuleSize: optional(number())
2192
+ })))
2193
+ });
2194
+ OutputOptionsSchema = strictObject({
2195
+ dir: pipe(optional(string()), description("Output directory, defaults to `dist` if `file` is not set")),
2196
+ file: pipe(optional(string()), description("Single output file")),
2197
+ exports: pipe(optional(union([
2198
+ literal("auto"),
2199
+ literal("named"),
2200
+ literal("default"),
2201
+ literal("none")
2202
+ ])), description(`Specify a export mode (${colors.underline("auto")}, named, default, none)`)),
2203
+ hashCharacters: pipe(optional(union([
2204
+ literal("base64"),
2205
+ literal("base36"),
2206
+ literal("hex")
2207
+ ])), description("Use the specified character set for file hashes")),
2208
+ format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${colors.underline("esm")}, cjs, and iife)`)),
2209
+ sourcemap: pipe(optional(union([
2210
+ boolean(),
2211
+ literal("inline"),
2212
+ literal("hidden")
2213
+ ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold("pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2214
+ sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2215
+ sourcemapIgnoreList: optional(union([boolean(), custom(() => true)])),
2216
+ sourcemapPathTransform: optional(custom(() => true)),
2217
+ banner: optional(union([string(), AddonFunctionSchema])),
2218
+ footer: optional(union([string(), AddonFunctionSchema])),
2219
+ intro: optional(union([string(), AddonFunctionSchema])),
2220
+ outro: optional(union([string(), AddonFunctionSchema])),
2221
+ extend: pipe(optional(boolean()), description("Extend global variable defined by name in IIFE / UMD formats")),
2222
+ esModule: optional(union([boolean(), literal("if-default-prop")])),
2223
+ assetFileNames: optional(AssetFileNamesSchema),
2224
+ entryFileNames: optional(ChunkFileNamesSchema),
2225
+ chunkFileNames: optional(ChunkFileNamesSchema),
2226
+ cssEntryFileNames: optional(ChunkFileNamesSchema),
2227
+ cssChunkFileNames: optional(ChunkFileNamesSchema),
2228
+ sanitizeFileName: optional(SanitizeFileNameSchema),
2229
+ minify: pipe(optional(union([
2230
+ boolean(),
2231
+ string("dce-only"),
2232
+ MinifyOptionsSchema
2233
+ ])), description("Minify the bundled file")),
2234
+ name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
2235
+ globals: pipe(optional(union([record(string(), string()), GlobalsFunctionSchema])), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2236
+ externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2237
+ inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2238
+ manualChunks: optional(never("manualChunks is not supported. Please use advancedChunks instead")),
2239
+ advancedChunks: optional(AdvancedChunksSchema),
2240
+ legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2241
+ plugins: optional(custom(() => true)),
2242
+ polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2243
+ hoistTransitiveImports: optional(custom((input) => {
2244
+ if (input) return false;
2245
+ return true;
2246
+ }, () => `The 'true' value is not supported`)),
2247
+ preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2248
+ preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2249
+ virtualDirname: optional(string())
2250
+ });
2251
+ getAddonDescription = (placement, wrapper) => {
2252
+ return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
2253
+ };
2254
+ OutputCliOverrideSchema = strictObject({
2255
+ assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
2256
+ entryFileNames: pipe(optional(string()), description("Name pattern for emitted entry chunks")),
2257
+ chunkFileNames: pipe(optional(string()), description("Name pattern for emitted secondary chunks")),
2258
+ cssEntryFileNames: pipe(optional(string()), description("Name pattern for emitted css entry chunks")),
2259
+ cssChunkFileNames: pipe(optional(string()), description("Name pattern for emitted css secondary chunks")),
2260
+ sanitizeFileName: pipe(optional(boolean()), description("Sanitize file name")),
2261
+ banner: pipe(optional(string()), description(getAddonDescription("top", "outside"))),
2262
+ footer: pipe(optional(string()), description(getAddonDescription("bottom", "outside"))),
2263
+ intro: pipe(optional(string()), description(getAddonDescription("top", "inside"))),
2264
+ outro: pipe(optional(string()), description(getAddonDescription("bottom", "inside"))),
2265
+ esModule: pipe(optional(boolean()), description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
2266
+ globals: pipe(optional(record(string(), string())), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2267
+ advancedChunks: pipe(optional(strictObject({
2268
+ minSize: pipe(optional(number()), description("Minimum size of the chunk")),
2269
+ minShareCount: pipe(optional(number()), description("Minimum share count of the chunk"))
2270
+ })), description("Global variable of UMD / IIFE dependencies (syntax: `key=value`)")),
2271
+ minify: pipe(optional(boolean()), description("Minify the bundled file"))
2272
+ });
2273
+ OutputCliOptionsSchema = omit(strictObject({
2274
+ ...OutputOptionsSchema.entries,
2275
+ ...OutputCliOverrideSchema.entries
2276
+ }), [
2277
+ "sourcemapIgnoreList",
2278
+ "sourcemapPathTransform",
2279
+ "plugins",
2280
+ "hoistTransitiveImports"
2281
+ ]);
2282
+ CliOptionsSchema = strictObject({
2283
+ config: pipe(optional(union([string(), boolean()])), description("Path to the config file (default: `rolldown.config.js`)")),
2284
+ help: pipe(optional(boolean()), description("Show help")),
2285
+ version: pipe(optional(boolean()), description("Show version number")),
2286
+ watch: pipe(optional(boolean()), description("Watch files in bundle and rebuild on changes")),
2287
+ ...InputCliOptionsSchema.entries,
2288
+ ...OutputCliOptionsSchema.entries
2289
+ });
2290
+ inputHelperMsgRecord = { output: { ignored: true } };
2291
+ outputHelperMsgRecord = {};
2292
+ } });
2170
2293
 
2171
2294
  //#endregion
2172
2295
  //#region src/constants/plugin-context.ts
2173
- /**
2174
- * If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
2175
- * To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
2176
- * will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
2177
- * internally.
2178
- */
2179
- const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2296
+ var SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF;
2297
+ var init_plugin_context$1 = __esm({ "src/constants/plugin-context.ts"() {
2298
+ SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol("plugin-context-resolve-caller");
2299
+ } });
2180
2300
 
2181
2301
  //#endregion
2182
2302
  //#region src/options/normalized-input-options.ts
2183
- var NormalizedInputOptionsImpl = class {
2184
- inner;
2185
- constructor(inner, onLog) {
2186
- this.onLog = onLog;
2187
- this.inner = inner;
2188
- }
2189
- get shimMissingExports() {
2190
- return this.inner.shimMissingExports;
2191
- }
2192
- get input() {
2193
- return this.inner.input;
2194
- }
2195
- get cwd() {
2196
- return this.inner.cwd ?? void 0;
2197
- }
2198
- get platform() {
2199
- return this.inner.platform;
2200
- }
2201
- };
2303
+ var NormalizedInputOptionsImpl;
2304
+ var init_normalized_input_options = __esm({ "src/options/normalized-input-options.ts"() {
2305
+ NormalizedInputOptionsImpl = class {
2306
+ inner;
2307
+ constructor(inner, onLog) {
2308
+ this.onLog = onLog;
2309
+ this.inner = inner;
2310
+ }
2311
+ get shimMissingExports() {
2312
+ return this.inner.shimMissingExports;
2313
+ }
2314
+ get input() {
2315
+ return this.inner.input;
2316
+ }
2317
+ get cwd() {
2318
+ return this.inner.cwd ?? void 0;
2319
+ }
2320
+ get platform() {
2321
+ return this.inner.platform;
2322
+ }
2323
+ };
2324
+ } });
2202
2325
 
2203
2326
  //#endregion
2204
2327
  //#region src/types/sourcemap.ts
@@ -2215,6 +2338,7 @@ function bindingifySourcemap(map) {
2215
2338
  debugId: "debugId" in map ? map.debugId : void 0
2216
2339
  } };
2217
2340
  }
2341
+ var init_sourcemap = __esm({ "src/types/sourcemap.ts"() {} });
2218
2342
 
2219
2343
  //#endregion
2220
2344
  //#region src/utils/error.ts
@@ -2265,6 +2389,7 @@ function getErrorMessage(e) {
2265
2389
  function joinNewLine(s1, s2) {
2266
2390
  return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
2267
2391
  }
2392
+ var init_error = __esm({ "src/utils/error.ts"() {} });
2268
2393
 
2269
2394
  //#endregion
2270
2395
  //#region src/utils/transform-module-info.ts
@@ -2286,10 +2411,12 @@ function transformModuleInfo(info, option) {
2286
2411
  ...option
2287
2412
  };
2288
2413
  }
2414
+ var init_transform_module_info = __esm({ "src/utils/transform-module-info.ts"() {
2415
+ init_misc();
2416
+ } });
2289
2417
 
2290
2418
  //#endregion
2291
2419
  //#region src/utils/transform-side-effects.ts
2292
- var import_binding$5 = __toESM(require_binding());
2293
2420
  function bindingifySideEffects(sideEffects) {
2294
2421
  switch (sideEffects) {
2295
2422
  case true: return import_binding$5.BindingHookSideEffects.True;
@@ -2300,6 +2427,10 @@ function bindingifySideEffects(sideEffects) {
2300
2427
  default: throw new Error(`Unexpected side effects: ${sideEffects}`);
2301
2428
  }
2302
2429
  }
2430
+ var import_binding$5;
2431
+ var init_transform_side_effects = __esm({ "src/utils/transform-side-effects.ts"() {
2432
+ import_binding$5 = __toESM(require_binding());
2433
+ } });
2303
2434
 
2304
2435
  //#endregion
2305
2436
  //#region src/utils/transform-sourcemap.ts
@@ -2315,9 +2446,10 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2315
2446
  if (isEmptySourcemapFiled(map.sources) || map.sources && map.sources.length === 1 && map.sources[0] !== id) map.sources = [id];
2316
2447
  return map;
2317
2448
  }
2449
+ var init_transform_sourcemap = __esm({ "src/utils/transform-sourcemap.ts"() {} });
2318
2450
 
2319
2451
  //#endregion
2320
- //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-D6FCK2GA.js
2452
+ //#region ../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-D6FCK2GA.js
2321
2453
  function u$1(o, n, a) {
2322
2454
  let t$1 = (r) => o(r, ...n);
2323
2455
  return a === void 0 ? t$1 : Object.assign(t$1, {
@@ -2325,32 +2457,50 @@ function u$1(o, n, a) {
2325
2457
  lazyArgs: n
2326
2458
  });
2327
2459
  }
2460
+ var init_chunk_D6FCK2GA = __esm({ "../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-D6FCK2GA.js"() {} });
2328
2461
 
2329
2462
  //#endregion
2330
- //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-WIMGWYZL.js
2463
+ //#region ../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-WIMGWYZL.js
2331
2464
  function u(r, n, o) {
2332
2465
  let a = r.length - n.length;
2333
2466
  if (a === 0) return r(...n);
2334
2467
  if (a === 1) return u$1(r, n, o);
2335
2468
  throw new Error("Wrong number of arguments");
2336
2469
  }
2470
+ var init_chunk_WIMGWYZL = __esm({ "../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-WIMGWYZL.js"() {
2471
+ init_chunk_D6FCK2GA();
2472
+ } });
2337
2473
 
2338
2474
  //#endregion
2339
- //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-3IFJP4R5.js
2475
+ //#region ../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-3IFJP4R5.js
2340
2476
  function d(...r) {
2341
2477
  return u(i, r);
2342
2478
  }
2343
- var i = (r, t$1) => {
2344
- let a = [[], []];
2345
- for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
2346
- return a;
2347
- };
2479
+ var i;
2480
+ var init_chunk_3IFJP4R5 = __esm({ "../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-3IFJP4R5.js"() {
2481
+ init_chunk_WIMGWYZL();
2482
+ i = (r, t$1) => {
2483
+ let a = [[], []];
2484
+ for (let [o, e] of r.entries()) t$1(e, o, r) ? a[0].push(e) : a[1].push(e);
2485
+ return a;
2486
+ };
2487
+ } });
2348
2488
 
2349
2489
  //#endregion
2350
- //#region ../../node_modules/.pnpm/remeda@2.21.6/node_modules/remeda/dist/chunk-5NQBDF4H.js
2490
+ //#region ../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-5NQBDF4H.js
2351
2491
  function t(...n) {
2352
2492
  return u(Object.keys, n);
2353
2493
  }
2494
+ var init_chunk_5NQBDF4H = __esm({ "../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/chunk-5NQBDF4H.js"() {
2495
+ init_chunk_WIMGWYZL();
2496
+ } });
2497
+
2498
+ //#endregion
2499
+ //#region ../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/index.js
2500
+ var init_dist = __esm({ "../../node_modules/.pnpm/remeda@2.22.5/node_modules/remeda/dist/index.js"() {
2501
+ init_chunk_3IFJP4R5();
2502
+ init_chunk_5NQBDF4H();
2503
+ } });
2354
2504
 
2355
2505
  //#endregion
2356
2506
  //#region src/plugin/bindingify-hook-filter.ts
@@ -2492,10 +2642,13 @@ function bindingifyRenderChunkFilter(filterOption) {
2492
2642
  if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
2493
2643
  return filterOption.code ? bindingifyGeneralHookFilter("code", filterOption.code) : void 0;
2494
2644
  }
2645
+ var init_bindingify_hook_filter = __esm({ "src/plugin/bindingify-hook-filter.ts"() {
2646
+ init_dist();
2647
+ init_misc();
2648
+ } });
2495
2649
 
2496
2650
  //#endregion
2497
2651
  //#region src/plugin/bindingify-plugin-hook-meta.ts
2498
- var import_binding$4 = __toESM(require_binding());
2499
2652
  function bindingifyPluginHookMeta(options) {
2500
2653
  return { order: bindingPluginOrder(options.order) };
2501
2654
  }
@@ -2508,6 +2661,10 @@ function bindingPluginOrder(order) {
2508
2661
  default: throw new Error(`Unknown plugin order: ${order}`);
2509
2662
  }
2510
2663
  }
2664
+ var import_binding$4;
2665
+ var init_bindingify_plugin_hook_meta = __esm({ "src/plugin/bindingify-plugin-hook-meta.ts"() {
2666
+ import_binding$4 = __toESM(require_binding());
2667
+ } });
2511
2668
 
2512
2669
  //#endregion
2513
2670
  //#region src/utils/asset-source.ts
@@ -2517,129 +2674,146 @@ function transformAssetSource(bindingAssetSource$1) {
2517
2674
  function bindingAssetSource(source) {
2518
2675
  return { inner: source };
2519
2676
  }
2677
+ var init_asset_source = __esm({ "src/utils/asset-source.ts"() {} });
2520
2678
 
2521
2679
  //#endregion
2522
2680
  //#region src/plugin/plugin-context.ts
2523
- var PluginContextImpl = class extends MinimalPluginContextImpl {
2524
- getModuleInfo;
2525
- constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2526
- super(onLog, logLevel, plugin.name, watchMode);
2527
- this.outputOptions = outputOptions;
2528
- this.context = context;
2529
- this.data = data;
2530
- this.onLog = onLog;
2531
- this.currentLoadingModule = currentLoadingModule;
2532
- this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
2533
- }
2534
- async load(options) {
2535
- const id = options.id;
2536
- if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2537
- const moduleInfo = this.data.getModuleInfo(id, this.context);
2538
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2539
- const rawOptions = {
2540
- meta: options.meta || {},
2541
- moduleSideEffects: options.moduleSideEffects || null,
2542
- invalidate: false
2543
- };
2544
- this.data.updateModuleOption(id, rawOptions);
2545
- async function createLoadModulePromise(context, data) {
2546
- const loadPromise = data.loadModulePromiseMap.get(id);
2547
- if (loadPromise) return loadPromise;
2548
- const promise$1 = new Promise((resolve, _) => {
2549
- data.loadModulePromiseResolveFnMap.set(id, resolve);
2550
- });
2551
- data.loadModulePromiseMap.set(id, promise$1);
2552
- try {
2553
- await context.load(id, bindingifySideEffects(options.moduleSideEffects));
2554
- } catch (e) {
2555
- data.loadModulePromiseMap.delete(id);
2556
- data.loadModulePromiseResolveFnMap.delete(id);
2557
- throw e;
2681
+ var PluginContextImpl;
2682
+ var init_plugin_context = __esm({ "src/plugin/plugin-context.ts"() {
2683
+ init_logging();
2684
+ init_logs();
2685
+ init_parse_ast_index();
2686
+ init_minimal_plugin_context();
2687
+ init_asset_source();
2688
+ init_misc();
2689
+ init_transform_side_effects();
2690
+ PluginContextImpl = class extends MinimalPluginContextImpl {
2691
+ getModuleInfo;
2692
+ constructor(outputOptions, context, plugin, data, onLog, logLevel, watchMode, currentLoadingModule) {
2693
+ super(onLog, logLevel, plugin.name, watchMode);
2694
+ this.outputOptions = outputOptions;
2695
+ this.context = context;
2696
+ this.data = data;
2697
+ this.onLog = onLog;
2698
+ this.currentLoadingModule = currentLoadingModule;
2699
+ this.getModuleInfo = (id) => this.data.getModuleInfo(id, context);
2700
+ }
2701
+ async load(options) {
2702
+ const id = options.id;
2703
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
2704
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
2705
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
2706
+ const rawOptions = {
2707
+ meta: options.meta || {},
2708
+ moduleSideEffects: options.moduleSideEffects || null,
2709
+ invalidate: false
2710
+ };
2711
+ this.data.updateModuleOption(id, rawOptions);
2712
+ async function createLoadModulePromise(context, data) {
2713
+ const loadPromise = data.loadModulePromiseMap.get(id);
2714
+ if (loadPromise) return loadPromise;
2715
+ const promise$1 = new Promise((resolve, _) => {
2716
+ data.loadModulePromiseResolveFnMap.set(id, resolve);
2717
+ });
2718
+ data.loadModulePromiseMap.set(id, promise$1);
2719
+ try {
2720
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects));
2721
+ } catch (e) {
2722
+ data.loadModulePromiseMap.delete(id);
2723
+ data.loadModulePromiseResolveFnMap.delete(id);
2724
+ throw e;
2725
+ }
2726
+ return promise$1;
2558
2727
  }
2559
- return promise$1;
2728
+ await createLoadModulePromise(this.context, this.data);
2729
+ return this.data.getModuleInfo(id, this.context);
2560
2730
  }
2561
- await createLoadModulePromise(this.context, this.data);
2562
- return this.data.getModuleInfo(id, this.context);
2563
- }
2564
- async resolve(source, importer, options) {
2565
- let receipt = void 0;
2566
- if (options != null) receipt = this.data.saveResolveOptions(options);
2567
- const res = await this.context.resolve(source, importer, {
2568
- custom: receipt,
2569
- skipSelf: options?.skipSelf
2570
- });
2571
- if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2572
- if (res == null) return null;
2573
- const info = this.data.getModuleOption(res.id) || {};
2574
- return {
2575
- ...res,
2576
- external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2577
- ...info
2731
+ async resolve(source, importer, options) {
2732
+ let receipt = void 0;
2733
+ if (options != null) receipt = this.data.saveResolveOptions(options);
2734
+ const res = await this.context.resolve(source, importer, {
2735
+ custom: receipt,
2736
+ skipSelf: options?.skipSelf
2737
+ });
2738
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
2739
+ if (res == null) return null;
2740
+ const info = this.data.getModuleOption(res.id) || {};
2741
+ return {
2742
+ ...res,
2743
+ external: res.external === "relative" ? unreachable(`The PluginContext resolve result external couldn't be 'relative'`) : res.external,
2744
+ ...info
2745
+ };
2746
+ }
2747
+ emitFile = (file) => {
2748
+ if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2749
+ if (file.type === "chunk") return this.context.emitChunk(file);
2750
+ const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2751
+ const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2752
+ return this.context.emitFile({
2753
+ ...file,
2754
+ originalFileName: file.originalFileName || void 0,
2755
+ source: bindingAssetSource(file.source)
2756
+ }, filename, fnSanitizedFileName);
2578
2757
  };
2579
- }
2580
- emitFile = (file) => {
2581
- if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
2582
- if (file.type === "chunk") return this.context.emitChunk(file);
2583
- const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== "function" ? void 0 : this.outputOptions.sanitizeFileName(file.name || "asset");
2584
- const filename = file.fileName ? void 0 : this.getAssetFileNames(file);
2585
- return this.context.emitFile({
2586
- ...file,
2587
- originalFileName: file.originalFileName || void 0,
2588
- source: bindingAssetSource(file.source)
2589
- }, filename, fnSanitizedFileName);
2758
+ getAssetFileNames(file) {
2759
+ if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2760
+ names: file.name ? [file.name] : [],
2761
+ originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2762
+ source: file.source,
2763
+ type: "asset"
2764
+ });
2765
+ }
2766
+ getFileName(referenceId) {
2767
+ return this.context.getFileName(referenceId);
2768
+ }
2769
+ getModuleIds() {
2770
+ return this.data.getModuleIds(this.context);
2771
+ }
2772
+ addWatchFile(id) {
2773
+ this.context.addWatchFile(id);
2774
+ }
2775
+ parse(input, options) {
2776
+ return parseAst(input, options);
2777
+ }
2590
2778
  };
2591
- getAssetFileNames(file) {
2592
- if (typeof this.outputOptions.assetFileNames === "function") return this.outputOptions.assetFileNames({
2593
- names: file.name ? [file.name] : [],
2594
- originalFileNames: file.originalFileName ? [file.originalFileName] : [],
2595
- source: file.source,
2596
- type: "asset"
2597
- });
2598
- }
2599
- getFileName(referenceId) {
2600
- return this.context.getFileName(referenceId);
2601
- }
2602
- getModuleIds() {
2603
- return this.data.getModuleIds(this.context);
2604
- }
2605
- addWatchFile(id) {
2606
- this.context.addWatchFile(id);
2607
- }
2608
- parse(input, options) {
2609
- return parseAst(input, options);
2610
- }
2611
- };
2779
+ } });
2612
2780
 
2613
2781
  //#endregion
2614
2782
  //#region src/plugin/transform-plugin-context.ts
2615
- var TransformPluginContextImpl = class extends PluginContextImpl {
2616
- constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2617
- super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2618
- this.inner = inner;
2619
- this.moduleId = moduleId;
2620
- this.moduleSource = moduleSource;
2621
- const getLogHandler$1 = (handler) => (log, pos) => {
2622
- log = normalizeLog(log);
2623
- if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2624
- log.id = moduleId;
2625
- log.hook = "transform";
2626
- handler(log);
2627
- };
2628
- this.debug = getLogHandler$1(this.debug);
2629
- this.warn = getLogHandler$1(this.warn);
2630
- this.info = getLogHandler$1(this.info);
2631
- }
2632
- error(e, pos) {
2633
- if (typeof e === "string") e = { message: e };
2634
- if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
2635
- e.id = this.moduleId;
2636
- e.hook = "transform";
2637
- return error(logPluginError(normalizeLog(e), this.pluginName));
2638
- }
2639
- getCombinedSourcemap() {
2640
- return JSON.parse(this.inner.getCombinedSourcemap());
2641
- }
2642
- };
2783
+ var TransformPluginContextImpl;
2784
+ var init_transform_plugin_context = __esm({ "src/plugin/transform-plugin-context.ts"() {
2785
+ init_log_handler();
2786
+ init_logs();
2787
+ init_plugin_context();
2788
+ TransformPluginContextImpl = class extends PluginContextImpl {
2789
+ constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption, watchMode) {
2790
+ super(outputOptions, context, plugin, data, onLog, LogLevelOption, watchMode, moduleId);
2791
+ this.inner = inner;
2792
+ this.moduleId = moduleId;
2793
+ this.moduleSource = moduleSource;
2794
+ const getLogHandler$1 = (handler) => (log, pos) => {
2795
+ log = normalizeLog(log);
2796
+ if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
2797
+ log.id = moduleId;
2798
+ log.hook = "transform";
2799
+ handler(log);
2800
+ };
2801
+ this.debug = getLogHandler$1(this.debug);
2802
+ this.warn = getLogHandler$1(this.warn);
2803
+ this.info = getLogHandler$1(this.info);
2804
+ }
2805
+ error(e, pos) {
2806
+ if (typeof e === "string") e = { message: e };
2807
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
2808
+ e.id = this.moduleId;
2809
+ e.hook = "transform";
2810
+ return error(logPluginError(normalizeLog(e), this.pluginName));
2811
+ }
2812
+ getCombinedSourcemap() {
2813
+ return JSON.parse(this.inner.getCombinedSourcemap());
2814
+ }
2815
+ };
2816
+ } });
2643
2817
 
2644
2818
  //#endregion
2645
2819
  //#region src/plugin/bindingify-build-hooks.ts
@@ -2804,6 +2978,20 @@ function bindingifyModuleParsed(args$1) {
2804
2978
  meta: bindingifyPluginHookMeta(meta)
2805
2979
  };
2806
2980
  }
2981
+ var init_bindingify_build_hooks = __esm({ "src/plugin/bindingify-build-hooks.ts"() {
2982
+ init_normalize_hook();
2983
+ init_plugin_context$1();
2984
+ init_normalized_input_options();
2985
+ init_sourcemap();
2986
+ init_error();
2987
+ init_transform_module_info();
2988
+ init_transform_side_effects();
2989
+ init_transform_sourcemap();
2990
+ init_bindingify_hook_filter();
2991
+ init_bindingify_plugin_hook_meta();
2992
+ init_plugin_context();
2993
+ init_transform_plugin_context();
2994
+ } });
2807
2995
 
2808
2996
  //#endregion
2809
2997
  //#region src/utils/transform-rendered-module.ts
@@ -2820,6 +3008,7 @@ function transformToRenderedModule(bindingRenderedModule) {
2820
3008
  }
2821
3009
  };
2822
3010
  }
3011
+ var init_transform_rendered_module = __esm({ "src/utils/transform-rendered-module.ts"() {} });
2823
3012
 
2824
3013
  //#endregion
2825
3014
  //#region src/utils/transform-rendered-chunk.ts
@@ -2869,6 +3058,9 @@ function transformChunkModules(modules) {
2869
3058
  }
2870
3059
  return result;
2871
3060
  }
3061
+ var init_transform_rendered_chunk = __esm({ "src/utils/transform-rendered-chunk.ts"() {
3062
+ init_transform_rendered_module();
3063
+ } });
2872
3064
 
2873
3065
  //#endregion
2874
3066
  //#region src/utils/bindingify-output-options.ts
@@ -2954,116 +3146,125 @@ function bindingifyAssetFilenames(assetFileNames) {
2954
3146
  };
2955
3147
  return assetFileNames;
2956
3148
  }
3149
+ var init_bindingify_output_options = __esm({ "src/utils/bindingify-output-options.ts"() {
3150
+ init_asset_source();
3151
+ init_misc();
3152
+ init_transform_rendered_chunk();
3153
+ } });
2957
3154
 
2958
3155
  //#endregion
2959
3156
  //#region src/options/normalized-output-options.ts
2960
- var NormalizedOutputOptionsImpl = class {
2961
- constructor(inner, outputOptions, normalizedOutputPlugins) {
2962
- this.inner = inner;
2963
- this.outputOptions = outputOptions;
2964
- this.normalizedOutputPlugins = normalizedOutputPlugins;
2965
- }
2966
- get dir() {
2967
- return this.inner.dir ?? void 0;
2968
- }
2969
- get entryFileNames() {
2970
- return this.inner.entryFilenames || this.outputOptions.entryFileNames;
2971
- }
2972
- get chunkFileNames() {
2973
- return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
2974
- }
2975
- get assetFileNames() {
2976
- return this.inner.assetFilenames || this.outputOptions.assetFileNames;
2977
- }
2978
- get format() {
2979
- return this.inner.format;
2980
- }
2981
- get exports() {
2982
- return this.inner.exports;
2983
- }
2984
- get sourcemap() {
2985
- return this.inner.sourcemap;
2986
- }
2987
- get cssEntryFileNames() {
2988
- return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
2989
- }
2990
- get cssChunkFileNames() {
2991
- return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
2992
- }
2993
- get shimMissingExports() {
2994
- return this.inner.shimMissingExports;
2995
- }
2996
- get name() {
2997
- return this.inner.name ?? void 0;
2998
- }
2999
- get file() {
3000
- return this.inner.file ?? void 0;
3001
- }
3002
- get inlineDynamicImports() {
3003
- return this.inner.inlineDynamicImports;
3004
- }
3005
- get externalLiveBindings() {
3006
- return this.inner.externalLiveBindings;
3007
- }
3008
- get banner() {
3009
- return normalizeAddon(this.outputOptions.banner);
3010
- }
3011
- get footer() {
3012
- return normalizeAddon(this.outputOptions.footer);
3013
- }
3014
- get intro() {
3015
- return normalizeAddon(this.outputOptions.intro);
3016
- }
3017
- get outro() {
3018
- return normalizeAddon(this.outputOptions.outro);
3019
- }
3020
- get esModule() {
3021
- return this.inner.esModule;
3022
- }
3023
- get extend() {
3024
- return this.inner.extend;
3025
- }
3026
- get globals() {
3027
- return this.inner.globals || this.outputOptions.globals;
3028
- }
3029
- get hashCharacters() {
3030
- return this.inner.hashCharacters;
3031
- }
3032
- get sourcemapDebugIds() {
3033
- return this.inner.sourcemapDebugIds;
3034
- }
3035
- get sourcemapIgnoreList() {
3036
- return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3037
- }
3038
- get sourcemapPathTransform() {
3039
- return this.outputOptions.sourcemapPathTransform;
3040
- }
3041
- get minify() {
3042
- return this.inner.minify;
3043
- }
3044
- get legalComments() {
3045
- return this.inner.legalComments;
3046
- }
3047
- get polyfillRequire() {
3048
- return this.inner.polyfillRequire;
3049
- }
3050
- get plugins() {
3051
- return this.normalizedOutputPlugins;
3052
- }
3053
- get preserveModules() {
3054
- return this.preserveModules;
3055
- }
3056
- get preserveModulesRoot() {
3057
- return this.preserveModulesRoot;
3058
- }
3059
- get virtualDirname() {
3060
- return this.virtualDirname;
3061
- }
3062
- };
3063
3157
  function normalizeAddon(value) {
3064
3158
  if (typeof value === "function") return value;
3065
3159
  return () => value || "";
3066
3160
  }
3161
+ var NormalizedOutputOptionsImpl;
3162
+ var init_normalized_output_options = __esm({ "src/options/normalized-output-options.ts"() {
3163
+ init_bindingify_output_options();
3164
+ NormalizedOutputOptionsImpl = class {
3165
+ constructor(inner, outputOptions, normalizedOutputPlugins) {
3166
+ this.inner = inner;
3167
+ this.outputOptions = outputOptions;
3168
+ this.normalizedOutputPlugins = normalizedOutputPlugins;
3169
+ }
3170
+ get dir() {
3171
+ return this.inner.dir ?? void 0;
3172
+ }
3173
+ get entryFileNames() {
3174
+ return this.inner.entryFilenames || this.outputOptions.entryFileNames;
3175
+ }
3176
+ get chunkFileNames() {
3177
+ return this.inner.chunkFilenames || this.outputOptions.chunkFileNames;
3178
+ }
3179
+ get assetFileNames() {
3180
+ return this.inner.assetFilenames || this.outputOptions.assetFileNames;
3181
+ }
3182
+ get format() {
3183
+ return this.inner.format;
3184
+ }
3185
+ get exports() {
3186
+ return this.inner.exports;
3187
+ }
3188
+ get sourcemap() {
3189
+ return this.inner.sourcemap;
3190
+ }
3191
+ get cssEntryFileNames() {
3192
+ return this.inner.cssEntryFilenames || this.outputOptions.cssEntryFileNames;
3193
+ }
3194
+ get cssChunkFileNames() {
3195
+ return this.inner.cssChunkFilenames || this.outputOptions.cssChunkFileNames;
3196
+ }
3197
+ get shimMissingExports() {
3198
+ return this.inner.shimMissingExports;
3199
+ }
3200
+ get name() {
3201
+ return this.inner.name ?? void 0;
3202
+ }
3203
+ get file() {
3204
+ return this.inner.file ?? void 0;
3205
+ }
3206
+ get inlineDynamicImports() {
3207
+ return this.inner.inlineDynamicImports;
3208
+ }
3209
+ get externalLiveBindings() {
3210
+ return this.inner.externalLiveBindings;
3211
+ }
3212
+ get banner() {
3213
+ return normalizeAddon(this.outputOptions.banner);
3214
+ }
3215
+ get footer() {
3216
+ return normalizeAddon(this.outputOptions.footer);
3217
+ }
3218
+ get intro() {
3219
+ return normalizeAddon(this.outputOptions.intro);
3220
+ }
3221
+ get outro() {
3222
+ return normalizeAddon(this.outputOptions.outro);
3223
+ }
3224
+ get esModule() {
3225
+ return this.inner.esModule;
3226
+ }
3227
+ get extend() {
3228
+ return this.inner.extend;
3229
+ }
3230
+ get globals() {
3231
+ return this.inner.globals || this.outputOptions.globals;
3232
+ }
3233
+ get hashCharacters() {
3234
+ return this.inner.hashCharacters;
3235
+ }
3236
+ get sourcemapDebugIds() {
3237
+ return this.inner.sourcemapDebugIds;
3238
+ }
3239
+ get sourcemapIgnoreList() {
3240
+ return bindingifySourcemapIgnoreList(this.outputOptions.sourcemapIgnoreList);
3241
+ }
3242
+ get sourcemapPathTransform() {
3243
+ return this.outputOptions.sourcemapPathTransform;
3244
+ }
3245
+ get minify() {
3246
+ return this.inner.minify;
3247
+ }
3248
+ get legalComments() {
3249
+ return this.inner.legalComments;
3250
+ }
3251
+ get polyfillRequire() {
3252
+ return this.inner.polyfillRequire;
3253
+ }
3254
+ get plugins() {
3255
+ return this.normalizedOutputPlugins;
3256
+ }
3257
+ get preserveModules() {
3258
+ return this.preserveModules;
3259
+ }
3260
+ get preserveModulesRoot() {
3261
+ return this.preserveModulesRoot;
3262
+ }
3263
+ get virtualDirname() {
3264
+ return this.virtualDirname;
3265
+ }
3266
+ };
3267
+ } });
3067
3268
 
3068
3269
  //#endregion
3069
3270
  //#region src/utils/transform-to-rollup-output.ts
@@ -3207,6 +3408,12 @@ function collectChangedBundle(changed, bundle) {
3207
3408
  deleted: Array.from(changed.deleted)
3208
3409
  };
3209
3410
  }
3411
+ var init_transform_to_rollup_output = __esm({ "src/utils/transform-to-rollup-output.ts"() {
3412
+ init_sourcemap();
3413
+ init_asset_source();
3414
+ init_error();
3415
+ init_transform_rendered_chunk();
3416
+ } });
3210
3417
 
3211
3418
  //#endregion
3212
3419
  //#region src/plugin/bindingify-output-hooks.ts
@@ -3356,6 +3563,18 @@ function bindingifyOutro(args$1) {
3356
3563
  meta: bindingifyPluginHookMeta(meta)
3357
3564
  };
3358
3565
  }
3566
+ var init_bindingify_output_hooks = __esm({ "src/plugin/bindingify-output-hooks.ts"() {
3567
+ init_normalized_input_options();
3568
+ init_normalized_output_options();
3569
+ init_sourcemap();
3570
+ init_error();
3571
+ init_normalize_hook();
3572
+ init_transform_rendered_chunk();
3573
+ init_transform_to_rollup_output();
3574
+ init_bindingify_hook_filter();
3575
+ init_bindingify_plugin_hook_meta();
3576
+ init_plugin_context();
3577
+ } });
3359
3578
 
3360
3579
  //#endregion
3361
3580
  //#region src/plugin/bindingify-watch-hooks.ts
@@ -3381,43 +3600,14 @@ function bindingifyCloseWatcher(args$1) {
3381
3600
  meta: bindingifyPluginHookMeta(meta)
3382
3601
  };
3383
3602
  }
3603
+ var init_bindingify_watch_hooks = __esm({ "src/plugin/bindingify-watch-hooks.ts"() {
3604
+ init_normalize_hook();
3605
+ init_bindingify_plugin_hook_meta();
3606
+ init_plugin_context();
3607
+ } });
3384
3608
 
3385
3609
  //#endregion
3386
3610
  //#region src/plugin/generated/hook-usage.ts
3387
- let HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3388
- HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3389
- HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3390
- HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3391
- HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3392
- HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3393
- HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3394
- HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3395
- HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3396
- HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3397
- HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3398
- HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3399
- HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3400
- HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3401
- HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3402
- HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3403
- HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3404
- HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3405
- HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3406
- HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3407
- HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3408
- HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3409
- return HookUsageKind$1;
3410
- }({});
3411
- var HookUsage = class {
3412
- bitflag = BigInt(0);
3413
- constructor() {}
3414
- union(kind) {
3415
- this.bitflag |= BigInt(kind);
3416
- }
3417
- inner() {
3418
- return Number(this.bitflag);
3419
- }
3420
- };
3421
3611
  function extractHookUsage(plugin) {
3422
3612
  let hookUsage = new HookUsage();
3423
3613
  if (plugin.buildStart) hookUsage.union(HookUsageKind.buildStart);
@@ -3442,6 +3632,43 @@ function extractHookUsage(plugin) {
3442
3632
  if (plugin.outro) hookUsage.union(HookUsageKind.outro);
3443
3633
  return hookUsage;
3444
3634
  }
3635
+ var HookUsageKind, HookUsage;
3636
+ var init_hook_usage = __esm({ "src/plugin/generated/hook-usage.ts"() {
3637
+ HookUsageKind = /* @__PURE__ */ function(HookUsageKind$1) {
3638
+ HookUsageKind$1[HookUsageKind$1["buildStart"] = 1] = "buildStart";
3639
+ HookUsageKind$1[HookUsageKind$1["resolveId"] = 2] = "resolveId";
3640
+ HookUsageKind$1[HookUsageKind$1["resolveDynamicImport"] = 4] = "resolveDynamicImport";
3641
+ HookUsageKind$1[HookUsageKind$1["load"] = 8] = "load";
3642
+ HookUsageKind$1[HookUsageKind$1["transform"] = 16] = "transform";
3643
+ HookUsageKind$1[HookUsageKind$1["moduleParsed"] = 32] = "moduleParsed";
3644
+ HookUsageKind$1[HookUsageKind$1["buildEnd"] = 64] = "buildEnd";
3645
+ HookUsageKind$1[HookUsageKind$1["renderStart"] = 128] = "renderStart";
3646
+ HookUsageKind$1[HookUsageKind$1["renderError"] = 256] = "renderError";
3647
+ HookUsageKind$1[HookUsageKind$1["renderChunk"] = 512] = "renderChunk";
3648
+ HookUsageKind$1[HookUsageKind$1["augmentChunkHash"] = 1024] = "augmentChunkHash";
3649
+ HookUsageKind$1[HookUsageKind$1["generateBundle"] = 2048] = "generateBundle";
3650
+ HookUsageKind$1[HookUsageKind$1["writeBundle"] = 4096] = "writeBundle";
3651
+ HookUsageKind$1[HookUsageKind$1["closeBundle"] = 8192] = "closeBundle";
3652
+ HookUsageKind$1[HookUsageKind$1["watchChange"] = 16384] = "watchChange";
3653
+ HookUsageKind$1[HookUsageKind$1["closeWatcher"] = 32768] = "closeWatcher";
3654
+ HookUsageKind$1[HookUsageKind$1["transformAst"] = 65536] = "transformAst";
3655
+ HookUsageKind$1[HookUsageKind$1["banner"] = 131072] = "banner";
3656
+ HookUsageKind$1[HookUsageKind$1["footer"] = 262144] = "footer";
3657
+ HookUsageKind$1[HookUsageKind$1["intro"] = 524288] = "intro";
3658
+ HookUsageKind$1[HookUsageKind$1["outro"] = 1048576] = "outro";
3659
+ return HookUsageKind$1;
3660
+ }({});
3661
+ HookUsage = class {
3662
+ bitflag = BigInt(0);
3663
+ constructor() {}
3664
+ union(kind) {
3665
+ this.bitflag |= BigInt(kind);
3666
+ }
3667
+ inner() {
3668
+ return Number(this.bitflag);
3669
+ }
3670
+ };
3671
+ } });
3445
3672
 
3446
3673
  //#endregion
3447
3674
  //#region src/plugin/bindingify-plugin.ts
@@ -3564,95 +3791,106 @@ function wrapHandlers(plugin) {
3564
3791
  }
3565
3792
  return plugin;
3566
3793
  }
3794
+ var init_bindingify_plugin = __esm({ "src/plugin/bindingify-plugin.ts"() {
3795
+ init_bindingify_build_hooks();
3796
+ init_bindingify_output_hooks();
3797
+ init_logs();
3798
+ init_bindingify_watch_hooks();
3799
+ init_hook_usage();
3800
+ } });
3567
3801
 
3568
3802
  //#endregion
3569
3803
  //#region src/plugin/plugin-context-data.ts
3570
- var PluginContextData = class {
3571
- moduleOptionMap = /* @__PURE__ */ new Map();
3572
- resolveOptionsMap = /* @__PURE__ */ new Map();
3573
- loadModulePromiseMap = /* @__PURE__ */ new Map();
3574
- loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3575
- renderedChunkMeta = null;
3576
- updateModuleOption(id, option) {
3577
- const existing = this.moduleOptionMap.get(id);
3578
- if (existing) {
3579
- if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3580
- if (option.meta != null) Object.assign(existing.meta, option.meta);
3581
- if (option.invalidate != null) existing.invalidate = option.invalidate;
3582
- } else {
3583
- this.moduleOptionMap.set(id, option);
3804
+ var PluginContextData;
3805
+ var init_plugin_context_data = __esm({ "src/plugin/plugin-context-data.ts"() {
3806
+ init_transform_module_info();
3807
+ PluginContextData = class {
3808
+ moduleOptionMap = /* @__PURE__ */ new Map();
3809
+ resolveOptionsMap = /* @__PURE__ */ new Map();
3810
+ loadModulePromiseMap = /* @__PURE__ */ new Map();
3811
+ loadModulePromiseResolveFnMap = /* @__PURE__ */ new Map();
3812
+ renderedChunkMeta = null;
3813
+ updateModuleOption(id, option) {
3814
+ const existing = this.moduleOptionMap.get(id);
3815
+ if (existing) {
3816
+ if (option.moduleSideEffects != null) existing.moduleSideEffects = option.moduleSideEffects;
3817
+ if (option.meta != null) Object.assign(existing.meta, option.meta);
3818
+ if (option.invalidate != null) existing.invalidate = option.invalidate;
3819
+ } else {
3820
+ this.moduleOptionMap.set(id, option);
3821
+ return option;
3822
+ }
3823
+ return existing;
3824
+ }
3825
+ getModuleOption(id) {
3826
+ const option = this.moduleOptionMap.get(id);
3827
+ if (!option) {
3828
+ const raw = {
3829
+ moduleSideEffects: null,
3830
+ meta: {}
3831
+ };
3832
+ this.moduleOptionMap.set(id, raw);
3833
+ return raw;
3834
+ }
3584
3835
  return option;
3585
3836
  }
3586
- return existing;
3587
- }
3588
- getModuleOption(id) {
3589
- const option = this.moduleOptionMap.get(id);
3590
- if (!option) {
3591
- const raw = {
3592
- moduleSideEffects: null,
3593
- meta: {}
3594
- };
3595
- this.moduleOptionMap.set(id, raw);
3596
- return raw;
3837
+ getModuleInfo(id, context) {
3838
+ const bindingInfo = context.getModuleInfo(id);
3839
+ if (bindingInfo) {
3840
+ const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
3841
+ return this.proxyModuleInfo(id, info);
3842
+ }
3843
+ return null;
3597
3844
  }
3598
- return option;
3599
- }
3600
- getModuleInfo(id, context) {
3601
- const bindingInfo = context.getModuleInfo(id);
3602
- if (bindingInfo) {
3603
- const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
3604
- return this.proxyModuleInfo(id, info);
3845
+ proxyModuleInfo(id, info) {
3846
+ let moduleSideEffects = info.moduleSideEffects;
3847
+ Object.defineProperty(info, "moduleSideEffects", {
3848
+ get() {
3849
+ return moduleSideEffects;
3850
+ },
3851
+ set: (v) => {
3852
+ this.updateModuleOption(id, {
3853
+ moduleSideEffects: v,
3854
+ meta: info.meta,
3855
+ invalidate: true
3856
+ });
3857
+ moduleSideEffects = v;
3858
+ }
3859
+ });
3860
+ return info;
3605
3861
  }
3606
- return null;
3607
- }
3608
- proxyModuleInfo(id, info) {
3609
- let moduleSideEffects = info.moduleSideEffects;
3610
- Object.defineProperty(info, "moduleSideEffects", {
3611
- get() {
3612
- return moduleSideEffects;
3613
- },
3614
- set: (v) => {
3615
- this.updateModuleOption(id, {
3616
- moduleSideEffects: v,
3617
- meta: info.meta,
3618
- invalidate: true
3619
- });
3620
- moduleSideEffects = v;
3621
- }
3622
- });
3623
- return info;
3624
- }
3625
- getModuleIds(context) {
3626
- const moduleIds = context.getModuleIds();
3627
- return moduleIds.values();
3628
- }
3629
- saveResolveOptions(options) {
3630
- const index = this.resolveOptionsMap.size;
3631
- this.resolveOptionsMap.set(index, options);
3632
- return index;
3633
- }
3634
- getSavedResolveOptions(receipt) {
3635
- return this.resolveOptionsMap.get(receipt);
3636
- }
3637
- removeSavedResolveOptions(receipt) {
3638
- this.resolveOptionsMap.delete(receipt);
3639
- }
3640
- setRenderChunkMeta(meta) {
3641
- this.renderedChunkMeta = meta;
3642
- }
3643
- getRenderChunkMeta() {
3644
- return this.renderedChunkMeta;
3645
- }
3646
- markModuleLoaded(id, _success) {
3647
- const resolve = this.loadModulePromiseResolveFnMap.get(id);
3648
- if (resolve) resolve();
3649
- }
3650
- clear() {
3651
- this.renderedChunkMeta = null;
3652
- this.loadModulePromiseMap.clear();
3653
- this.loadModulePromiseResolveFnMap.clear();
3654
- }
3655
- };
3862
+ getModuleIds(context) {
3863
+ const moduleIds = context.getModuleIds();
3864
+ return moduleIds.values();
3865
+ }
3866
+ saveResolveOptions(options) {
3867
+ const index = this.resolveOptionsMap.size;
3868
+ this.resolveOptionsMap.set(index, options);
3869
+ return index;
3870
+ }
3871
+ getSavedResolveOptions(receipt) {
3872
+ return this.resolveOptionsMap.get(receipt);
3873
+ }
3874
+ removeSavedResolveOptions(receipt) {
3875
+ this.resolveOptionsMap.delete(receipt);
3876
+ }
3877
+ setRenderChunkMeta(meta) {
3878
+ this.renderedChunkMeta = meta;
3879
+ }
3880
+ getRenderChunkMeta() {
3881
+ return this.renderedChunkMeta;
3882
+ }
3883
+ markModuleLoaded(id, _success) {
3884
+ const resolve = this.loadModulePromiseResolveFnMap.get(id);
3885
+ if (resolve) resolve();
3886
+ }
3887
+ clear() {
3888
+ this.renderedChunkMeta = null;
3889
+ this.loadModulePromiseMap.clear();
3890
+ this.loadModulePromiseResolveFnMap.clear();
3891
+ }
3892
+ };
3893
+ } });
3656
3894
 
3657
3895
  //#endregion
3658
3896
  //#region src/utils/normalize-string-or-regex.ts
@@ -3664,10 +3902,10 @@ function normalizedStringOrRegex(pattern) {
3664
3902
  function isReadonlyArray(input) {
3665
3903
  return Array.isArray(input);
3666
3904
  }
3905
+ var init_normalize_string_or_regex = __esm({ "src/utils/normalize-string-or-regex.ts"() {} });
3667
3906
 
3668
3907
  //#endregion
3669
3908
  //#region src/utils/bindingify-input-options.ts
3670
- var import_binding$3 = __toESM(require_binding());
3671
3909
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3672
3910
  const pluginContextData = new PluginContextData();
3673
3911
  const plugins = rawPlugins.map((plugin) => {
@@ -3855,31 +4093,33 @@ function bindingifyMakeAbsoluteExternalsRelative(makeAbsoluteExternalsRelative)
3855
4093
  field0: makeAbsoluteExternalsRelative
3856
4094
  };
3857
4095
  }
4096
+ var import_binding$3;
4097
+ var init_bindingify_input_options = __esm({ "src/utils/bindingify-input-options.ts"() {
4098
+ import_binding$3 = __toESM(require_binding());
4099
+ init_constructors();
4100
+ init_utils();
4101
+ init_bindingify_plugin();
4102
+ init_plugin_context_data();
4103
+ init_misc();
4104
+ init_normalize_string_or_regex();
4105
+ init_transform_side_effects();
4106
+ } });
3858
4107
 
3859
4108
  //#endregion
3860
4109
  //#region src/utils/plugin/index.ts
3861
- const isPluginHookName = function() {
3862
- const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
3863
- return function isPluginHookName$1(hookName) {
3864
- return PLUGIN_HOOK_NAMES_SET.has(hookName);
3865
- };
3866
- }();
4110
+ var isPluginHookName;
4111
+ var init_plugin = __esm({ "src/utils/plugin/index.ts"() {
4112
+ init_plugin$1();
4113
+ isPluginHookName = function() {
4114
+ const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
4115
+ return function isPluginHookName$1(hookName) {
4116
+ return PLUGIN_HOOK_NAMES_SET.has(hookName);
4117
+ };
4118
+ }();
4119
+ } });
3867
4120
 
3868
4121
  //#endregion
3869
4122
  //#region src/utils/compose-js-plugins.ts
3870
- const unsupportedHookName = [
3871
- "augmentChunkHash",
3872
- "generateBundle",
3873
- "moduleParsed",
3874
- "onLog",
3875
- "options",
3876
- "outputOptions",
3877
- "renderError",
3878
- "renderStart",
3879
- "resolveDynamicImport",
3880
- "writeBundle"
3881
- ];
3882
- const unsupportedHooks = new Set(unsupportedHookName);
3883
4123
  function isUnsupportedHooks(hookName) {
3884
4124
  return unsupportedHooks.has(hookName);
3885
4125
  }
@@ -4172,10 +4412,31 @@ function composeJsPlugins(plugins) {
4172
4412
  }
4173
4413
  return newPlugins;
4174
4414
  }
4415
+ var unsupportedHookName, unsupportedHooks;
4416
+ var init_compose_js_plugins = __esm({ "src/utils/compose-js-plugins.ts"() {
4417
+ init_dist();
4418
+ init_constructors();
4419
+ init_plugin_context$1();
4420
+ init_misc();
4421
+ init_normalize_hook();
4422
+ init_plugin();
4423
+ unsupportedHookName = [
4424
+ "augmentChunkHash",
4425
+ "generateBundle",
4426
+ "moduleParsed",
4427
+ "onLog",
4428
+ "options",
4429
+ "outputOptions",
4430
+ "renderError",
4431
+ "renderStart",
4432
+ "resolveDynamicImport",
4433
+ "writeBundle"
4434
+ ];
4435
+ unsupportedHooks = new Set(unsupportedHookName);
4436
+ } });
4175
4437
 
4176
4438
  //#endregion
4177
4439
  //#region src/utils/initialize-parallel-plugins.ts
4178
- var import_binding$2 = __toESM(require_binding());
4179
4440
  async function initializeParallelPlugins(plugins) {
4180
4441
  const pluginInfos = [];
4181
4442
  for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
@@ -4225,16 +4486,20 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
4225
4486
  throw e;
4226
4487
  }
4227
4488
  }
4228
- const availableParallelism = () => {
4229
- let availableParallelism$1 = 1;
4230
- try {
4231
- availableParallelism$1 = os.availableParallelism();
4232
- } catch {
4233
- const cpus = os.cpus();
4234
- if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4235
- }
4236
- return Math.min(availableParallelism$1, 8);
4237
- };
4489
+ var import_binding$2, availableParallelism;
4490
+ var init_initialize_parallel_plugins = __esm({ "src/utils/initialize-parallel-plugins.ts"() {
4491
+ import_binding$2 = __toESM(require_binding());
4492
+ availableParallelism = () => {
4493
+ let availableParallelism$1 = 1;
4494
+ try {
4495
+ availableParallelism$1 = os.availableParallelism();
4496
+ } catch {
4497
+ const cpus = os.cpus();
4498
+ if (Array.isArray(cpus) && cpus.length > 0) availableParallelism$1 = cpus.length;
4499
+ }
4500
+ return Math.min(availableParallelism$1, 8);
4501
+ };
4502
+ } });
4238
4503
 
4239
4504
  //#endregion
4240
4505
  //#region src/utils/create-bundler-option.ts
@@ -4270,11 +4535,19 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4270
4535
  throw e;
4271
4536
  }
4272
4537
  }
4538
+ var init_create_bundler_option = __esm({ "src/utils/create-bundler-option.ts"() {
4539
+ init_logger();
4540
+ init_logging();
4541
+ init_plugin_driver();
4542
+ init_bindingify_input_options();
4543
+ init_bindingify_output_options();
4544
+ init_compose_js_plugins();
4545
+ init_initialize_parallel_plugins();
4546
+ init_normalize_plugin_option();
4547
+ } });
4273
4548
 
4274
4549
  //#endregion
4275
4550
  //#region src/utils/create-bundler.ts
4276
- var import_binding$1 = __toESM(require_binding());
4277
- let asyncRuntimeShutdown = false;
4278
4551
  async function createBundler(inputOptions, outputOptions, isClose) {
4279
4552
  const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
4280
4553
  if (asyncRuntimeShutdown) (0, import_binding$1.startAsyncRuntime)();
@@ -4292,62 +4565,80 @@ async function createBundler(inputOptions, outputOptions, isClose) {
4292
4565
  throw e;
4293
4566
  }
4294
4567
  }
4568
+ var import_binding$1, asyncRuntimeShutdown;
4569
+ var init_create_bundler = __esm({ "src/utils/create-bundler.ts"() {
4570
+ import_binding$1 = __toESM(require_binding());
4571
+ init_create_bundler_option();
4572
+ asyncRuntimeShutdown = false;
4573
+ } });
4295
4574
 
4296
4575
  //#endregion
4297
4576
  //#region src/api/rolldown/rolldown-build.ts
4298
- Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4299
- var RolldownBuild = class {
4300
- #inputOptions;
4301
- #bundler;
4302
- constructor(inputOptions) {
4303
- this.#inputOptions = inputOptions;
4304
- }
4305
- get closed() {
4306
- return this.#bundler?.bundler.closed ?? false;
4307
- }
4308
- async #getBundlerWithStopWorker(outputOptions, isClose) {
4309
- if (this.#bundler) await this.#bundler.stopWorkers?.();
4310
- return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
4311
- }
4312
- async generate(outputOptions = {}) {
4313
- validateOption("output", outputOptions);
4314
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4315
- const output = await bundler.generate();
4316
- return transformToRollupOutput(output);
4317
- }
4318
- async write(outputOptions = {}) {
4319
- validateOption("output", outputOptions);
4320
- const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4321
- const output = await bundler.write();
4322
- return transformToRollupOutput(output);
4323
- }
4324
- async close() {
4325
- const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4326
- await stopWorkers?.();
4327
- await bundler.close();
4328
- shutdown();
4329
- }
4330
- async [Symbol.asyncDispose]() {
4331
- await this.close();
4332
- }
4333
- async generateHmrPatch(changedFiles) {
4334
- return this.#bundler?.bundler.generateHmrPatch(changedFiles);
4335
- }
4336
- async hmrInvalidate(file, firstInvalidatedBy) {
4337
- return this.#bundler?.bundler.hmrInvalidate(file, firstInvalidatedBy);
4338
- }
4339
- get watchFiles() {
4340
- return this.#bundler?.bundler.getWatchFiles() ?? Promise.resolve([]);
4341
- }
4342
- };
4577
+ var RolldownBuild;
4578
+ var init_rolldown_build = __esm({ "src/api/rolldown/rolldown-build.ts"() {
4579
+ init_create_bundler();
4580
+ init_transform_to_rollup_output();
4581
+ init_validator();
4582
+ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4583
+ RolldownBuild = class {
4584
+ #inputOptions;
4585
+ #bundler;
4586
+ constructor(inputOptions) {
4587
+ this.#inputOptions = inputOptions;
4588
+ }
4589
+ get closed() {
4590
+ return this.#bundler?.bundler.closed ?? false;
4591
+ }
4592
+ async #getBundlerWithStopWorker(outputOptions, isClose) {
4593
+ if (this.#bundler) await this.#bundler.stopWorkers?.();
4594
+ return this.#bundler = await createBundler(this.#inputOptions, outputOptions, isClose);
4595
+ }
4596
+ async generate(outputOptions = {}) {
4597
+ validateOption("output", outputOptions);
4598
+ const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4599
+ const output = await bundler.generate();
4600
+ return transformToRollupOutput(output);
4601
+ }
4602
+ async write(outputOptions = {}) {
4603
+ validateOption("output", outputOptions);
4604
+ const { bundler } = await this.#getBundlerWithStopWorker(outputOptions);
4605
+ const output = await bundler.write();
4606
+ return transformToRollupOutput(output);
4607
+ }
4608
+ async close() {
4609
+ const { bundler, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4610
+ await stopWorkers?.();
4611
+ await bundler.close();
4612
+ shutdown();
4613
+ }
4614
+ async [Symbol.asyncDispose]() {
4615
+ await this.close();
4616
+ }
4617
+ async generateHmrPatch(changedFiles) {
4618
+ return this.#bundler?.bundler.generateHmrPatch(changedFiles);
4619
+ }
4620
+ async hmrInvalidate(file, firstInvalidatedBy) {
4621
+ return this.#bundler?.bundler.hmrInvalidate(file, firstInvalidatedBy);
4622
+ }
4623
+ get watchFiles() {
4624
+ return this.#bundler?.bundler.getWatchFiles() ?? Promise.resolve([]);
4625
+ }
4626
+ };
4627
+ } });
4343
4628
 
4344
4629
  //#endregion
4345
4630
  //#region src/api/rolldown/index.ts
4346
- const rolldown = async (input) => {
4347
- validateOption("input", input);
4348
- const inputOptions = await PluginDriver.callOptionsHook(input);
4349
- return new RolldownBuild(inputOptions);
4350
- };
4631
+ var rolldown;
4632
+ var init_rolldown = __esm({ "src/api/rolldown/index.ts"() {
4633
+ init_plugin_driver();
4634
+ init_validator();
4635
+ init_rolldown_build();
4636
+ rolldown = async (input) => {
4637
+ validateOption("input", input);
4638
+ const inputOptions = await PluginDriver.callOptionsHook(input);
4639
+ return new RolldownBuild(inputOptions);
4640
+ };
4641
+ } });
4351
4642
 
4352
4643
  //#endregion
4353
4644
  //#region src/api/build.ts
@@ -4364,107 +4655,86 @@ async function build(options) {
4364
4655
  }
4365
4656
  }
4366
4657
  }
4658
+ var init_build = __esm({ "src/api/build.ts"() {
4659
+ init_rolldown();
4660
+ } });
4367
4661
 
4368
4662
  //#endregion
4369
4663
  //#region src/api/watch/watch-emitter.ts
4370
- var WatcherEmitter = class {
4371
- listeners = /* @__PURE__ */ new Map();
4372
- timer;
4373
- constructor() {
4374
- this.timer = setInterval(() => {}, 1e9);
4375
- }
4376
- on(event, listener) {
4377
- const listeners = this.listeners.get(event);
4378
- if (listeners) listeners.push(listener);
4379
- else this.listeners.set(event, [listener]);
4380
- return this;
4381
- }
4382
- off(event, listener) {
4383
- const listeners = this.listeners.get(event);
4384
- if (listeners) {
4385
- const index = listeners.indexOf(listener);
4386
- if (index !== -1) listeners.splice(index, 1);
4664
+ var WatcherEmitter;
4665
+ var init_watch_emitter = __esm({ "src/api/watch/watch-emitter.ts"() {
4666
+ init_error();
4667
+ WatcherEmitter = class {
4668
+ listeners = /* @__PURE__ */ new Map();
4669
+ timer;
4670
+ constructor() {
4671
+ this.timer = setInterval(() => {}, 1e9);
4387
4672
  }
4388
- return this;
4389
- }
4390
- async onEvent(event) {
4391
- const listeners = this.listeners.get(event.eventKind());
4392
- if (listeners) switch (event.eventKind()) {
4393
- case "close":
4394
- case "restart":
4395
- for (const listener of listeners) await listener();
4396
- break;
4397
- case "event":
4398
- for (const listener of listeners) {
4399
- const code = event.bundleEventKind();
4400
- switch (code) {
4401
- case "BUNDLE_END":
4402
- const { duration, output, result } = event.bundleEndData();
4403
- await listener({
4404
- code: "BUNDLE_END",
4405
- duration,
4406
- output: [output],
4407
- result
4408
- });
4409
- break;
4410
- case "ERROR":
4411
- const data = event.bundleErrorData();
4412
- await listener({
4413
- code: "ERROR",
4414
- error: normalizeErrors(data.error),
4415
- result: data.result
4416
- });
4417
- break;
4418
- default:
4419
- await listener({ code });
4420
- break;
4673
+ on(event, listener) {
4674
+ const listeners = this.listeners.get(event);
4675
+ if (listeners) listeners.push(listener);
4676
+ else this.listeners.set(event, [listener]);
4677
+ return this;
4678
+ }
4679
+ off(event, listener) {
4680
+ const listeners = this.listeners.get(event);
4681
+ if (listeners) {
4682
+ const index = listeners.indexOf(listener);
4683
+ if (index !== -1) listeners.splice(index, 1);
4684
+ }
4685
+ return this;
4686
+ }
4687
+ async onEvent(event) {
4688
+ const listeners = this.listeners.get(event.eventKind());
4689
+ if (listeners) switch (event.eventKind()) {
4690
+ case "close":
4691
+ case "restart":
4692
+ for (const listener of listeners) await listener();
4693
+ break;
4694
+ case "event":
4695
+ for (const listener of listeners) {
4696
+ const code = event.bundleEventKind();
4697
+ switch (code) {
4698
+ case "BUNDLE_END":
4699
+ const { duration, output, result } = event.bundleEndData();
4700
+ await listener({
4701
+ code: "BUNDLE_END",
4702
+ duration,
4703
+ output: [output],
4704
+ result
4705
+ });
4706
+ break;
4707
+ case "ERROR":
4708
+ const data = event.bundleErrorData();
4709
+ await listener({
4710
+ code: "ERROR",
4711
+ error: normalizeErrors(data.error),
4712
+ result: data.result
4713
+ });
4714
+ break;
4715
+ default:
4716
+ await listener({ code });
4717
+ break;
4718
+ }
4421
4719
  }
4422
- }
4423
- break;
4424
- case "change":
4425
- for (const listener of listeners) {
4426
- const { path: path$1, kind } = event.watchChangeData();
4427
- await listener(path$1, { event: kind });
4428
- }
4429
- break;
4430
- default: throw new Error(`Unknown event: ${event}`);
4720
+ break;
4721
+ case "change":
4722
+ for (const listener of listeners) {
4723
+ const { path: path$1, kind } = event.watchChangeData();
4724
+ await listener(path$1, { event: kind });
4725
+ }
4726
+ break;
4727
+ default: throw new Error(`Unknown event: ${event}`);
4728
+ }
4431
4729
  }
4432
- }
4433
- async close() {
4434
- clearInterval(this.timer);
4435
- }
4436
- };
4730
+ async close() {
4731
+ clearInterval(this.timer);
4732
+ }
4733
+ };
4734
+ } });
4437
4735
 
4438
4736
  //#endregion
4439
4737
  //#region src/api/watch/watcher.ts
4440
- var import_binding = __toESM(require_binding());
4441
- var Watcher = class {
4442
- closed;
4443
- inner;
4444
- emitter;
4445
- stopWorkers;
4446
- constructor(emitter, inner, stopWorkers) {
4447
- this.closed = false;
4448
- this.inner = inner;
4449
- this.emitter = emitter;
4450
- const originClose = emitter.close.bind(emitter);
4451
- emitter.close = async () => {
4452
- await this.close();
4453
- originClose();
4454
- };
4455
- this.stopWorkers = stopWorkers;
4456
- }
4457
- async close() {
4458
- if (this.closed) return;
4459
- this.closed = true;
4460
- for (const stop of this.stopWorkers) await stop?.();
4461
- await this.inner.close();
4462
- (0, import_binding.shutdownAsyncRuntime)();
4463
- }
4464
- start() {
4465
- process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4466
- }
4467
- };
4468
4738
  async function createWatcher(emitter, input) {
4469
4739
  const options = arraify(input);
4470
4740
  const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
@@ -4486,24 +4756,72 @@ function getValidNotifyOption(bundlerOptions) {
4486
4756
  } else result = notifyOption;
4487
4757
  }
4488
4758
  }
4759
+ var import_binding, Watcher;
4760
+ var init_watcher = __esm({ "src/api/watch/watcher.ts"() {
4761
+ import_binding = __toESM(require_binding());
4762
+ init_logging();
4763
+ init_logs();
4764
+ init_plugin_driver();
4765
+ init_create_bundler_option();
4766
+ init_misc();
4767
+ Watcher = class {
4768
+ closed;
4769
+ inner;
4770
+ emitter;
4771
+ stopWorkers;
4772
+ constructor(emitter, inner, stopWorkers) {
4773
+ this.closed = false;
4774
+ this.inner = inner;
4775
+ this.emitter = emitter;
4776
+ const originClose = emitter.close.bind(emitter);
4777
+ emitter.close = async () => {
4778
+ await this.close();
4779
+ originClose();
4780
+ };
4781
+ this.stopWorkers = stopWorkers;
4782
+ }
4783
+ async close() {
4784
+ if (this.closed) return;
4785
+ this.closed = true;
4786
+ for (const stop of this.stopWorkers) await stop?.();
4787
+ await this.inner.close();
4788
+ (0, import_binding.shutdownAsyncRuntime)();
4789
+ }
4790
+ start() {
4791
+ process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4792
+ }
4793
+ };
4794
+ } });
4489
4795
 
4490
4796
  //#endregion
4491
4797
  //#region src/api/watch/index.ts
4492
- const watch = (input) => {
4493
- const emitter = new WatcherEmitter();
4494
- createWatcher(emitter, input);
4495
- return emitter;
4496
- };
4798
+ var watch;
4799
+ var init_watch = __esm({ "src/api/watch/index.ts"() {
4800
+ init_watch_emitter();
4801
+ init_watcher();
4802
+ watch = (input) => {
4803
+ const emitter = new WatcherEmitter();
4804
+ createWatcher(emitter, input);
4805
+ return emitter;
4806
+ };
4807
+ } });
4497
4808
 
4498
4809
  //#endregion
4499
4810
  //#region src/utils/define-config.ts
4500
4811
  function defineConfig(config) {
4501
4812
  return config;
4502
4813
  }
4814
+ var init_define_config = __esm({ "src/utils/define-config.ts"() {} });
4503
4815
 
4504
4816
  //#endregion
4505
4817
  //#region src/index.ts
4506
- const VERSION = version;
4818
+ var VERSION;
4819
+ var init_src = __esm({ "src/index.ts"() {
4820
+ init_build();
4821
+ init_rolldown();
4822
+ init_watch();
4823
+ VERSION = version;
4824
+ } });
4507
4825
 
4508
4826
  //#endregion
4509
- export { BuiltinPlugin, PluginContextData, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, 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 };
4827
+ export { BuiltinPlugin, PluginContextData, VERSION, assetPlugin, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description$1 as description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, init_bindingify_plugin, init_compose_js_plugins, init_constructors, init_create_bundler, init_normalize_string_or_regex, init_plugin_context_data, 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 };