rolldown 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/THIRD-PARTY-LICENSE +33 -0
  2. package/dist/cli.mjs +9 -10
  3. package/dist/config.d.mts +1 -1
  4. package/dist/config.mjs +2 -2
  5. package/dist/experimental-default-runtime.mjs +116 -0
  6. package/dist/experimental-index.d.mts +10 -4
  7. package/dist/experimental-index.mjs +32 -16
  8. package/dist/experimental-runtime-base.mjs +95 -0
  9. package/dist/experimental-runtime.d.ts +177 -0
  10. package/dist/experimental-runtime.mjs +257 -0
  11. package/dist/filter-index.d.mts +1 -1
  12. package/dist/filter-index.mjs +1 -3
  13. package/dist/index.d.mts +3 -3
  14. package/dist/index.mjs +4 -4
  15. package/dist/parallel-plugin-worker.mjs +2 -2
  16. package/dist/parallel-plugin.d.mts +1 -1
  17. package/dist/parse-ast-index.d.mts +1 -1
  18. package/dist/parse-ast-index.mjs +2 -2
  19. package/dist/plugins-index.d.mts +3 -3
  20. package/dist/plugins-index.mjs +2 -2
  21. package/dist/shared/{binding-Dbbi0RbO.d.mts → binding-CVtkJvyl.d.mts} +11 -0
  22. package/dist/shared/{binding-Dby9rwGk.mjs → binding-Cv62mM1i.mjs} +124 -50
  23. package/dist/shared/{bindingify-input-options-_ppP73I9.mjs → bindingify-input-options-EnUlEF0T.mjs} +209 -252
  24. package/dist/shared/{constructors-CSWbNgBZ.d.mts → constructors-ALilxAii.d.mts} +2 -2
  25. package/dist/shared/{constructors-CuGa75s-.mjs → constructors-CuqzPFxJ.mjs} +10 -6
  26. package/dist/shared/{rolldown-build-CdF8HAHX.mjs → create-bundler-option-4QtiLLuz.mjs} +39 -156
  27. package/dist/shared/{define-config-B-IDOhDz.d.mts → define-config-DSMNXceb.d.mts} +85 -22
  28. package/dist/shared/{error-DFGNOCle.mjs → error-BgfXq0Tb.mjs} +1 -1
  29. package/dist/shared/{load-config-C6UyiS41.mjs → load-config-DsMzOVzu.mjs} +2 -2
  30. package/dist/shared/{logs-ZGEh6uhb.mjs → logs-DmYCAKcW.mjs} +8 -1
  31. package/dist/shared/{misc-CoQm4NHO.mjs → misc-DOSKtd97.mjs} +9 -1
  32. package/dist/shared/{normalize-string-or-regex-SiXbePVH.mjs → normalize-string-or-regex-BVNGzRe4.mjs} +2 -2
  33. package/dist/shared/{parse-BFj5G_7i.mjs → parse-DQIYJwT4.mjs} +2 -2
  34. package/dist/shared/{prompt--dNycKSZ.mjs → prompt-CH6TK0bC.mjs} +2 -6
  35. package/dist/shared/{resolve-tsconfig-2TXRF_zr.mjs → resolve-tsconfig-CQndqeLj.mjs} +2 -2
  36. package/dist/shared/rolldown-DP_p9pd3.mjs +178 -0
  37. package/dist/shared/{transform-Cs2bUDRH.d.mts → transform-WmU_cI8e.d.mts} +1 -1
  38. package/dist/shared/{watch-WnrlHRS0.mjs → watch-Cwq-cFUy.mjs} +16 -13
  39. package/dist/utils-index.d.mts +3 -3
  40. package/dist/utils-index.mjs +6 -8
  41. package/package.json +31 -24
  42. package/dist/shared/rolldown-951h_1lf.mjs +0 -40
@@ -1,14 +1,16 @@
1
- import { n as __toESM, t as require_binding } from "./binding-Dby9rwGk.mjs";
2
- import { a as logInvalidLogPosition, c as logPluginError, n as error, r as logCycleLoading, t as augmentCodeLocation } from "./logs-ZGEh6uhb.mjs";
3
- import { i as bindingifyManifestPlugin, n as BuiltinPlugin, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-SiXbePVH.mjs";
4
- import { a as unreachable, o as unsupported, r as noop, t as arraify } from "./misc-CoQm4NHO.mjs";
5
- import { a as bindingifySourcemap, i as unwrapBindingResult, t as aggregateBindingErrorsIntoJsError } from "./error-DFGNOCle.mjs";
1
+ import { n as __toESM, t as require_binding } from "./binding-Cv62mM1i.mjs";
2
+ import { i as logFailedValidation, l as logPluginError, n as error, o as logInvalidLogPosition, r as logCycleLoading, t as augmentCodeLocation } from "./logs-DmYCAKcW.mjs";
3
+ import { i as bindingifyManifestPlugin, n as BuiltinPlugin, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-BVNGzRe4.mjs";
4
+ import { i as noop, n as isPathFragment, o as unreachable, s as unsupported, t as arraify } from "./misc-DOSKtd97.mjs";
5
+ import { a as bindingifySourcemap, i as unwrapBindingResult, t as aggregateBindingErrorsIntoJsError } from "./error-BgfXq0Tb.mjs";
6
6
  import { parseAst } from "../parse-ast-index.mjs";
7
+ import fs from "node:fs";
7
8
  import path from "node:path";
8
9
  import * as filter from "@rolldown/pluginutils";
9
10
  import fsp from "node:fs/promises";
11
+ import { fileURLToPath } from "node:url";
10
12
  //#region package.json
11
- var version = "1.2.0";
13
+ var version = "1.2.1";
12
14
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
13
15
  //#endregion
14
16
  //#region src/constants/version.ts
@@ -65,6 +67,26 @@ function normalizeHook(hook) {
65
67
  unreachable("Invalid hook type");
66
68
  }
67
69
  //#endregion
70
+ //#region src/utils/parallel-plugin.ts
71
+ /**
72
+ * Returns the `_parallel` marker of a parallel plugin, or `undefined` if the
73
+ * given plugin is not one.
74
+ *
75
+ * Detection is descriptor-based instead of using the `in` operator: only an
76
+ * own data property named `_parallel` with the expected shape counts. This
77
+ * avoids false positives from inherited or accessor `_parallel` properties on
78
+ * regular plugins, and guarantees that callers can safely read `fileUrl` and
79
+ * `options` from the returned value.
80
+ */
81
+ function getParallelPluginInfo(plugin) {
82
+ if (plugin === null || typeof plugin !== "object") return;
83
+ const descriptor = Object.getOwnPropertyDescriptor(plugin, "_parallel");
84
+ if (!descriptor || !("value" in descriptor)) return;
85
+ const parallel = descriptor.value;
86
+ if (parallel === null || typeof parallel !== "object" || typeof parallel.fileUrl !== "string") return;
87
+ return parallel;
88
+ }
89
+ //#endregion
68
90
  //#region src/plugin/minimal-plugin-context.ts
69
91
  var MinimalPluginContextImpl = class {
70
92
  pluginName;
@@ -214,7 +236,7 @@ function bindingAssetSource(source) {
214
236
  return { inner: source };
215
237
  }
216
238
  //#endregion
217
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
239
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/decorate.js
218
240
  function __decorate(decorators, target, key, desc) {
219
241
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
220
242
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -1087,6 +1109,20 @@ function containsImporterId(expr) {
1087
1109
  function assertNoImporterId(filterExprs, hookName) {
1088
1110
  if (filterExprs?.some(containsImporterId)) throw new Error(`The \`importerId\` filter can only be used with the \`resolveId\` hook, but it was used with the \`${hookName}\` hook.`);
1089
1111
  }
1112
+ function containsStringId(expr) {
1113
+ switch (expr.kind) {
1114
+ case "and":
1115
+ case "or": return expr.args.some(containsStringId);
1116
+ case "not":
1117
+ case "include":
1118
+ case "exclude": return containsStringId(expr.expr);
1119
+ case "id": return typeof expr.pattern === "string";
1120
+ default: return false;
1121
+ }
1122
+ }
1123
+ function assertNoStringId(filterExprs, hookName) {
1124
+ if (filterExprs?.some(containsStringId)) throw new Error(`A string \`id\` filter is not supported for the \`${hookName}\` hook, because its \`id\` is the import specifier rather than a resolved path. Use a RegExp instead.`);
1125
+ }
1090
1126
  function bindingifyFilterExprImpl(expr, list) {
1091
1127
  switch (expr.kind) {
1092
1128
  case "and": {
@@ -1160,8 +1196,11 @@ function bindingifyFilterExprImpl(expr, list) {
1160
1196
  }
1161
1197
  function bindingifyResolveIdFilter(filterOption) {
1162
1198
  if (!filterOption) return;
1163
- if (Array.isArray(filterOption)) return { value: filterOption.map(bindingifyFilterExpr) };
1164
- return filterOption.id ? bindingifyGeneralHookFilter("id", filterOption.id) : void 0;
1199
+ const filterExprs = Array.isArray(filterOption) ? filterOption : filterOption.id ? generalHookFilterMatcherToFilterExprs(filterOption.id, "id") : void 0;
1200
+ assertNoStringId(filterExprs, "resolveId");
1201
+ if (!filterExprs) return;
1202
+ const value = filterExprs.map(bindingifyFilterExpr);
1203
+ return value.length > 0 ? { value } : void 0;
1165
1204
  }
1166
1205
  function bindingifyLoadFilter(filterOption) {
1167
1206
  if (!filterOption) return;
@@ -1201,6 +1240,14 @@ function bindingPluginOrder(order) {
1201
1240
  default: throw new Error(`Unknown plugin order: ${order}`);
1202
1241
  }
1203
1242
  }
1243
+ function bindingifyHook(hook, build) {
1244
+ if (!hook) return {};
1245
+ const normalized = normalizeHook(hook);
1246
+ return {
1247
+ ...build(normalized),
1248
+ meta: bindingifyPluginHookMeta(normalized.meta)
1249
+ };
1250
+ }
1204
1251
  //#endregion
1205
1252
  //#region src/plugin/fs.ts
1206
1253
  const fsModule = {
@@ -1284,17 +1331,23 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
1284
1331
  };
1285
1332
  }
1286
1333
  emitFile = (file) => {
1287
- if (file.type === "prebuilt-chunk") return this.context.emitPrebuiltChunk({
1288
- fileName: file.fileName,
1289
- name: file.name,
1290
- code: file.code,
1291
- exports: file.exports,
1292
- map: bindingifySourcemap(file.map),
1293
- sourcemapFileName: file.sourcemapFileName,
1294
- facadeModuleId: file.facadeModuleId,
1295
- isEntry: file.isEntry,
1296
- isDynamicEntry: file.isDynamicEntry
1297
- });
1334
+ if (file.type === "prebuilt-chunk") {
1335
+ if (typeof file.code !== "string") return error(logFailedValidation(`Emitted prebuilt chunks need to have a valid string code, received "${file.code}".`));
1336
+ if (typeof file.fileName !== "string" || isPathFragment(file.fileName)) return error(logFailedValidation(`The "fileName" property of emitted prebuilt chunks must be strings that are neither absolute nor relative paths, received "${file.fileName}".`));
1337
+ return this.context.emitPrebuiltChunk({
1338
+ fileName: file.fileName,
1339
+ name: file.name,
1340
+ code: file.code,
1341
+ exports: file.exports,
1342
+ map: bindingifySourcemap(file.map),
1343
+ sourcemapFileName: file.sourcemapFileName,
1344
+ facadeModuleId: file.facadeModuleId,
1345
+ isEntry: file.isEntry,
1346
+ isDynamicEntry: file.isDynamicEntry
1347
+ });
1348
+ }
1349
+ const validatedName = file.fileName || file.name;
1350
+ if (typeof validatedName === "string" && isPathFragment(validatedName)) return error(logFailedValidation(`The "fileName" or "name" properties of emitted chunks and assets must be strings that are neither absolute nor relative paths, received "${validatedName}".`));
1298
1351
  if (file.type === "chunk") return this.context.emitChunk({
1299
1352
  preserveEntrySignatures: bindingifyPreserveEntrySignatures(file.preserveSignature),
1300
1353
  ...file
@@ -1330,6 +1383,9 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
1330
1383
  return parseAst(input, options);
1331
1384
  }
1332
1385
  };
1386
+ function createPluginContext(args, ctx) {
1387
+ return new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1388
+ }
1333
1389
  //#endregion
1334
1390
  //#region src/plugin/load-plugin-context.ts
1335
1391
  var LoadPluginContextImpl = class extends PluginContextImpl {
@@ -1383,36 +1439,19 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
1383
1439
  };
1384
1440
  //#endregion
1385
1441
  //#region src/plugin/bindingify-build-hooks.ts
1386
- function createPluginContext(args, ctx) {
1387
- return new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1388
- }
1389
1442
  function bindingifyBuildStart(args) {
1390
- const hook = args.plugin.buildStart;
1391
- if (!hook) return {};
1392
- const { handler, meta } = normalizeHook(hook);
1393
- return {
1394
- plugin: async (ctx, opts) => {
1395
- await handler.call(createPluginContext(args, ctx), args.pluginContextData.getInputOptions(opts));
1396
- },
1397
- meta: bindingifyPluginHookMeta(meta)
1398
- };
1443
+ return bindingifyHook(args.plugin.buildStart, ({ handler }) => ({ plugin: async (ctx, opts) => {
1444
+ await handler.call(createPluginContext(args, ctx), args.pluginContextData.getInputOptions(opts));
1445
+ } }));
1399
1446
  }
1400
1447
  function bindingifyBuildEnd(args) {
1401
- const hook = args.plugin.buildEnd;
1402
- if (!hook) return {};
1403
- const { handler, meta } = normalizeHook(hook);
1404
- return {
1405
- plugin: async (ctx, err) => {
1406
- await handler.call(createPluginContext(args, ctx), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1407
- },
1408
- meta: bindingifyPluginHookMeta(meta)
1409
- };
1448
+ return bindingifyHook(args.plugin.buildEnd, ({ handler }) => ({ plugin: async (ctx, err) => {
1449
+ await handler.call(createPluginContext(args, ctx), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1450
+ } }));
1410
1451
  }
1411
1452
  function bindingifyResolveId(args) {
1412
1453
  const hook = args.plugin.resolveId;
1413
- if (!hook) return {};
1414
- const { handler, meta, options } = normalizeHook(hook);
1415
- return {
1454
+ return bindingifyHook(hook, ({ handler, options }) => ({
1416
1455
  plugin: async (ctx, specifier, importer, extraOptions) => {
1417
1456
  const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : void 0;
1418
1457
  const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0, {
@@ -1442,44 +1481,34 @@ function bindingifyResolveId(args) {
1442
1481
  packageJsonPath: ret.packageJsonPath
1443
1482
  };
1444
1483
  },
1445
- meta: bindingifyPluginHookMeta(meta),
1446
1484
  filter: bindingifyResolveIdFilter(options.filter)
1447
- };
1485
+ }));
1448
1486
  }
1449
1487
  function bindingifyResolveDynamicImport(args) {
1450
- const hook = args.plugin.resolveDynamicImport;
1451
- if (!hook) return {};
1452
- const { handler, meta } = normalizeHook(hook);
1453
- return {
1454
- plugin: async (ctx, specifier, importer) => {
1455
- const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0);
1456
- if (ret == null) return;
1457
- if (ret === false) return {
1458
- id: specifier,
1459
- external: true
1460
- };
1461
- if (typeof ret === "string") return { id: ret };
1462
- const result = {
1463
- id: ret.id,
1464
- external: ret.external,
1465
- packageJsonPath: ret.packageJsonPath
1466
- };
1467
- if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
1468
- args.pluginContextData.updateModuleOption(ret.id, {
1469
- meta: ret.meta || {},
1470
- moduleSideEffects: ret.moduleSideEffects || null,
1471
- invalidate: false
1472
- });
1473
- return result;
1474
- },
1475
- meta: bindingifyPluginHookMeta(meta)
1476
- };
1488
+ return bindingifyHook(args.plugin.resolveDynamicImport, ({ handler }) => ({ plugin: async (ctx, specifier, importer) => {
1489
+ const ret = await handler.call(createPluginContext(args, ctx), specifier, importer ?? void 0);
1490
+ if (ret == null) return;
1491
+ if (ret === false) return {
1492
+ id: specifier,
1493
+ external: true
1494
+ };
1495
+ if (typeof ret === "string") return { id: ret };
1496
+ const result = {
1497
+ id: ret.id,
1498
+ external: ret.external,
1499
+ packageJsonPath: ret.packageJsonPath
1500
+ };
1501
+ if (ret.moduleSideEffects !== null) result.moduleSideEffects = ret.moduleSideEffects;
1502
+ args.pluginContextData.updateModuleOption(ret.id, {
1503
+ meta: ret.meta || {},
1504
+ moduleSideEffects: ret.moduleSideEffects || null,
1505
+ invalidate: false
1506
+ });
1507
+ return result;
1508
+ } }));
1477
1509
  }
1478
1510
  function bindingifyTransform(args) {
1479
- const hook = args.plugin.transform;
1480
- if (!hook) return {};
1481
- const { handler, meta, options } = normalizeHook(hook);
1482
- return {
1511
+ return bindingifyHook(args.plugin.transform, ({ handler, options }) => ({
1483
1512
  plugin: async (ctx, code, id, meta) => {
1484
1513
  let magicStringInstance, astInstance;
1485
1514
  Object.defineProperties(meta, {
@@ -1495,10 +1524,7 @@ function bindingifyTransform(args) {
1495
1524
  case "js":
1496
1525
  case "jsx":
1497
1526
  case "ts":
1498
- case "tsx":
1499
- lang = meta.moduleType;
1500
- break;
1501
- default: break;
1527
+ case "tsx": lang = meta.moduleType;
1502
1528
  }
1503
1529
  astInstance = parseAst(code, {
1504
1530
  astType: meta.moduleType.includes("ts") ? "ts" : "js",
@@ -1534,15 +1560,11 @@ function bindingifyTransform(args) {
1534
1560
  moduleType: ret.moduleType
1535
1561
  };
1536
1562
  },
1537
- meta: bindingifyPluginHookMeta(meta),
1538
1563
  filter: bindingifyTransformFilter(options.filter)
1539
- };
1564
+ }));
1540
1565
  }
1541
1566
  function bindingifyLoad(args) {
1542
- const hook = args.plugin.load;
1543
- if (!hook) return {};
1544
- const { handler, meta, options } = normalizeHook(hook);
1545
- return {
1567
+ return bindingifyHook(args.plugin.load, ({ handler, options }) => ({
1546
1568
  plugin: async (ctx, id) => {
1547
1569
  const ret = await handler.call(new LoadPluginContextImpl(args.outputOptions, ctx.inner(), args.plugin, args.pluginContextData, ctx, id, args.onLog, args.logLevel, args.watchMode), id);
1548
1570
  if (ret == null) return;
@@ -1560,9 +1582,8 @@ function bindingifyLoad(args) {
1560
1582
  moduleSideEffects: moduleOption.moduleSideEffects ?? void 0
1561
1583
  };
1562
1584
  },
1563
- meta: bindingifyPluginHookMeta(meta),
1564
1585
  filter: bindingifyLoadFilter(options.filter)
1565
- };
1586
+ }));
1566
1587
  }
1567
1588
  function preProcessSourceMap(ret, id) {
1568
1589
  if (!ret.map) return;
@@ -1575,34 +1596,19 @@ function preProcessSourceMap(ret, id) {
1575
1596
  return map;
1576
1597
  }
1577
1598
  function bindingifyModuleParsed(args) {
1578
- const hook = args.plugin.moduleParsed;
1579
- if (!hook) return {};
1580
- const { handler, meta } = normalizeHook(hook);
1581
- return {
1582
- plugin: async (ctx, moduleInfo) => {
1583
- await handler.call(createPluginContext(args, ctx), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
1584
- },
1585
- meta: bindingifyPluginHookMeta(meta)
1586
- };
1599
+ return bindingifyHook(args.plugin.moduleParsed, ({ handler }) => ({ plugin: async (ctx, moduleInfo) => {
1600
+ await handler.call(createPluginContext(args, ctx), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
1601
+ } }));
1587
1602
  }
1588
1603
  //#endregion
1589
1604
  //#region src/plugin/bindingify-output-hooks.ts
1590
1605
  function bindingifyRenderStart(args) {
1591
- const hook = args.plugin.renderStart;
1592
- if (!hook) return {};
1593
- const { handler, meta } = normalizeHook(hook);
1594
- return {
1595
- plugin: async (ctx, opts) => {
1596
- handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
1597
- },
1598
- meta: bindingifyPluginHookMeta(meta)
1599
- };
1606
+ return bindingifyHook(args.plugin.renderStart, ({ handler }) => ({ plugin: async (ctx, opts) => {
1607
+ await handler.call(createPluginContext(args, ctx), args.pluginContextData.getOutputOptions(opts), args.pluginContextData.getInputOptions(opts));
1608
+ } }));
1600
1609
  }
1601
1610
  function bindingifyRenderChunk(args) {
1602
- const hook = args.plugin.renderChunk;
1603
- if (!hook) return {};
1604
- const { handler, meta, options } = normalizeHook(hook);
1605
- return {
1611
+ return bindingifyHook(args.plugin.renderChunk, ({ handler, options }) => ({
1606
1612
  plugin: async (ctx, code, chunk, opts, meta) => {
1607
1613
  if (args.pluginContextData.getRenderChunkMeta() == null) args.pluginContextData.setRenderChunkMeta({ chunks: Object.fromEntries(Object.entries(meta.chunks).map(([key, value]) => [key, transformRenderedChunk(value)])) });
1608
1614
  const renderChunkMeta = args.pluginContextData.getRenderChunkMeta();
@@ -1615,7 +1621,7 @@ function bindingifyRenderChunk(args) {
1615
1621
  },
1616
1622
  configurable: true
1617
1623
  });
1618
- const ret = await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), renderChunkMeta);
1624
+ const ret = await handler.call(createPluginContext(args, ctx), code, transformRenderedChunk(chunk), args.pluginContextData.getOutputOptions(opts), renderChunkMeta);
1619
1625
  if (ret == null) return;
1620
1626
  if (ret instanceof RolldownMagicString) {
1621
1627
  const normalizedCode = ret.toString();
@@ -1666,150 +1672,81 @@ function bindingifyRenderChunk(args) {
1666
1672
  map: bindingifySourcemap(ret.map)
1667
1673
  };
1668
1674
  },
1669
- meta: bindingifyPluginHookMeta(meta),
1670
1675
  filter: bindingifyRenderChunkFilter(options.filter)
1671
- };
1676
+ }));
1672
1677
  }
1673
1678
  function bindingifyAugmentChunkHash(args) {
1674
- const hook = args.plugin.augmentChunkHash;
1675
- if (!hook) return {};
1676
- const { handler, meta } = normalizeHook(hook);
1677
- return {
1678
- plugin: async (ctx, chunk) => {
1679
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1680
- },
1681
- meta: bindingifyPluginHookMeta(meta)
1682
- };
1679
+ return bindingifyHook(args.plugin.augmentChunkHash, ({ handler }) => ({ plugin: async (ctx, chunk) => {
1680
+ return handler.call(createPluginContext(args, ctx), transformRenderedChunk(chunk));
1681
+ } }));
1682
+ }
1683
+ function bindingifyResolveFileUrl(args) {
1684
+ return bindingifyHook(args.plugin.resolveFileUrl, ({ handler }) => ({ plugin: async (ctx, resolveFileUrlArgs) => {
1685
+ return handler.call(createPluginContext(args, ctx), resolveFileUrlArgs);
1686
+ } }));
1683
1687
  }
1684
1688
  function bindingifyRenderError(args) {
1685
- const hook = args.plugin.renderError;
1686
- if (!hook) return {};
1687
- const { handler, meta } = normalizeHook(hook);
1689
+ return bindingifyHook(args.plugin.renderError, ({ handler }) => ({ plugin: async (ctx, err) => {
1690
+ await handler.call(createPluginContext(args, ctx), aggregateBindingErrorsIntoJsError(err));
1691
+ } }));
1692
+ }
1693
+ function createOutputBundle(args, ctx, bundle) {
1694
+ const changed = {
1695
+ updated: /* @__PURE__ */ new Set(),
1696
+ deleted: /* @__PURE__ */ new Set()
1697
+ };
1698
+ const context = createPluginContext(args, ctx);
1688
1699
  return {
1689
- plugin: async (ctx, err) => {
1690
- handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), aggregateBindingErrorsIntoJsError(err));
1691
- },
1692
- meta: bindingifyPluginHookMeta(meta)
1700
+ changed,
1701
+ context,
1702
+ output: transformToOutputBundle(context, unwrapBindingResult(bundle), changed)
1693
1703
  };
1694
1704
  }
1695
1705
  function bindingifyGenerateBundle(args) {
1696
- const hook = args.plugin.generateBundle;
1697
- if (!hook) return {};
1698
- const { handler, meta } = normalizeHook(hook);
1699
- return {
1700
- plugin: async (ctx, bundle, isWrite, opts) => {
1701
- const changed = {
1702
- updated: /* @__PURE__ */ new Set(),
1703
- deleted: /* @__PURE__ */ new Set()
1704
- };
1705
- const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1706
- const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1707
- await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
1708
- return collectChangedBundle(changed, output);
1709
- },
1710
- meta: bindingifyPluginHookMeta(meta)
1711
- };
1706
+ return bindingifyHook(args.plugin.generateBundle, ({ handler }) => ({ plugin: async (ctx, bundle, isWrite, opts) => {
1707
+ const { changed, context, output } = createOutputBundle(args, ctx, bundle);
1708
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output, isWrite);
1709
+ return collectChangedBundle(changed, output);
1710
+ } }));
1712
1711
  }
1713
1712
  function bindingifyWriteBundle(args) {
1714
- const hook = args.plugin.writeBundle;
1715
- if (!hook) return {};
1716
- const { handler, meta } = normalizeHook(hook);
1717
- return {
1718
- plugin: async (ctx, bundle, opts) => {
1719
- const changed = {
1720
- updated: /* @__PURE__ */ new Set(),
1721
- deleted: /* @__PURE__ */ new Set()
1722
- };
1723
- const context = new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode);
1724
- const output = transformToOutputBundle(context, unwrapBindingResult(bundle), changed);
1725
- await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
1726
- return collectChangedBundle(changed, output);
1727
- },
1728
- meta: bindingifyPluginHookMeta(meta)
1729
- };
1713
+ return bindingifyHook(args.plugin.writeBundle, ({ handler }) => ({ plugin: async (ctx, bundle, opts) => {
1714
+ const { changed, context, output } = createOutputBundle(args, ctx, bundle);
1715
+ await handler.call(context, args.pluginContextData.getOutputOptions(opts), output);
1716
+ return collectChangedBundle(changed, output);
1717
+ } }));
1730
1718
  }
1731
1719
  function bindingifyCloseBundle(args) {
1732
- const hook = args.plugin.closeBundle;
1733
- if (!hook) return {};
1734
- const { handler, meta } = normalizeHook(hook);
1735
- return {
1736
- plugin: async (ctx, err) => {
1737
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1738
- },
1739
- meta: bindingifyPluginHookMeta(meta)
1740
- };
1720
+ return bindingifyHook(args.plugin.closeBundle, ({ handler }) => ({ plugin: async (ctx, err) => {
1721
+ await handler.call(createPluginContext(args, ctx), err ? aggregateBindingErrorsIntoJsError(err) : void 0);
1722
+ } }));
1741
1723
  }
1742
- function bindingifyBanner(args) {
1743
- const hook = args.plugin.banner;
1744
- if (!hook) return {};
1745
- const { handler, meta } = normalizeHook(hook);
1746
- return {
1747
- plugin: async (ctx, chunk) => {
1748
- if (typeof handler === "string") return handler;
1749
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1750
- },
1751
- meta: bindingifyPluginHookMeta(meta)
1752
- };
1753
- }
1754
- function bindingifyFooter(args) {
1755
- const hook = args.plugin.footer;
1756
- if (!hook) return {};
1757
- const { handler, meta } = normalizeHook(hook);
1758
- return {
1759
- plugin: async (ctx, chunk) => {
1760
- if (typeof handler === "string") return handler;
1761
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1762
- },
1763
- meta: bindingifyPluginHookMeta(meta)
1764
- };
1765
- }
1766
- function bindingifyIntro(args) {
1767
- const hook = args.plugin.intro;
1768
- if (!hook) return {};
1769
- const { handler, meta } = normalizeHook(hook);
1770
- return {
1771
- plugin: async (ctx, chunk) => {
1772
- if (typeof handler === "string") return handler;
1773
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1774
- },
1775
- meta: bindingifyPluginHookMeta(meta)
1776
- };
1777
- }
1778
- function bindingifyOutro(args) {
1779
- const hook = args.plugin.outro;
1780
- if (!hook) return {};
1781
- const { handler, meta } = normalizeHook(hook);
1782
- return {
1783
- plugin: async (ctx, chunk) => {
1784
- if (typeof handler === "string") return handler;
1785
- return handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), transformRenderedChunk(chunk));
1786
- },
1787
- meta: bindingifyPluginHookMeta(meta)
1788
- };
1724
+ function bindingifyAddonHook(args, name) {
1725
+ return bindingifyHook(args.plugin[name], ({ handler }) => ({ plugin: async (ctx, chunk) => {
1726
+ if (typeof handler === "string") return handler;
1727
+ return handler.call(createPluginContext(args, ctx), transformRenderedChunk(chunk));
1728
+ } }));
1789
1729
  }
1790
1730
  //#endregion
1791
1731
  //#region src/plugin/bindingify-watch-hooks.ts
1732
+ function bindingifyHotUpdate(args) {
1733
+ return bindingifyHook(args.plugin.hotUpdate, ({ handler }) => ({ plugin: async (ctx, hookArgs) => {
1734
+ return await handler.call(createPluginContext(args, ctx), {
1735
+ type: hookArgs.kind,
1736
+ file: hookArgs.file,
1737
+ modules: hookArgs.modules
1738
+ }) ?? void 0;
1739
+ } }));
1740
+ }
1792
1741
  function bindingifyWatchChange(args) {
1793
- const hook = args.plugin.watchChange;
1794
- if (!hook) return {};
1795
- const { handler, meta } = normalizeHook(hook);
1796
- return {
1797
- plugin: async (ctx, id, event) => {
1798
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode), id, { event });
1799
- },
1800
- meta: bindingifyPluginHookMeta(meta)
1801
- };
1742
+ return bindingifyHook(args.plugin.watchChange, ({ handler }) => ({ plugin: async (ctx, id, event) => {
1743
+ await handler.call(createPluginContext(args, ctx), id, { event });
1744
+ } }));
1802
1745
  }
1803
1746
  function bindingifyCloseWatcher(args) {
1804
- const hook = args.plugin.closeWatcher;
1805
- if (!hook) return {};
1806
- const { handler, meta } = normalizeHook(hook);
1807
- return {
1808
- plugin: async (ctx) => {
1809
- await handler.call(new PluginContextImpl(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, args.watchMode));
1810
- },
1811
- meta: bindingifyPluginHookMeta(meta)
1812
- };
1747
+ return bindingifyHook(args.plugin.closeWatcher, ({ handler }) => ({ plugin: async (ctx) => {
1748
+ await handler.call(createPluginContext(args, ctx));
1749
+ } }));
1813
1750
  }
1814
1751
  //#endregion
1815
1752
  //#region src/plugin/generated/hook-usage.ts
@@ -1845,6 +1782,8 @@ function extractHookUsage(plugin) {
1845
1782
  if (plugin.footer) hookUsage.union(262144);
1846
1783
  if (plugin.intro) hookUsage.union(524288);
1847
1784
  if (plugin.outro) hookUsage.union(1048576);
1785
+ if (plugin.resolveFileUrl) hookUsage.union(2097152);
1786
+ if (plugin.hotUpdate) hookUsage.union(4194304);
1848
1787
  return hookUsage;
1849
1788
  }
1850
1789
  //#endregion
@@ -1869,16 +1808,18 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
1869
1808
  const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
1870
1809
  const { plugin: renderChunk, meta: renderChunkMeta, filter: renderChunkFilter } = bindingifyRenderChunk(args);
1871
1810
  const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
1811
+ const { plugin: resolveFileUrl, meta: resolveFileUrlMeta } = bindingifyResolveFileUrl(args);
1872
1812
  const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
1873
1813
  const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
1874
1814
  const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
1875
1815
  const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
1876
1816
  const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
1877
- const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
1878
- const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
1879
- const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
1880
- const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
1817
+ const { plugin: banner, meta: bannerMeta } = bindingifyAddonHook(args, "banner");
1818
+ const { plugin: footer, meta: footerMeta } = bindingifyAddonHook(args, "footer");
1819
+ const { plugin: intro, meta: introMeta } = bindingifyAddonHook(args, "intro");
1820
+ const { plugin: outro, meta: outroMeta } = bindingifyAddonHook(args, "outro");
1881
1821
  const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
1822
+ const { plugin: hotUpdate, meta: hotUpdateMeta } = bindingifyHotUpdate(args);
1882
1823
  const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
1883
1824
  let hookUsage = extractHookUsage(plugin).inner();
1884
1825
  return wrapHandlers({
@@ -1905,6 +1846,8 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
1905
1846
  renderChunkFilter,
1906
1847
  augmentChunkHash,
1907
1848
  augmentChunkHashMeta,
1849
+ resolveFileUrl,
1850
+ resolveFileUrlMeta,
1908
1851
  renderStart,
1909
1852
  renderStartMeta,
1910
1853
  renderError,
@@ -1925,6 +1868,8 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, nor
1925
1868
  outroMeta,
1926
1869
  watchChange,
1927
1870
  watchChangeMeta,
1871
+ hotUpdate,
1872
+ hotUpdateMeta,
1928
1873
  closeWatcher,
1929
1874
  closeWatcherMeta,
1930
1875
  hookUsage
@@ -1941,6 +1886,7 @@ function wrapHandlers(plugin) {
1941
1886
  "load",
1942
1887
  "renderChunk",
1943
1888
  "augmentChunkHash",
1889
+ "resolveFileUrl",
1944
1890
  "renderStart",
1945
1891
  "renderError",
1946
1892
  "generateBundle",
@@ -1951,6 +1897,7 @@ function wrapHandlers(plugin) {
1951
1897
  "intro",
1952
1898
  "outro",
1953
1899
  "watchChange",
1900
+ "hotUpdate",
1954
1901
  "closeWatcher"
1955
1902
  ]) {
1956
1903
  const handler = plugin[hookName];
@@ -1995,10 +1942,18 @@ function normalizeTransformOptions(inputOptions) {
1995
1942
  };
1996
1943
  }
1997
1944
  //#endregion
1945
+ //#region src/utils/default-dev-runtime.ts
1946
+ function getDefaultDevRuntime(host = "localhost", port = 3e3) {
1947
+ const runtimeEntry = fs.readFileSync(fileURLToPath(import.meta.resolve("rolldown/experimental/runtime")), "utf8");
1948
+ const runtimeHelperImportEnd = runtimeEntry.indexOf("\n");
1949
+ if (!runtimeEntry.startsWith("import ") || runtimeHelperImportEnd === -1) throw new Error("Expected the standalone runtime to start with a helper import");
1950
+ return `${runtimeEntry.slice(runtimeHelperImportEnd + 1)}\n${fs.readFileSync(fileURLToPath(import.meta.resolve("#default-runtime")), "utf8").replaceAll("$ADDR", `${host}:${port}`)}`;
1951
+ }
1952
+ //#endregion
1998
1953
  //#region src/utils/bindingify-input-options.ts
1999
1954
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode) {
2000
1955
  const plugins = rawPlugins.map((plugin) => {
2001
- if ("_parallel" in plugin) return;
1956
+ if (getParallelPluginInfo(plugin)) return;
2002
1957
  if (plugin instanceof BuiltinPlugin) switch (plugin.name) {
2003
1958
  case "builtin:vite-manifest": return bindingifyManifestPlugin(plugin, pluginContextData);
2004
1959
  default: return bindingifyBuiltInPlugin(plugin);
@@ -2048,8 +2003,16 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, pluginC
2048
2003
  }
2049
2004
  function bindingifyDevMode(devMode) {
2050
2005
  if (devMode) {
2051
- if (typeof devMode === "boolean") return devMode ? {} : void 0;
2052
- return devMode;
2006
+ if (typeof devMode === "boolean") return devMode ? {
2007
+ implement: getDefaultDevRuntime(),
2008
+ skipCommonRuntimeInjection: true
2009
+ } : void 0;
2010
+ const usesDefaultRuntime = devMode.implement == null;
2011
+ return {
2012
+ ...devMode,
2013
+ implement: devMode.implement ?? getDefaultDevRuntime(devMode.host, devMode.port),
2014
+ skipCommonRuntimeInjection: usesDefaultRuntime ? true : devMode.skipCommonRuntimeInjection
2015
+ };
2053
2016
  }
2054
2017
  }
2055
2018
  function bindingifyAttachDebugInfo(attachDebugInfo) {
@@ -2191,19 +2154,13 @@ function bindingifyTreeshakeOptions(config) {
2191
2154
  case "always":
2192
2155
  normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.Always;
2193
2156
  break;
2194
- case false:
2195
- normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.False;
2196
- break;
2197
- default:
2157
+ case false: normalizedConfig.propertyReadSideEffects = import_binding.BindingPropertyReadSideEffects.False;
2198
2158
  }
2199
2159
  switch (config.propertyWriteSideEffects) {
2200
2160
  case "always":
2201
2161
  normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.Always;
2202
2162
  break;
2203
- case false:
2204
- normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.False;
2205
- break;
2206
- default:
2163
+ case false: normalizedConfig.propertyWriteSideEffects = import_binding.BindingPropertyWriteSideEffects.False;
2207
2164
  }
2208
2165
  if (config.moduleSideEffects === void 0) normalizedConfig.moduleSideEffects = true;
2209
2166
  else if (config.moduleSideEffects === "no-external") normalizedConfig.moduleSideEffects = [{
@@ -2235,4 +2192,4 @@ function bindingifyPreserveEntrySignatures(preserveEntrySignatures) {
2235
2192
  };
2236
2193
  }
2237
2194
  //#endregion
2238
- export { version as S, LOG_LEVEL_INFO as _, transformModuleInfo as a, VERSION as b, __decorate as c, PlainObjectLike as d, MinimalPluginContextImpl as f, LOG_LEVEL_ERROR as g, LOG_LEVEL_DEBUG as h, PluginContextData as i, transformAssetSource as l, normalizeLog as m, bindingifyPlugin as n, transformToRollupOutput as o, normalizeHook as p, RolldownMagicString as r, transformRenderedChunk as s, bindingifyInputOptions as t, lazyProp as u, LOG_LEVEL_WARN as v, description as x, logLevelPriority as y };
2195
+ export { version as C, description as S, LOG_LEVEL_ERROR as _, transformModuleInfo as a, logLevelPriority as b, __decorate as c, PlainObjectLike as d, MinimalPluginContextImpl as f, LOG_LEVEL_DEBUG as g, normalizeLog as h, PluginContextData as i, transformAssetSource as l, normalizeHook as m, bindingifyPlugin as n, transformToRollupOutput as o, getParallelPluginInfo as p, RolldownMagicString as r, transformRenderedChunk as s, bindingifyInputOptions as t, lazyProp as u, LOG_LEVEL_INFO as v, VERSION as x, LOG_LEVEL_WARN as y };