@rolldown/browser 1.0.0-beta.49 → 1.0.0-beta.51

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 (48) hide show
  1. package/dist/cli.mjs +12 -8
  2. package/dist/config.d.mts +3 -3
  3. package/dist/config.mjs +9 -5
  4. package/dist/constructors-DoUEJY6G.js +65 -0
  5. package/dist/experimental-index.browser.mjs +17 -11
  6. package/dist/experimental-index.d.mts +52 -15
  7. package/dist/experimental-index.mjs +21 -13
  8. package/dist/filter-index.d.mts +3 -3
  9. package/dist/filter-index.mjs +2 -1
  10. package/dist/index.browser.mjs +161 -2
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +36 -4
  13. package/dist/normalize-string-or-regex-BXFT9GiS.js +830 -0
  14. package/dist/parallel-plugin-worker.mjs +5 -4
  15. package/dist/parallel-plugin.d.mts +3 -3
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +1 -1
  18. package/dist/plugins-index.browser.mjs +2 -2
  19. package/dist/plugins-index.d.mts +3 -3
  20. package/dist/plugins-index.mjs +3 -2
  21. package/dist/rolldown-binding.wasi-browser.js +5 -2
  22. package/dist/rolldown-binding.wasi.cjs +5 -2
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/{src-CnMyHYgB.js → rolldown-build-C0UB1WZy.js} +32 -756
  25. package/dist/shared/{binding-B4uTNiw2.d.mts → binding-lSvYApx7.d.mts} +198 -89
  26. package/dist/shared/bindingify-input-options-CSdAtTcQ.mjs +1568 -0
  27. package/dist/shared/{composable-filters-CBpK2Fbc.mjs → composable-filters-DZ5ToxRJ.mjs} +1 -22
  28. package/dist/shared/constructors-DF6M1PTb.mjs +65 -0
  29. package/dist/shared/constructors-DgFF472b.d.mts +31 -0
  30. package/dist/shared/{define-config-BAQ9c-hh.d.mts → define-config-BKu-xa_0.d.mts} +10 -49
  31. package/dist/shared/define-config-DfeZGBEt.mjs +7 -0
  32. package/dist/shared/{load-config-DQI-2sfE.mjs → load-config-Beo_LOwd.mjs} +1 -1
  33. package/dist/shared/misc-5GYLGQ20.mjs +22 -0
  34. package/dist/shared/normalize-string-or-regex-DvECZN2V.mjs +629 -0
  35. package/dist/shared/{parse-ast-index-D9jH_38U.mjs → parse-ast-index-C_M-Y4oC.mjs} +3 -3
  36. package/dist/shared/{prompt-Ckjl2FdJ.mjs → prompt-pmGBC3ws.mjs} +1 -1
  37. package/dist/shared/rolldown-BhV7L6Kg.mjs +10 -0
  38. package/dist/shared/rolldown-build-DYR94CyF.mjs +2121 -0
  39. package/dist/shared/utils-BJWI2OzT.d.mts +62 -0
  40. package/dist/shared/watch-Cjxo-3u4.mjs +338 -0
  41. package/package.json +1 -1
  42. package/dist/constructors-EhfoQfqh.js +0 -68
  43. package/dist/normalize-string-or-regex-d47jXr3r.js +0 -231
  44. package/dist/shared/constructors-CaN9lKj2.d.mts +0 -32
  45. package/dist/shared/constructors-DcEzB0nc.mjs +0 -68
  46. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +0 -46
  47. package/dist/shared/src-CZ_U2fML.mjs +0 -4597
  48. package/dist/shared/utils-CduIqa7h.d.mts +0 -18
@@ -1,10 +1,6 @@
1
- import { a as augmentCodeLocation, c as logInputHookInOutputPlugin, d as logNoFileSystemInBrowser, f as logParseError, h as getCodeFrame, l as logInvalidLogPosition, m as locate, n as BuiltinPlugin, o as error, p as logPluginError, r as bindingifyBuiltInPlugin, s as logCycleLoading, t as normalizedStringOrRegex, u as logMultiplyNotifyOption } from "./normalize-string-or-regex-d47jXr3r.js";
2
- import { BindingAttachDebugInfo, BindingBundler, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingMagicString as BindingMagicString$1, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
1
+ import { A as logCycleLoading, C as logLevelPriority, D as unsupported, E as unreachable, F as logPluginError, I as locate, L as getCodeFrame, N as logNoFileSystemInBrowser, O as augmentCodeLocation, P as logParseError, S as LOG_LEVEL_WARN, T as unimplemented, _ as VERSION, b as LOG_LEVEL_ERROR, c as transformToRollupOutput, d as __decorate, f as bindingAssetSource, g as MinimalPluginContextImpl, h as PlainObjectLike, i as bindingifyViteHtmlPlugin, j as logInputHookInOutputPlugin, k as error, l as bindingifySourcemap$1, m as lazyProp, n as BuiltinPlugin, o as collectChangedBundle, p as transformAssetSource, r as bindingifyBuiltInPlugin, s as transformToOutputBundle, t as normalizedStringOrRegex, u as transformRenderedChunk, v as normalizeLog, w as arraify, x as LOG_LEVEL_INFO, y as LOG_LEVEL_DEBUG } from "./normalize-string-or-regex-BXFT9GiS.js";
2
+ import { BindingAttachDebugInfo, BindingBundler, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
3
3
 
4
- //#region package.json
5
- var version = "1.0.0-beta.49";
6
-
7
- //#endregion
8
4
  //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
9
5
  let _lazyMatch = () => {
10
6
  var __lib__ = (() => {
@@ -402,7 +398,7 @@ const basename = function(p, extension) {
402
398
  }
403
399
  return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
404
400
  };
405
- const parse = function(p) {
401
+ const parse$1 = function(p) {
406
402
  const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
407
403
  const base = basename(p);
408
404
  const extension = extname(base);
@@ -428,7 +424,7 @@ const _path = {
428
424
  matchesGlob,
429
425
  normalize,
430
426
  normalizeString,
431
- parse,
427
+ parse: parse$1,
432
428
  relative,
433
429
  resolve,
434
430
  sep,
@@ -453,53 +449,6 @@ const mix = (del = delimiter) => {
453
449
  const posix = /* @__PURE__ */ mix(":");
454
450
  const win32 = /* @__PURE__ */ mix(";");
455
451
 
456
- //#endregion
457
- //#region src/utils/misc.ts
458
- function arraify(value) {
459
- return Array.isArray(value) ? value : [value];
460
- }
461
- function unimplemented(info) {
462
- if (info) throw new Error(`unimplemented: ${info}`);
463
- throw new Error("unimplemented");
464
- }
465
- function unreachable(info) {
466
- if (info) throw new Error(`unreachable: ${info}`);
467
- throw new Error("unreachable");
468
- }
469
- function unsupported(info) {
470
- throw new Error(`UNSUPPORTED: ${info}`);
471
- }
472
- function noop(..._args) {}
473
-
474
- //#endregion
475
- //#region src/log/logging.ts
476
- const LOG_LEVEL_SILENT = "silent";
477
- const LOG_LEVEL_ERROR = "error";
478
- const LOG_LEVEL_WARN = "warn";
479
- const LOG_LEVEL_INFO = "info";
480
- const LOG_LEVEL_DEBUG = "debug";
481
- const logLevelPriority = {
482
- [LOG_LEVEL_DEBUG]: 0,
483
- [LOG_LEVEL_INFO]: 1,
484
- [LOG_LEVEL_WARN]: 2,
485
- [LOG_LEVEL_SILENT]: 3
486
- };
487
-
488
- //#endregion
489
- //#region src/log/log-handler.ts
490
- const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
491
- function getLogHandler(level, code$1, logger, pluginName, logLevel) {
492
- if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
493
- return (log, pos) => {
494
- if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
495
- log = normalizeLog(log);
496
- if (log.code && !log.pluginCode) log.pluginCode = log.code;
497
- log.code = code$1;
498
- log.plugin = pluginName;
499
- logger(level, log);
500
- };
501
- }
502
-
503
452
  //#endregion
504
453
  //#region src/log/logger.ts
505
454
  function getLogger(plugins, onLog, logLevel, watchMode) {
@@ -510,20 +459,20 @@ function getLogger(plugins, onLog, logLevel, watchMode) {
510
459
  if (skipped.has(plugin)) continue;
511
460
  const { onLog: pluginOnLog } = plugin;
512
461
  if (pluginOnLog) {
513
- const getLogHandler$1 = (level$1) => {
462
+ const getLogHandler = (level$1) => {
514
463
  if (logLevelPriority[level$1] < minimalPriority) return () => {};
515
464
  return (log$1) => logger(level$1, normalizeLog(log$1), new Set(skipped).add(plugin));
516
465
  };
517
466
  if (("handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog).call({
518
- debug: getLogHandler$1(LOG_LEVEL_DEBUG),
467
+ debug: getLogHandler(LOG_LEVEL_DEBUG),
519
468
  error: (log$1) => error(normalizeLog(log$1)),
520
- info: getLogHandler$1(LOG_LEVEL_INFO),
469
+ info: getLogHandler(LOG_LEVEL_INFO),
521
470
  meta: {
522
471
  rollupVersion: "4.23.0",
523
472
  rolldownVersion: VERSION,
524
473
  watchMode
525
474
  },
526
- warn: getLogHandler$1(LOG_LEVEL_WARN),
475
+ warn: getLogHandler(LOG_LEVEL_WARN),
527
476
  pluginName: plugin.name || "unknown"
528
477
  }, level, log) === false) return;
529
478
  }
@@ -583,7 +532,7 @@ function normalizeHook(hook) {
583
532
  meta: {}
584
533
  };
585
534
  if (typeof hook === "object" && hook !== null) {
586
- const { handler, order,...options } = hook;
535
+ const { handler, order, ...options } = hook;
587
536
  return {
588
537
  handler,
589
538
  options,
@@ -692,30 +641,6 @@ function normalizePlugins(plugins, anonymousPrefix) {
692
641
  const ANONYMOUS_PLUGIN_PREFIX = "at position ";
693
642
  const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
694
643
 
695
- //#endregion
696
- //#region src/plugin/minimal-plugin-context.ts
697
- var MinimalPluginContextImpl = class {
698
- info;
699
- warn;
700
- debug;
701
- meta;
702
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
703
- this.pluginName = pluginName;
704
- this.hookName = hookName;
705
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
706
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
707
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
708
- this.meta = {
709
- rollupVersion: "4.23.0",
710
- rolldownVersion: VERSION,
711
- watchMode
712
- };
713
- }
714
- error(e$1) {
715
- return error(logPluginError(normalizeLog(e$1), this.pluginName, { hook: this.hookName }));
716
- }
717
- };
718
-
719
644
  //#endregion
720
645
  //#region src/plugin/plugin-driver.ts
721
646
  var PluginDriver = class {
@@ -1911,7 +1836,8 @@ const ChecksOptionsSchema = strictObject({
1911
1836
  importIsUndefined: pipe(optional(boolean()), description("Whether to emit warning when detecting import is undefined")),
1912
1837
  emptyImportMeta: pipe(optional(boolean()), description("Whether to emit warning when detecting empty import meta")),
1913
1838
  configurationFieldConflict: pipe(optional(boolean()), description("Whether to emit warning when detecting configuration field conflict")),
1914
- preferBuiltinFeature: pipe(optional(boolean()), description("Whether to emit warning when detecting prefer builtin feature"))
1839
+ preferBuiltinFeature: pipe(optional(boolean()), description("Whether to emit warning when detecting prefer builtin feature")),
1840
+ couldNotCleanDirectory: pipe(optional(boolean()), description("Whether to emit warning when detecting could not clean directory"))
1915
1841
  });
1916
1842
  const CompressOptionsKeepNamesSchema = strictObject({
1917
1843
  function: boolean(),
@@ -2250,497 +2176,6 @@ function validateOption(key, options) {
2250
2176
  }
2251
2177
  }
2252
2178
 
2253
- //#endregion
2254
- //#region src/types/plain-object-like.ts
2255
- const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
2256
- /**
2257
- * Base class for classes that use `@lazyProp` decorated properties.
2258
- *
2259
- * **Design Pattern in Rolldown:**
2260
- * This is a common pattern in Rolldown due to its three-layer architecture:
2261
- * TypeScript API → NAPI Bindings → Rust Core
2262
- *
2263
- * **Why we use getters:**
2264
- * For performance - to lazily fetch data from Rust bindings only when needed,
2265
- * rather than eagerly fetching all data during object construction.
2266
- *
2267
- * **The problem:**
2268
- * Getters defined on class prototypes are non-enumerable by default, which breaks:
2269
- * - Object spread operators ({...obj})
2270
- * - Object.keys() and similar methods
2271
- * - Standard JavaScript object semantics
2272
- *
2273
- * **The solution:**
2274
- * This base class automatically converts `@lazyProp` decorated getters into
2275
- * own enumerable getters on each instance during construction.
2276
- *
2277
- * **Result:**
2278
- * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
2279
- *
2280
- * @example
2281
- * ```typescript
2282
- * class MyClass extends PlainObjectLike {
2283
- * @lazyProp
2284
- * get myProp() {
2285
- * return fetchFromRustBinding();
2286
- * }
2287
- * }
2288
- * ```
2289
- */
2290
- var PlainObjectLike = class {
2291
- constructor() {
2292
- setupLazyProperties(this);
2293
- }
2294
- };
2295
- /**
2296
- * Set up lazy properties as own getters on an instance.
2297
- * This is called automatically by the `PlainObjectLike` base class constructor.
2298
- *
2299
- * @param instance - The instance to set up lazy properties on
2300
- * @internal
2301
- */
2302
- function setupLazyProperties(instance$1) {
2303
- const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2304
- if (!lazyFields) return;
2305
- for (const [propertyKey, originalGetter] of lazyFields.entries()) {
2306
- let cachedValue;
2307
- let hasValue = false;
2308
- Object.defineProperty(instance$1, propertyKey, {
2309
- get() {
2310
- if (!hasValue) {
2311
- cachedValue = originalGetter.call(this);
2312
- hasValue = true;
2313
- }
2314
- return cachedValue;
2315
- },
2316
- enumerable: true,
2317
- configurable: true
2318
- });
2319
- }
2320
- }
2321
- /**
2322
- * Get all lazy field names from a class instance.
2323
- *
2324
- * @param instance - Instance to inspect
2325
- * @returns Set of lazy property names
2326
- */
2327
- function getLazyFields(instance$1) {
2328
- const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2329
- return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
2330
- }
2331
-
2332
- //#endregion
2333
- //#region src/decorators/lazy.ts
2334
- /**
2335
- * Decorator that marks a getter as lazy-evaluated and cached.
2336
- *
2337
- * **What "lazy" means here:**
2338
- * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
2339
- * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
2340
- * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
2341
- *
2342
- * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
2343
- * properties on each instance (not on the prototype). This ensures they:
2344
- * - Appear in Object.keys() and Object.getOwnPropertyNames()
2345
- * - Are included in object spreads ({...obj})
2346
- * - Are enumerable in for...in loops
2347
- *
2348
- * Classes using this decorator must extend `PlainObjectLike` base class.
2349
- *
2350
- * @example
2351
- * ```typescript
2352
- * class MyClass extends PlainObjectLike {
2353
- * @lazyProp
2354
- * get expensiveValue() {
2355
- * return someExpensiveComputation();
2356
- * }
2357
- * }
2358
- * ```
2359
- */
2360
- function lazyProp(target, propertyKey, descriptor) {
2361
- if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
2362
- const originalGetter = descriptor.get;
2363
- target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
2364
- return {
2365
- enumerable: false,
2366
- configurable: true
2367
- };
2368
- }
2369
-
2370
- //#endregion
2371
- //#region src/utils/asset-source.ts
2372
- function transformAssetSource(bindingAssetSource$1) {
2373
- return bindingAssetSource$1.inner;
2374
- }
2375
- function bindingAssetSource(source) {
2376
- return { inner: source };
2377
- }
2378
-
2379
- //#endregion
2380
- //#region \0@oxc-project+runtime@0.96.0/helpers/decorate.js
2381
- function __decorate(decorators, target, key, desc) {
2382
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2383
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2384
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2385
- return c > 3 && r && Object.defineProperty(target, key, r), r;
2386
- }
2387
-
2388
- //#endregion
2389
- //#region src/types/output-asset-impl.ts
2390
- var OutputAssetImpl = class extends PlainObjectLike {
2391
- type = "asset";
2392
- constructor(bindingAsset) {
2393
- super();
2394
- this.bindingAsset = bindingAsset;
2395
- }
2396
- get fileName() {
2397
- return this.bindingAsset.getFileName();
2398
- }
2399
- get originalFileName() {
2400
- return this.bindingAsset.getOriginalFileName() || null;
2401
- }
2402
- get originalFileNames() {
2403
- return this.bindingAsset.getOriginalFileNames();
2404
- }
2405
- get name() {
2406
- return this.bindingAsset.getName() ?? void 0;
2407
- }
2408
- get names() {
2409
- return this.bindingAsset.getNames();
2410
- }
2411
- get source() {
2412
- return transformAssetSource(this.bindingAsset.getSource());
2413
- }
2414
- __rolldown_external_memory_handle__(keepDataAlive) {
2415
- if (keepDataAlive) this.#evaluateAllLazyFields();
2416
- return this.bindingAsset.dropInner();
2417
- }
2418
- #evaluateAllLazyFields() {
2419
- for (const field of getLazyFields(this)) this[field];
2420
- }
2421
- };
2422
- __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
2423
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
2424
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
2425
- __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
2426
- __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
2427
- __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
2428
-
2429
- //#endregion
2430
- //#region src/utils/transform-rendered-module.ts
2431
- function transformToRenderedModule(bindingRenderedModule) {
2432
- return {
2433
- get code() {
2434
- return bindingRenderedModule.code;
2435
- },
2436
- get renderedLength() {
2437
- return bindingRenderedModule.code?.length || 0;
2438
- },
2439
- get renderedExports() {
2440
- return bindingRenderedModule.renderedExports;
2441
- }
2442
- };
2443
- }
2444
-
2445
- //#endregion
2446
- //#region src/utils/transform-rendered-chunk.ts
2447
- function transformRenderedChunk(chunk) {
2448
- let modules = null;
2449
- return {
2450
- type: "chunk",
2451
- get name() {
2452
- return chunk.name;
2453
- },
2454
- get isEntry() {
2455
- return chunk.isEntry;
2456
- },
2457
- get isDynamicEntry() {
2458
- return chunk.isDynamicEntry;
2459
- },
2460
- get facadeModuleId() {
2461
- return chunk.facadeModuleId;
2462
- },
2463
- get moduleIds() {
2464
- return chunk.moduleIds;
2465
- },
2466
- get exports() {
2467
- return chunk.exports;
2468
- },
2469
- get fileName() {
2470
- return chunk.fileName;
2471
- },
2472
- get imports() {
2473
- return chunk.imports;
2474
- },
2475
- get dynamicImports() {
2476
- return chunk.dynamicImports;
2477
- },
2478
- get modules() {
2479
- if (!modules) modules = transformChunkModules(chunk.modules);
2480
- return modules;
2481
- }
2482
- };
2483
- }
2484
- function transformChunkModules(modules) {
2485
- const result = {};
2486
- for (let i = 0; i < modules.values.length; i++) {
2487
- let key = modules.keys[i];
2488
- const mod = modules.values[i];
2489
- result[key] = transformToRenderedModule(mod);
2490
- }
2491
- return result;
2492
- }
2493
-
2494
- //#endregion
2495
- //#region src/types/output-chunk-impl.ts
2496
- var OutputChunkImpl = class extends PlainObjectLike {
2497
- type = "chunk";
2498
- constructor(bindingChunk) {
2499
- super();
2500
- this.bindingChunk = bindingChunk;
2501
- }
2502
- get fileName() {
2503
- return this.bindingChunk.getFileName();
2504
- }
2505
- get name() {
2506
- return this.bindingChunk.getName();
2507
- }
2508
- get exports() {
2509
- return this.bindingChunk.getExports();
2510
- }
2511
- get isEntry() {
2512
- return this.bindingChunk.getIsEntry();
2513
- }
2514
- get facadeModuleId() {
2515
- return this.bindingChunk.getFacadeModuleId() || null;
2516
- }
2517
- get isDynamicEntry() {
2518
- return this.bindingChunk.getIsDynamicEntry();
2519
- }
2520
- get sourcemapFileName() {
2521
- return this.bindingChunk.getSourcemapFileName() || null;
2522
- }
2523
- get preliminaryFileName() {
2524
- return this.bindingChunk.getPreliminaryFileName();
2525
- }
2526
- get code() {
2527
- return this.bindingChunk.getCode();
2528
- }
2529
- get modules() {
2530
- return transformChunkModules(this.bindingChunk.getModules());
2531
- }
2532
- get imports() {
2533
- return this.bindingChunk.getImports();
2534
- }
2535
- get dynamicImports() {
2536
- return this.bindingChunk.getDynamicImports();
2537
- }
2538
- get moduleIds() {
2539
- return this.bindingChunk.getModuleIds();
2540
- }
2541
- get map() {
2542
- const mapString = this.bindingChunk.getMap();
2543
- return mapString ? transformToRollupSourceMap(mapString) : null;
2544
- }
2545
- __rolldown_external_memory_handle__(keepDataAlive) {
2546
- if (keepDataAlive) this.#evaluateAllLazyFields();
2547
- return this.bindingChunk.dropInner();
2548
- }
2549
- #evaluateAllLazyFields() {
2550
- for (const field of getLazyFields(this)) this[field];
2551
- }
2552
- };
2553
- __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
2554
- __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
2555
- __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
2556
- __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
2557
- __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
2558
- __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
2559
- __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
2560
- __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
2561
- __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
2562
- __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
2563
- __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
2564
- __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
2565
- __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
2566
- __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
2567
-
2568
- //#endregion
2569
- //#region src/types/sourcemap.ts
2570
- function bindingifySourcemap$1(map) {
2571
- if (map == null) return;
2572
- return { inner: typeof map === "string" ? map : {
2573
- file: map.file ?? void 0,
2574
- mappings: map.mappings,
2575
- sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2576
- sources: map.sources?.map((s) => s ?? void 0),
2577
- sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2578
- names: map.names,
2579
- x_google_ignoreList: map.x_google_ignoreList,
2580
- debugId: "debugId" in map ? map.debugId : void 0
2581
- } };
2582
- }
2583
-
2584
- //#endregion
2585
- //#region src/utils/transform-to-rollup-output.ts
2586
- function transformToRollupSourceMap(map) {
2587
- const obj = {
2588
- ...JSON.parse(map),
2589
- toString() {
2590
- return JSON.stringify(obj);
2591
- },
2592
- toUrl() {
2593
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
2594
- }
2595
- };
2596
- return obj;
2597
- }
2598
- function transformToRollupOutputChunk(bindingChunk) {
2599
- return new OutputChunkImpl(bindingChunk);
2600
- }
2601
- function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2602
- const chunk = {
2603
- type: "chunk",
2604
- get code() {
2605
- return bindingChunk.getCode();
2606
- },
2607
- fileName: bindingChunk.getFileName(),
2608
- name: bindingChunk.getName(),
2609
- get modules() {
2610
- return transformChunkModules(bindingChunk.getModules());
2611
- },
2612
- get imports() {
2613
- return bindingChunk.getImports();
2614
- },
2615
- get dynamicImports() {
2616
- return bindingChunk.getDynamicImports();
2617
- },
2618
- exports: bindingChunk.getExports(),
2619
- isEntry: bindingChunk.getIsEntry(),
2620
- facadeModuleId: bindingChunk.getFacadeModuleId() || null,
2621
- isDynamicEntry: bindingChunk.getIsDynamicEntry(),
2622
- get moduleIds() {
2623
- return bindingChunk.getModuleIds();
2624
- },
2625
- get map() {
2626
- const map = bindingChunk.getMap();
2627
- return map ? transformToRollupSourceMap(map) : null;
2628
- },
2629
- sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
2630
- preliminaryFileName: bindingChunk.getPreliminaryFileName()
2631
- };
2632
- const cache = {};
2633
- return new Proxy(chunk, {
2634
- get(target, p) {
2635
- if (p in cache) return cache[p];
2636
- const value = target[p];
2637
- cache[p] = value;
2638
- return value;
2639
- },
2640
- set(_target, p, newValue) {
2641
- cache[p] = newValue;
2642
- changed.updated.add(bindingChunk.getFileName());
2643
- return true;
2644
- },
2645
- has(target, p) {
2646
- if (p in cache) return true;
2647
- return p in target;
2648
- }
2649
- });
2650
- }
2651
- function transformToRollupOutputAsset(bindingAsset) {
2652
- return new OutputAssetImpl(bindingAsset);
2653
- }
2654
- function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2655
- const asset = {
2656
- type: "asset",
2657
- fileName: bindingAsset.getFileName(),
2658
- originalFileName: bindingAsset.getOriginalFileName() || null,
2659
- originalFileNames: bindingAsset.getOriginalFileNames(),
2660
- get source() {
2661
- return transformAssetSource(bindingAsset.getSource());
2662
- },
2663
- name: bindingAsset.getName() ?? void 0,
2664
- names: bindingAsset.getNames()
2665
- };
2666
- const cache = {};
2667
- return new Proxy(asset, {
2668
- get(target, p) {
2669
- if (p in cache) return cache[p];
2670
- const value = target[p];
2671
- cache[p] = value;
2672
- return value;
2673
- },
2674
- set(_target, p, newValue) {
2675
- cache[p] = newValue;
2676
- changed.updated.add(bindingAsset.getFileName());
2677
- return true;
2678
- }
2679
- });
2680
- }
2681
- function transformToRollupOutput(output) {
2682
- const { chunks, assets } = output;
2683
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
2684
- }
2685
- function transformToMutableRollupOutput(output, changed) {
2686
- const { chunks, assets } = output;
2687
- return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
2688
- }
2689
- function transformToOutputBundle(context, output, changed) {
2690
- const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
2691
- return new Proxy(bundle, {
2692
- set(_target, _p, _newValue, _receiver) {
2693
- const originalStackTraceLimit = Error.stackTraceLimit;
2694
- Error.stackTraceLimit = 2;
2695
- const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
2696
- const stack = new Error(message).stack ?? message;
2697
- Error.stackTraceLimit = originalStackTraceLimit;
2698
- context.warn({
2699
- message: stack,
2700
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
2701
- });
2702
- return true;
2703
- },
2704
- deleteProperty(target, property) {
2705
- if (typeof property === "string") changed.deleted.add(property);
2706
- return true;
2707
- }
2708
- });
2709
- }
2710
- function collectChangedBundle(changed, bundle) {
2711
- const changes = {};
2712
- for (const key in bundle) {
2713
- if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
2714
- const item = bundle[key];
2715
- if (item.type === "asset") changes[key] = {
2716
- filename: item.fileName,
2717
- originalFileNames: item.originalFileNames,
2718
- source: bindingAssetSource(item.source),
2719
- names: item.names
2720
- };
2721
- else changes[key] = {
2722
- code: item.code,
2723
- filename: item.fileName,
2724
- name: item.name,
2725
- isEntry: item.isEntry,
2726
- exports: item.exports,
2727
- modules: {},
2728
- imports: item.imports,
2729
- dynamicImports: item.dynamicImports,
2730
- facadeModuleId: item.facadeModuleId || void 0,
2731
- isDynamicEntry: item.isDynamicEntry,
2732
- moduleIds: item.moduleIds,
2733
- map: bindingifySourcemap$1(item.map),
2734
- sourcemapFilename: item.sourcemapFileName || void 0,
2735
- preliminaryFilename: item.preliminaryFileName
2736
- };
2737
- }
2738
- return {
2739
- changes,
2740
- deleted: changed.deleted
2741
- };
2742
- }
2743
-
2744
2179
  //#endregion
2745
2180
  //#region src/types/rolldown-output-impl.ts
2746
2181
  var RolldownOutputImpl = class extends PlainObjectLike {
@@ -2766,7 +2201,7 @@ var RolldownOutputImpl = class extends PlainObjectLike {
2766
2201
  __decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
2767
2202
 
2768
2203
  //#endregion
2769
- //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
2204
+ //#region ../../node_modules/.pnpm/oxc-parser@0.98.0/node_modules/oxc-parser/src-js/wrap.js
2770
2205
  function wrap$1(result) {
2771
2206
  let program, module, comments, errors;
2772
2207
  return {
@@ -3328,16 +2763,16 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
3328
2763
  this.inner = inner;
3329
2764
  this.moduleId = moduleId;
3330
2765
  this.moduleSource = moduleSource;
3331
- const getLogHandler$1 = (handler) => (log, pos) => {
2766
+ const getLogHandler = (handler) => (log, pos) => {
3332
2767
  log = normalizeLog(log);
3333
2768
  if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
3334
2769
  log.id = moduleId;
3335
2770
  log.hook = "transform";
3336
2771
  handler(log);
3337
2772
  };
3338
- this.debug = getLogHandler$1(this.debug);
3339
- this.warn = getLogHandler$1(this.warn);
3340
- this.info = getLogHandler$1(this.info);
2773
+ this.debug = getLogHandler(this.debug);
2774
+ this.warn = getLogHandler(this.warn);
2775
+ this.info = getLogHandler(this.info);
3341
2776
  }
3342
2777
  error(e$1, pos) {
3343
2778
  if (typeof e$1 === "string") e$1 = { message: e$1 };
@@ -4222,7 +3657,7 @@ function normalizeTransformOptions(inputOptions) {
4222
3657
  const dropLabels = transform?.dropLabels;
4223
3658
  let oxcTransformOptions;
4224
3659
  if (transform) {
4225
- const { define: _define, inject: _inject, dropLabels: _dropLabels,...rest } = transform;
3660
+ const { define: _define, inject: _inject, dropLabels: _dropLabels, ...rest } = transform;
4226
3661
  if (Object.keys(rest).length > 0) {
4227
3662
  if (rest.jsx === false) rest.jsx = "disable";
4228
3663
  oxcTransformOptions = rest;
@@ -4242,7 +3677,10 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
4242
3677
  const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
4243
3678
  const plugins = rawPlugins.map((plugin) => {
4244
3679
  if ("_parallel" in plugin) return;
4245
- if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
3680
+ if (plugin instanceof BuiltinPlugin) {
3681
+ if (plugin.name === "builtin:vite-html") return bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode);
3682
+ return bindingifyBuiltInPlugin(plugin);
3683
+ }
4246
3684
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
4247
3685
  });
4248
3686
  const normalizedTransform = normalizeTransformOptions(inputOptions);
@@ -4337,7 +3775,7 @@ function bindingifyExperimental(experimental) {
4337
3775
  function bindingifyResolve(resolve$1) {
4338
3776
  const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
4339
3777
  if (resolve$1) {
4340
- const { alias, extensionAlias,...rest } = resolve$1;
3778
+ const { alias, extensionAlias, ...rest } = resolve$1;
4341
3779
  return {
4342
3780
  alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
4343
3781
  find: name,
@@ -4394,13 +3832,13 @@ function bindingifyInput(input) {
4394
3832
  };
4395
3833
  });
4396
3834
  }
4397
- function bindingifyWatch(watch$1) {
4398
- if (watch$1) return {
4399
- buildDelay: watch$1.buildDelay,
4400
- skipWrite: watch$1.skipWrite,
4401
- include: normalizedStringOrRegex(watch$1.include),
4402
- exclude: normalizedStringOrRegex(watch$1.exclude),
4403
- onInvalidate: (...args$1) => watch$1.onInvalidate?.(...args$1)
3835
+ function bindingifyWatch(watch) {
3836
+ if (watch) return {
3837
+ buildDelay: watch.buildDelay,
3838
+ skipWrite: watch.skipWrite,
3839
+ include: normalizedStringOrRegex(watch.include),
3840
+ exclude: normalizedStringOrRegex(watch.exclude),
3841
+ onInvalidate: (...args$1) => watch.onInvalidate?.(...args$1)
4404
3842
  };
4405
3843
  }
4406
3844
  function bindingifyTreeshakeOptions(config) {
@@ -4572,11 +4010,11 @@ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
4572
4010
  return manualChunks(moduleId, { getModuleInfo: (id$1) => ctx.getModuleInfo(id$1) });
4573
4011
  } }] };
4574
4012
  if (advancedChunks == null) return;
4575
- const { groups,...restAdvancedChunks } = advancedChunks;
4013
+ const { groups, ...restAdvancedChunks } = advancedChunks;
4576
4014
  return {
4577
4015
  ...restAdvancedChunks,
4578
4016
  groups: groups?.map((group) => {
4579
- const { name,...restGroup } = group;
4017
+ const { name, ...restGroup } = group;
4580
4018
  return {
4581
4019
  ...restGroup,
4582
4020
  name: typeof name === "function" ? (id$1, ctx) => name(id$1, new ChunkingContextImpl(ctx)) : name
@@ -4669,166 +4107,4 @@ var RolldownBuild = class RolldownBuild {
4669
4107
  };
4670
4108
 
4671
4109
  //#endregion
4672
- //#region src/api/rolldown/index.ts
4673
- const rolldown = async (input) => {
4674
- validateOption("input", input);
4675
- return new RolldownBuild(await PluginDriver.callOptionsHook(input));
4676
- };
4677
-
4678
- //#endregion
4679
- //#region src/api/build.ts
4680
- async function build(options) {
4681
- if (Array.isArray(options)) return Promise.all(options.map((opts) => build(opts)));
4682
- else {
4683
- const { output, write = true,...inputOptions } = options;
4684
- const build$1 = await rolldown(inputOptions);
4685
- try {
4686
- if (write) return await build$1.write(output);
4687
- else return await build$1.generate(output);
4688
- } finally {
4689
- await build$1.close();
4690
- }
4691
- }
4692
- }
4693
-
4694
- //#endregion
4695
- //#region src/api/watch/watch-emitter.ts
4696
- var WatcherEmitter = class {
4697
- listeners = /* @__PURE__ */ new Map();
4698
- timer;
4699
- constructor() {
4700
- this.timer = setInterval(() => {}, 1e9);
4701
- }
4702
- on(event, listener) {
4703
- const listeners = this.listeners.get(event);
4704
- if (listeners) listeners.push(listener);
4705
- else this.listeners.set(event, [listener]);
4706
- return this;
4707
- }
4708
- off(event, listener) {
4709
- const listeners = this.listeners.get(event);
4710
- if (listeners) {
4711
- const index = listeners.indexOf(listener);
4712
- if (index !== -1) listeners.splice(index, 1);
4713
- }
4714
- return this;
4715
- }
4716
- clear(event) {
4717
- if (this.listeners.has(event)) this.listeners.delete(event);
4718
- }
4719
- async onEvent(event) {
4720
- const listeners = this.listeners.get(event.eventKind());
4721
- if (listeners) switch (event.eventKind()) {
4722
- case "close":
4723
- case "restart":
4724
- for (const listener of listeners) await listener();
4725
- break;
4726
- case "event":
4727
- for (const listener of listeners) {
4728
- const code$1 = event.bundleEventKind();
4729
- switch (code$1) {
4730
- case "BUNDLE_END":
4731
- const { duration, output, result } = event.bundleEndData();
4732
- await listener({
4733
- code: "BUNDLE_END",
4734
- duration,
4735
- output: [output],
4736
- result
4737
- });
4738
- break;
4739
- case "ERROR":
4740
- const data = event.bundleErrorData();
4741
- await listener({
4742
- code: "ERROR",
4743
- error: aggregateBindingErrorsIntoJsError(data.error),
4744
- result: data.result
4745
- });
4746
- break;
4747
- default:
4748
- await listener({ code: code$1 });
4749
- break;
4750
- }
4751
- }
4752
- break;
4753
- case "change":
4754
- for (const listener of listeners) {
4755
- const { path, kind } = event.watchChangeData();
4756
- await listener(path, { event: kind });
4757
- }
4758
- break;
4759
- default: throw new Error(`Unknown event: ${event}`);
4760
- }
4761
- }
4762
- async close() {
4763
- clearInterval(this.timer);
4764
- }
4765
- };
4766
-
4767
- //#endregion
4768
- //#region src/api/watch/watcher.ts
4769
- var Watcher = class {
4770
- closed;
4771
- inner;
4772
- emitter;
4773
- stopWorkers;
4774
- constructor(emitter, inner, stopWorkers) {
4775
- this.closed = false;
4776
- this.inner = inner;
4777
- this.emitter = emitter;
4778
- const originClose = emitter.close.bind(emitter);
4779
- emitter.close = async () => {
4780
- await this.close();
4781
- originClose();
4782
- };
4783
- this.stopWorkers = stopWorkers;
4784
- }
4785
- async close() {
4786
- if (this.closed) return;
4787
- this.closed = true;
4788
- for (const stop of this.stopWorkers) await stop?.();
4789
- await this.inner.close();
4790
- shutdownAsyncRuntime();
4791
- }
4792
- start() {
4793
- process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
4794
- }
4795
- };
4796
- async function createWatcher(emitter, input) {
4797
- const options = arraify(input);
4798
- const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
4799
- return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
4800
- })).flat());
4801
- const notifyOptions = getValidNotifyOption(bundlerOptions);
4802
- new Watcher(emitter, new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions), bundlerOptions.map((option) => option.stopWorkers)).start();
4803
- }
4804
- function getValidNotifyOption(bundlerOptions) {
4805
- let result;
4806
- for (const option of bundlerOptions) if (option.inputOptions.watch) {
4807
- const notifyOption = option.inputOptions.watch.notify;
4808
- if (notifyOption) if (result) {
4809
- option.onLog(LOG_LEVEL_WARN, logMultiplyNotifyOption());
4810
- return result;
4811
- } else result = notifyOption;
4812
- }
4813
- }
4814
-
4815
- //#endregion
4816
- //#region src/api/watch/index.ts
4817
- const watch = (input) => {
4818
- const emitter = new WatcherEmitter();
4819
- createWatcher(emitter, input);
4820
- return emitter;
4821
- };
4822
-
4823
- //#endregion
4824
- //#region src/utils/define-config.ts
4825
- function defineConfig(config) {
4826
- return config;
4827
- }
4828
-
4829
- //#endregion
4830
- //#region src/index.ts
4831
- const VERSION = version;
4832
-
4833
- //#endregion
4834
- export { build as a, createBundlerOptions as c, transformToRollupOutput as d, bindingifySourcemap$1 as f, watch as i, normalizeBindingResult as l, PluginDriver as m, VERSION as n, rolldown as o, validateOption as p, defineConfig as r, RolldownBuild as s, BindingMagicString$1 as t, unwrapBindingResult as u };
4110
+ export { unwrapBindingResult as a, normalizeBindingResult as i, createBundlerOptions as n, validateOption as o, aggregateBindingErrorsIntoJsError as r, PluginDriver as s, RolldownBuild as t };