rolldown 0.13.2-snapshot-46ac3fb-20241015003358 → 0.13.2-snapshot-e5c8b2f-20241017003312

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.
package/dist/cjs/cli.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { __export, __toESM } = require("../shared/chunk-JoMxl5V2.cjs");
4
- const { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, arraify, description, rolldown, version, watch } = require("../shared/src_index-tm1mV84P.cjs");
4
+ const { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, arraify, description, rolldown, version, watch } = require("../shared/src_index-AYQ0hgIb.cjs");
5
5
  const { createConsola } = require("../shared/consola.36c0034f-HcmWcfPe.cjs");
6
6
  const { default: nodePath } = __toESM(require("node:path"));
7
7
  const { ZodFirstPartyTypeKind, ZodFirstPartyTypeKind: ZodFirstPartyTypeKind$1, ZodFirstPartyTypeKind: ZodFirstPartyTypeKind$2, z, z: z$1, z: z$2, z: z$3 } = __toESM(require("zod"));
@@ -1318,6 +1318,15 @@ const voidNullable = () => {
1318
1318
  const inputOptionSchema = ((z$2.string()).or((z$2.string()).array())).or(z$2.record(z$2.string()));
1319
1319
  const externalSchema = ((stringOrRegExp()).or((stringOrRegExp()).array())).or(((z$2.function()).args(z$2.string(), (z$2.string()).optional(), z$2.boolean())).returns(voidNullableWith(z$2.boolean())));
1320
1320
  const moduleTypesSchema = z$2.record((((((((((z$2.literal("js")).or(z$2.literal("jsx"))).or(z$2.literal("ts"))).or(z$2.literal("tsx"))).or(z$2.literal("json"))).or(z$2.literal("text"))).or(z$2.literal("base64"))).or(z$2.literal("dataurl"))).or(z$2.literal("binary"))).or(z$2.literal("empty")));
1321
+ const jsxOptionsSchema = z$2.strictObject({
1322
+ mode: (((z$2.literal("classic")).or(z$2.literal("automatic"))).describe("Jsx transformation mode")).optional(),
1323
+ factory: ((z$2.string()).describe("Jsx element transformation")).optional(),
1324
+ fragment: ((z$2.string()).describe("Jsx fragment transformation")).optional(),
1325
+ importSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is classic")).optional(),
1326
+ jsxImportSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is automatic")).optional(),
1327
+ refresh: ((z$2.boolean()).describe("React refresh transformation")).optional(),
1328
+ development: ((z$2.boolean()).describe("Development specific information")).optional()
1329
+ });
1321
1330
  const inputOptionsSchema = z$2.strictObject({
1322
1331
  input: inputOptionSchema.optional(),
1323
1332
  plugins: ((phantom()).array()).optional(),
@@ -1350,7 +1359,8 @@ const inputOptionsSchema = z$2.strictObject({
1350
1359
  })).optional(),
1351
1360
  define: ((z$2.record(z$2.string())).describe("define global variables")).optional(),
1352
1361
  inject: (z$2.record((z$2.string()).or(z$2.tuple([z$2.string(), z$2.string()])))).optional(),
1353
- profilerNames: (z$2.boolean()).optional()
1362
+ profilerNames: (z$2.boolean()).optional(),
1363
+ jsx: jsxOptionsSchema.optional()
1354
1364
  });
1355
1365
  const inputCliOptionsSchema = (inputOptionsSchema.extend({
1356
1366
  external: ((z$2.array(z$2.string())).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")).optional(),
@@ -1611,7 +1621,7 @@ function parseCliArguments() {
1611
1621
  writable: true
1612
1622
  });
1613
1623
  } else if (type === "object" && typeof option.value === "string") {
1614
- const [key, value] = ((option.value?.split(",")).map((x) => x.split("=")))[0];
1624
+ const [key, value] = ((option.value.split(",")).map((x) => x.split("=")))[0];
1615
1625
  if (!values[option.name]) {
1616
1626
  Object.defineProperty(values, option.name, {
1617
1627
  value: {},
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { __toESM } = require("../shared/chunk-JoMxl5V2.cjs");
4
- const { aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins, dynamicImportVarsPlugin, experimental_scan, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, replacePlugin, require_binding, transformPlugin, wasmFallbackPlugin, wasmHelperPlugin } = require("../shared/src_index-tm1mV84P.cjs");
4
+ const { aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins, dynamicImportVarsPlugin, experimental_scan, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, replacePlugin, require_binding, transformPlugin, wasmFallbackPlugin, wasmHelperPlugin } = require("../shared/src_index-AYQ0hgIb.cjs");
5
5
  const { pathToFileURL } = __toESM(require("node:url"));
6
6
 
7
7
  //#region src/plugin/parallel-plugin.ts
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { VERSION, defineConfig, rolldown, watch } = require("../shared/src_index-tm1mV84P.cjs");
3
+ const { VERSION, defineConfig, rolldown, watch } = require("../shared/src_index-AYQ0hgIb.cjs");
4
4
 
5
5
  Object.defineProperty(exports, '__esModule', { value: true });
6
6
  exports.VERSION = VERSION;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const { __toESM } = require("../shared/chunk-JoMxl5V2.cjs");
4
- const { PluginContextData, bindingifyPlugin, require_binding } = require("../shared/src_index-tm1mV84P.cjs");
4
+ const { PluginContextData, bindingifyPlugin, require_binding } = require("../shared/src_index-AYQ0hgIb.cjs");
5
5
  const { parentPort, workerData } = __toESM(require("node:worker_threads"));
6
6
 
7
7
  //#region src/parallel-plugin-worker.ts
package/dist/esm/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, __export, arraify, description, rolldown, version, watch } from "../shared/src_index-_6D8oVEl.mjs";
3
+ import { LogLevelOptionSchema, LogLevelSchema, LogLevelWithErrorSchema, RollupLogSchema, RollupLogWithStringSchema, __export, arraify, description, rolldown, version, watch } from "../shared/src_index-TBh5p3Dw.mjs";
4
4
  import { createConsola } from "../shared/consola.36c0034f-Xyw7SC_7.mjs";
5
5
  import { default as nodePath } from "node:path";
6
6
  import { ZodFirstPartyTypeKind, ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$1, ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$2, z, z as z$1, z as z$2, z as z$3 } from "zod";
@@ -1317,6 +1317,15 @@ const voidNullable = () => {
1317
1317
  const inputOptionSchema = ((z$2.string()).or((z$2.string()).array())).or(z$2.record(z$2.string()));
1318
1318
  const externalSchema = ((stringOrRegExp()).or((stringOrRegExp()).array())).or(((z$2.function()).args(z$2.string(), (z$2.string()).optional(), z$2.boolean())).returns(voidNullableWith(z$2.boolean())));
1319
1319
  const moduleTypesSchema = z$2.record((((((((((z$2.literal("js")).or(z$2.literal("jsx"))).or(z$2.literal("ts"))).or(z$2.literal("tsx"))).or(z$2.literal("json"))).or(z$2.literal("text"))).or(z$2.literal("base64"))).or(z$2.literal("dataurl"))).or(z$2.literal("binary"))).or(z$2.literal("empty")));
1320
+ const jsxOptionsSchema = z$2.strictObject({
1321
+ mode: (((z$2.literal("classic")).or(z$2.literal("automatic"))).describe("Jsx transformation mode")).optional(),
1322
+ factory: ((z$2.string()).describe("Jsx element transformation")).optional(),
1323
+ fragment: ((z$2.string()).describe("Jsx fragment transformation")).optional(),
1324
+ importSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is classic")).optional(),
1325
+ jsxImportSource: ((z$2.string()).describe("Import the factory of element and fragment if mode is automatic")).optional(),
1326
+ refresh: ((z$2.boolean()).describe("React refresh transformation")).optional(),
1327
+ development: ((z$2.boolean()).describe("Development specific information")).optional()
1328
+ });
1320
1329
  const inputOptionsSchema = z$2.strictObject({
1321
1330
  input: inputOptionSchema.optional(),
1322
1331
  plugins: ((phantom()).array()).optional(),
@@ -1349,7 +1358,8 @@ const inputOptionsSchema = z$2.strictObject({
1349
1358
  })).optional(),
1350
1359
  define: ((z$2.record(z$2.string())).describe("define global variables")).optional(),
1351
1360
  inject: (z$2.record((z$2.string()).or(z$2.tuple([z$2.string(), z$2.string()])))).optional(),
1352
- profilerNames: (z$2.boolean()).optional()
1361
+ profilerNames: (z$2.boolean()).optional(),
1362
+ jsx: jsxOptionsSchema.optional()
1353
1363
  });
1354
1364
  const inputCliOptionsSchema = (inputOptionsSchema.extend({
1355
1365
  external: ((z$2.array(z$2.string())).describe("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")).optional(),
@@ -1610,7 +1620,7 @@ function parseCliArguments() {
1610
1620
  writable: true
1611
1621
  });
1612
1622
  } else if (type === "object" && typeof option.value === "string") {
1613
- const [key, value] = ((option.value?.split(",")).map((x) => x.split("=")))[0];
1623
+ const [key, value] = ((option.value.split(",")).map((x) => x.split("=")))[0];
1614
1624
  if (!values[option.name]) {
1615
1625
  Object.defineProperty(values, option.name, {
1616
1626
  value: {},
@@ -1,6 +1,6 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { __toESM, aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins, dynamicImportVarsPlugin, experimental_scan, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, replacePlugin, require_binding, transformPlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src_index-_6D8oVEl.mjs";
3
+ import { __toESM, aliasPlugin, buildImportAnalysisPlugin, composeJsPlugins, dynamicImportVarsPlugin, experimental_scan, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, replacePlugin, require_binding, transformPlugin, wasmFallbackPlugin, wasmHelperPlugin } from "../shared/src_index-TBh5p3Dw.mjs";
4
4
  import { pathToFileURL } from "node:url";
5
5
 
6
6
  //#region src/plugin/parallel-plugin.ts
@@ -1,5 +1,5 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { VERSION, defineConfig, rolldown, watch } from "../shared/src_index-_6D8oVEl.mjs";
3
+ import { VERSION, defineConfig, rolldown, watch } from "../shared/src_index-TBh5p3Dw.mjs";
4
4
 
5
5
  export { VERSION, defineConfig, rolldown, watch };
@@ -1,6 +1,6 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src_index-_6D8oVEl.mjs";
3
+ import { PluginContextData, __toESM, bindingifyPlugin, require_binding } from "../shared/src_index-TBh5p3Dw.mjs";
4
4
  import { parentPort, workerData } from "node:worker_threads";
5
5
 
6
6
  //#region src/parallel-plugin-worker.ts
@@ -162,6 +162,8 @@ function __napi_rs_initialize_modules(__napiInstance) {
162
162
  __napiInstance.exports['__napi_register__ExtensionAliasItem_struct_99']?.()
163
163
  __napiInstance.exports['__napi_register__BindingSourcemap_struct_100']?.()
164
164
  __napiInstance.exports['__napi_register__BindingJsonSourcemap_struct_101']?.()
165
+ __napiInstance.exports['__napi_register__BindingWatcher_struct_102']?.()
166
+ __napiInstance.exports['__napi_register__BindingWatcher_impl_104']?.()
165
167
  }
166
168
  module.exports.BindingLog = __napiModule.exports.BindingLog
167
169
  module.exports.BindingModuleInfo = __napiModule.exports.BindingModuleInfo
@@ -170,6 +172,7 @@ module.exports.BindingOutputChunk = __napiModule.exports.BindingOutputChunk
170
172
  module.exports.BindingOutputs = __napiModule.exports.BindingOutputs
171
173
  module.exports.BindingPluginContext = __napiModule.exports.BindingPluginContext
172
174
  module.exports.BindingTransformPluginContext = __napiModule.exports.BindingTransformPluginContext
175
+ module.exports.BindingWatcher = __napiModule.exports.BindingWatcher
173
176
  module.exports.Bundler = __napiModule.exports.Bundler
174
177
  module.exports.ParallelJsPluginRegistry = __napiModule.exports.ParallelJsPluginRegistry
175
178
  module.exports.BindingBuiltinPluginName = __napiModule.exports.BindingBuiltinPluginName
@@ -1,5 +1,6 @@
1
1
  const { __commonJSMin, __toESM } = require("./chunk-JoMxl5V2.cjs");
2
- const { default: path, default: path$1 } = __toESM(require("node:path"));
2
+ const { spawn } = __toESM(require("node:child_process"));
3
+ const { default: path, default: path$1, resolve } = __toESM(require("node:path"));
3
4
  const { z } = __toESM(require("zod"));
4
5
  const { isRegExp, isRegExp: isRegExp$1, isRegExp: isRegExp$2 } = __toESM(require("node:util/types"));
5
6
  const { Worker } = __toESM(require("node:worker_threads"));
@@ -492,6 +493,7 @@ var require_binding = __commonJSMin((exports, module) => {
492
493
  module.exports.BindingOutputs = nativeBinding.BindingOutputs;
493
494
  module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
494
495
  module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
496
+ module.exports.BindingWatcher = nativeBinding.BindingWatcher;
495
497
  module.exports.Bundler = nativeBinding.Bundler;
496
498
  module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
497
499
  module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
@@ -1500,6 +1502,19 @@ function bindingifyWatchChange(plugin, options, pluginContextData) {
1500
1502
  meta: bindingifyPluginHookMeta(meta)
1501
1503
  };
1502
1504
  }
1505
+ function bindingifyCloseWatcher(plugin, options, pluginContextData) {
1506
+ const hook = plugin.closeWatcher;
1507
+ if (!hook) {
1508
+ return {};
1509
+ }
1510
+ const { handler: handler, meta: meta } = normalizeHook(hook);
1511
+ return {
1512
+ plugin: async (ctx) => {
1513
+ await handler.call(new PluginContext(options, ctx, plugin, pluginContextData));
1514
+ },
1515
+ meta: bindingifyPluginHookMeta(meta)
1516
+ };
1517
+ }
1503
1518
 
1504
1519
  //#endregion
1505
1520
  //#region src/plugin/bindingify-plugin.ts
@@ -1523,6 +1538,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
1523
1538
  const { plugin: intro, meta: introMeta } = bindingifyIntro(plugin, options, pluginContextData);
1524
1539
  const { plugin: outro, meta: outroMeta } = bindingifyOutro(plugin, options, pluginContextData);
1525
1540
  const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(plugin, options, pluginContextData);
1541
+ const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(plugin, options, pluginContextData);
1526
1542
  return {
1527
1543
  name: plugin.name ?? "unknown",
1528
1544
  buildStart,
@@ -1565,7 +1581,9 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
1565
1581
  outro,
1566
1582
  outroMeta,
1567
1583
  watchChange,
1568
- watchChangeMeta
1584
+ watchChangeMeta,
1585
+ closeWatcher,
1586
+ closeWatcherMeta
1569
1587
  };
1570
1588
  }
1571
1589
 
@@ -1874,7 +1892,8 @@ function bindingifyInputOptions(options, outputOptions) {
1874
1892
  strictExecutionOrder: options.experimental?.strictExecutionOrder,
1875
1893
  disableLiveBindings: options.experimental?.disableLiveBindings
1876
1894
  },
1877
- profilerNames: options?.profilerNames
1895
+ profilerNames: options?.profilerNames,
1896
+ jsx: bindingifyJsx(options.jsx)
1878
1897
  };
1879
1898
  }
1880
1899
  function bindingifyLogLevel(logLevel) {
@@ -1900,6 +1919,19 @@ function bindingifyInput(input) {
1900
1919
  });
1901
1920
  }
1902
1921
  }
1922
+ function bindingifyJsx(input) {
1923
+ if (input) {
1924
+ const mode = input.mode ?? "classic";
1925
+ return {
1926
+ runtime: mode,
1927
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
1928
+ pragma: input.factory,
1929
+ pragmaFrag: input.fragment,
1930
+ development: input.development,
1931
+ refresh: input.refresh
1932
+ };
1933
+ }
1934
+ }
1903
1935
 
1904
1936
  //#endregion
1905
1937
  //#region src/utils/initialize-parallel-plugins.ts
@@ -1945,12 +1977,12 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
1945
1977
  try {
1946
1978
  worker = new Worker(new URL(urlString), {workerData});
1947
1979
  worker.unref();
1948
- await new Promise((resolve, reject) => {
1980
+ await new Promise((resolve$1, reject) => {
1949
1981
  worker.once("message", async (message) => {
1950
1982
  if (message.type === "error") {
1951
1983
  reject(message.error);
1952
1984
  } else {
1953
- resolve();
1985
+ resolve$1();
1954
1986
  }
1955
1987
  });
1956
1988
  });
@@ -2078,7 +2110,7 @@ function t(...n) {
2078
2110
 
2079
2111
  //#endregion
2080
2112
  //#region src/constants/plugin.ts
2081
- const ENUMERATED_PLUGIN_HOOK_NAMES = ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange",];
2113
+ const ENUMERATED_PLUGIN_HOOK_NAMES = ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange", "closeWatcher",];
2082
2114
  const DEFINED_HOOK_NAMES = {
2083
2115
  [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
2084
2116
  [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
@@ -2101,7 +2133,8 @@ const DEFINED_HOOK_NAMES = {
2101
2133
  [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
2102
2134
  [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
2103
2135
  [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
2104
- [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21]
2136
+ [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
2137
+ [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
2105
2138
  };
2106
2139
 
2107
2140
  //#endregion
@@ -2209,6 +2242,14 @@ function createComposedPlugin(plugins) {
2209
2242
  }
2210
2243
  break;
2211
2244
  }
2245
+ case "closeWatcher": {
2246
+ const handlers = batchedHooks.closeWatcher ?? [];
2247
+ batchedHooks.closeWatcher = handlers;
2248
+ if (plugin.closeWatcher) {
2249
+ handlers.push([plugin.closeWatcher, plugin]);
2250
+ }
2251
+ break;
2252
+ }
2212
2253
  default: {}
2213
2254
  }
2214
2255
  });
@@ -2393,6 +2434,18 @@ function createComposedPlugin(plugins) {
2393
2434
  }
2394
2435
  break;
2395
2436
  }
2437
+ case "closeWatcher": {
2438
+ if (batchedHooks.closeWatcher) {
2439
+ const batchedHandlers = batchedHooks.closeWatcher;
2440
+ composed.closeWatcher = async function() {
2441
+ await Promise.all(batchedHandlers.map(([handler, plugin]) => {
2442
+ const { handler: handlerFn } = normalizeHook(handler);
2443
+ return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
2444
+ }));
2445
+ };
2446
+ }
2447
+ break;
2448
+ }
2396
2449
  default: {}
2397
2450
  }
2398
2451
  });
@@ -2609,6 +2662,29 @@ async function createBundler(inputOptions, outputOptions) {
2609
2662
  }
2610
2663
  }
2611
2664
 
2665
+ //#endregion
2666
+ //#region src/watcher.ts
2667
+ class Watcher {
2668
+ closed;
2669
+ controller;
2670
+ inner;
2671
+ constructor(inner) {
2672
+ this.closed = false;
2673
+ this.controller = new AbortController();
2674
+ this.inner = inner;
2675
+ }
2676
+ async close() {
2677
+ this.closed = true;
2678
+ await this.inner.close();
2679
+ this.controller.abort();
2680
+ }
2681
+ watch() {
2682
+ const watcherWorkerPath = resolve("rolldown", "./watcher-worker.js");
2683
+ const child = spawn(process.argv[0], [watcherWorkerPath], {signal: this.controller.signal});
2684
+ child.on("error", () => {});
2685
+ }
2686
+ }
2687
+
2612
2688
  //#endregion
2613
2689
  //#region src/rolldown-build.ts
2614
2690
  class RolldownBuild {
@@ -2643,7 +2719,10 @@ class RolldownBuild {
2643
2719
  }
2644
2720
  async watch() {
2645
2721
  const bundler = await this.#getBundler({});
2646
- await bundler.watch();
2722
+ const bindingWatcher = await bundler.watch();
2723
+ const watcher = new Watcher(bindingWatcher);
2724
+ watcher.watch();
2725
+ return watcher;
2647
2726
  }
2648
2727
  }
2649
2728
 
@@ -2653,7 +2732,7 @@ const rolldown = async (input) => {
2653
2732
  return new RolldownBuild(input);
2654
2733
  };
2655
2734
  const watch = async (input) => {
2656
- (new RolldownBuild(input)).watch();
2735
+ return (new RolldownBuild(input)).watch();
2657
2736
  };
2658
2737
  const experimental_scan = async (input) => {
2659
2738
  const { bundler: bundler, stopWorkers: stopWorkers } = await createBundler(input, {});
@@ -1,6 +1,7 @@
1
1
  import __node_module__ from 'node:module';
2
2
  const require = __node_module__.createRequire(import.meta.url)
3
- import { default as path, default as path$1 } from "node:path";
3
+ import { spawn } from "node:child_process";
4
+ import { default as path, default as path$1, resolve } from "node:path";
4
5
  import { z } from "zod";
5
6
  import { isRegExp, isRegExp as isRegExp$1, isRegExp as isRegExp$2 } from "node:util/types";
6
7
  import { Worker } from "node:worker_threads";
@@ -523,6 +524,7 @@ var require_binding = __commonJSMin((exports, module) => {
523
524
  module.exports.BindingOutputs = nativeBinding.BindingOutputs;
524
525
  module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
525
526
  module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
527
+ module.exports.BindingWatcher = nativeBinding.BindingWatcher;
526
528
  module.exports.Bundler = nativeBinding.Bundler;
527
529
  module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
528
530
  module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
@@ -1531,6 +1533,19 @@ function bindingifyWatchChange(plugin, options, pluginContextData) {
1531
1533
  meta: bindingifyPluginHookMeta(meta)
1532
1534
  };
1533
1535
  }
1536
+ function bindingifyCloseWatcher(plugin, options, pluginContextData) {
1537
+ const hook = plugin.closeWatcher;
1538
+ if (!hook) {
1539
+ return {};
1540
+ }
1541
+ const { handler: handler, meta: meta } = normalizeHook(hook);
1542
+ return {
1543
+ plugin: async (ctx) => {
1544
+ await handler.call(new PluginContext(options, ctx, plugin, pluginContextData));
1545
+ },
1546
+ meta: bindingifyPluginHookMeta(meta)
1547
+ };
1548
+ }
1534
1549
 
1535
1550
  //#endregion
1536
1551
  //#region src/plugin/bindingify-plugin.ts
@@ -1554,6 +1569,7 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
1554
1569
  const { plugin: intro, meta: introMeta } = bindingifyIntro(plugin, options, pluginContextData);
1555
1570
  const { plugin: outro, meta: outroMeta } = bindingifyOutro(plugin, options, pluginContextData);
1556
1571
  const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(plugin, options, pluginContextData);
1572
+ const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(plugin, options, pluginContextData);
1557
1573
  return {
1558
1574
  name: plugin.name ?? "unknown",
1559
1575
  buildStart,
@@ -1596,7 +1612,9 @@ function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
1596
1612
  outro,
1597
1613
  outroMeta,
1598
1614
  watchChange,
1599
- watchChangeMeta
1615
+ watchChangeMeta,
1616
+ closeWatcher,
1617
+ closeWatcherMeta
1600
1618
  };
1601
1619
  }
1602
1620
 
@@ -1905,7 +1923,8 @@ function bindingifyInputOptions(options, outputOptions) {
1905
1923
  strictExecutionOrder: options.experimental?.strictExecutionOrder,
1906
1924
  disableLiveBindings: options.experimental?.disableLiveBindings
1907
1925
  },
1908
- profilerNames: options?.profilerNames
1926
+ profilerNames: options?.profilerNames,
1927
+ jsx: bindingifyJsx(options.jsx)
1909
1928
  };
1910
1929
  }
1911
1930
  function bindingifyLogLevel(logLevel) {
@@ -1931,6 +1950,19 @@ function bindingifyInput(input) {
1931
1950
  });
1932
1951
  }
1933
1952
  }
1953
+ function bindingifyJsx(input) {
1954
+ if (input) {
1955
+ const mode = input.mode ?? "classic";
1956
+ return {
1957
+ runtime: mode,
1958
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
1959
+ pragma: input.factory,
1960
+ pragmaFrag: input.fragment,
1961
+ development: input.development,
1962
+ refresh: input.refresh
1963
+ };
1964
+ }
1965
+ }
1934
1966
 
1935
1967
  //#endregion
1936
1968
  //#region src/utils/initialize-parallel-plugins.ts
@@ -1976,12 +2008,12 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
1976
2008
  try {
1977
2009
  worker = new Worker(new URL(urlString), {workerData});
1978
2010
  worker.unref();
1979
- await new Promise((resolve, reject) => {
2011
+ await new Promise((resolve$1, reject) => {
1980
2012
  worker.once("message", async (message) => {
1981
2013
  if (message.type === "error") {
1982
2014
  reject(message.error);
1983
2015
  } else {
1984
- resolve();
2016
+ resolve$1();
1985
2017
  }
1986
2018
  });
1987
2019
  });
@@ -2109,7 +2141,7 @@ function t(...n) {
2109
2141
 
2110
2142
  //#endregion
2111
2143
  //#region src/constants/plugin.ts
2112
- const ENUMERATED_PLUGIN_HOOK_NAMES = ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange",];
2144
+ const ENUMERATED_PLUGIN_HOOK_NAMES = ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange", "closeWatcher",];
2113
2145
  const DEFINED_HOOK_NAMES = {
2114
2146
  [ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
2115
2147
  [ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
@@ -2132,7 +2164,8 @@ const DEFINED_HOOK_NAMES = {
2132
2164
  [ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
2133
2165
  [ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
2134
2166
  [ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
2135
- [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21]
2167
+ [ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
2168
+ [ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22]
2136
2169
  };
2137
2170
 
2138
2171
  //#endregion
@@ -2240,6 +2273,14 @@ function createComposedPlugin(plugins) {
2240
2273
  }
2241
2274
  break;
2242
2275
  }
2276
+ case "closeWatcher": {
2277
+ const handlers = batchedHooks.closeWatcher ?? [];
2278
+ batchedHooks.closeWatcher = handlers;
2279
+ if (plugin.closeWatcher) {
2280
+ handlers.push([plugin.closeWatcher, plugin]);
2281
+ }
2282
+ break;
2283
+ }
2243
2284
  default: {}
2244
2285
  }
2245
2286
  });
@@ -2424,6 +2465,18 @@ function createComposedPlugin(plugins) {
2424
2465
  }
2425
2466
  break;
2426
2467
  }
2468
+ case "closeWatcher": {
2469
+ if (batchedHooks.closeWatcher) {
2470
+ const batchedHandlers = batchedHooks.closeWatcher;
2471
+ composed.closeWatcher = async function() {
2472
+ await Promise.all(batchedHandlers.map(([handler, plugin]) => {
2473
+ const { handler: handlerFn } = normalizeHook(handler);
2474
+ return handlerFn.call(applyFixedPluginResolveFn(this, plugin));
2475
+ }));
2476
+ };
2477
+ }
2478
+ break;
2479
+ }
2427
2480
  default: {}
2428
2481
  }
2429
2482
  });
@@ -2640,6 +2693,29 @@ async function createBundler(inputOptions, outputOptions) {
2640
2693
  }
2641
2694
  }
2642
2695
 
2696
+ //#endregion
2697
+ //#region src/watcher.ts
2698
+ class Watcher {
2699
+ closed;
2700
+ controller;
2701
+ inner;
2702
+ constructor(inner) {
2703
+ this.closed = false;
2704
+ this.controller = new AbortController();
2705
+ this.inner = inner;
2706
+ }
2707
+ async close() {
2708
+ this.closed = true;
2709
+ await this.inner.close();
2710
+ this.controller.abort();
2711
+ }
2712
+ watch() {
2713
+ const watcherWorkerPath = resolve("rolldown", "./watcher-worker.js");
2714
+ const child = spawn(process.argv[0], [watcherWorkerPath], {signal: this.controller.signal});
2715
+ child.on("error", () => {});
2716
+ }
2717
+ }
2718
+
2643
2719
  //#endregion
2644
2720
  //#region src/rolldown-build.ts
2645
2721
  class RolldownBuild {
@@ -2674,7 +2750,10 @@ class RolldownBuild {
2674
2750
  }
2675
2751
  async watch() {
2676
2752
  const bundler = await this.#getBundler({});
2677
- await bundler.watch();
2753
+ const bindingWatcher = await bundler.watch();
2754
+ const watcher = new Watcher(bindingWatcher);
2755
+ watcher.watch();
2756
+ return watcher;
2678
2757
  }
2679
2758
  }
2680
2759
 
@@ -2684,7 +2763,7 @@ const rolldown = async (input) => {
2684
2763
  return new RolldownBuild(input);
2685
2764
  };
2686
2765
  const watch = async (input) => {
2687
- (new RolldownBuild(input)).watch();
2766
+ return (new RolldownBuild(input)).watch();
2688
2767
  };
2689
2768
  const experimental_scan = async (input) => {
2690
2769
  const { bundler: bundler, stopWorkers: stopWorkers } = await createBundler(input, {});
@@ -0,0 +1 @@
1
+ while (true) {}
@@ -57,13 +57,17 @@ export declare class BindingTransformPluginContext {
57
57
  inner(): BindingPluginContext
58
58
  }
59
59
 
60
+ export declare class BindingWatcher {
61
+ close(): Promise<void>
62
+ }
63
+
60
64
  export declare class Bundler {
61
65
  constructor(inputOptions: BindingInputOptions, outputOptions: BindingOutputOptions, parallelPluginsRegistry?: ParallelJsPluginRegistry | undefined | null)
62
66
  write(): Promise<BindingOutputs>
63
67
  generate(): Promise<BindingOutputs>
64
68
  scan(): Promise<void>
65
69
  close(): Promise<void>
66
- watch(): Promise<void>
70
+ watch(): Promise<BindingWatcher>
67
71
  }
68
72
 
69
73
  export declare class ParallelJsPluginRegistry {
@@ -229,6 +233,7 @@ export interface BindingInputOptions {
229
233
  inject?: Array<BindingInjectImportNamed | BindingInjectImportNamespace>
230
234
  experimental?: BindingExperimentalOptions
231
235
  profilerNames?: boolean
236
+ jsx?: JsxOptions
232
237
  }
233
238
 
234
239
  export interface BindingJsonPluginConfig {
@@ -344,6 +349,8 @@ export interface BindingPluginOptions {
344
349
  closeBundleMeta?: BindingPluginHookMeta
345
350
  watchChange?: (ctx: BindingPluginContext, path: string, event: string) => MaybePromise<VoidNullable>
346
351
  watchChangeMeta?: BindingPluginHookMeta
352
+ closeWatcher?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
353
+ closeWatcherMeta?: BindingPluginHookMeta
347
354
  banner?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
348
355
  bannerMeta?: BindingPluginHookMeta
349
356
  footer?: (ctx: BindingPluginContext, chunk: RenderedChunk) => void
@@ -70,6 +70,31 @@ export declare const cliOptionsSchema: z.ZodObject<z.objectUtil.extendShape<z.ob
70
70
  define: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
71
71
  inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
72
72
  profilerNames: z.ZodOptional<z.ZodBoolean>;
73
+ jsx: z.ZodOptional<z.ZodObject<{
74
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"automatic">]>>;
75
+ factory: z.ZodOptional<z.ZodString>;
76
+ fragment: z.ZodOptional<z.ZodString>;
77
+ importSource: z.ZodOptional<z.ZodString>;
78
+ jsxImportSource: z.ZodOptional<z.ZodString>;
79
+ refresh: z.ZodOptional<z.ZodBoolean>;
80
+ development: z.ZodOptional<z.ZodBoolean>;
81
+ }, "strict", z.ZodTypeAny, {
82
+ mode?: "classic" | "automatic" | undefined;
83
+ factory?: string | undefined;
84
+ fragment?: string | undefined;
85
+ importSource?: string | undefined;
86
+ jsxImportSource?: string | undefined;
87
+ refresh?: boolean | undefined;
88
+ development?: boolean | undefined;
89
+ }, {
90
+ mode?: "classic" | "automatic" | undefined;
91
+ factory?: string | undefined;
92
+ fragment?: string | undefined;
93
+ importSource?: string | undefined;
94
+ jsxImportSource?: string | undefined;
95
+ refresh?: boolean | undefined;
96
+ development?: boolean | undefined;
97
+ }>>;
73
98
  }, {
74
99
  external: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
75
100
  inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -161,6 +186,15 @@ export declare const cliOptionsSchema: z.ZodObject<z.objectUtil.extendShape<z.ob
161
186
  shimMissingExports?: boolean | undefined;
162
187
  treeshake?: boolean | undefined;
163
188
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
189
+ jsx?: {
190
+ mode?: "classic" | "automatic" | undefined;
191
+ factory?: string | undefined;
192
+ fragment?: string | undefined;
193
+ importSource?: string | undefined;
194
+ jsxImportSource?: string | undefined;
195
+ refresh?: boolean | undefined;
196
+ development?: boolean | undefined;
197
+ } | undefined;
164
198
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
165
199
  define?: Record<string, string> | undefined;
166
200
  inject?: Record<string, string> | undefined;
@@ -197,6 +231,15 @@ export declare const cliOptionsSchema: z.ZodObject<z.objectUtil.extendShape<z.ob
197
231
  shimMissingExports?: boolean | undefined;
198
232
  treeshake?: boolean | undefined;
199
233
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
234
+ jsx?: {
235
+ mode?: "classic" | "automatic" | undefined;
236
+ factory?: string | undefined;
237
+ fragment?: string | undefined;
238
+ importSource?: string | undefined;
239
+ jsxImportSource?: string | undefined;
240
+ refresh?: boolean | undefined;
241
+ development?: boolean | undefined;
242
+ } | undefined;
200
243
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
201
244
  define?: Record<string, string> | undefined;
202
245
  inject?: Record<string, string> | undefined;
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from '../plugin';
2
- export declare const ENUMERATED_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange"];
2
+ export declare const ENUMERATED_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "augmentChunkHash", "buildEnd", "onLog", "resolveDynamicImport", "generateBundle", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "footer", "banner", "intro", "outro", "closeBundle", "watchChange", "closeWatcher"];
3
3
  /**
4
4
  * Names of all properties in a `Plugin` object. Includes `name` and `api`.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  import { RolldownOutput, RolldownOutputAsset, RolldownOutputChunk, SourceMap } from './types/rolldown-output';
2
- import type { ExternalOption, InputOption, InputOptions } from './options/input-options';
2
+ import type { ExternalOption, InputOption, InputOptions, JsxOptions } from './options/input-options';
3
3
  import type { ModuleFormat, OutputOptions } from './options/output-options';
4
4
  import type { RolldownOptions } from './types/rolldown-options';
5
5
  import type { AsyncPluginHooks, CustomPluginOptions, FunctionPluginHooks, ImportKind, LoadResult, ModuleOptions, ModuleType, ObjectHook, ParallelPluginHooks, PartialResolvedId, Plugin, RolldownPlugin, ResolveIdResult, ResolvedId, SourceDescription, TransformResult } from './plugin';
@@ -20,6 +20,6 @@ import { ExistingRawSourceMap, SourceMapInput } from './types/sourcemap';
20
20
  import { OutputBundle } from './types/output-bundle';
21
21
  export { defineConfig, rolldown, watch };
22
22
  export declare const VERSION: string;
23
- export type { RolldownOutputAsset, RolldownOutputChunk, RolldownOptions, RolldownOutput, RolldownBuild, InputOptions, NormalizedInputOptions, OutputOptions, NormalizedOutputOptions, Plugin, RolldownPlugin, DefineParallelPluginResult, ConfigExport, ImportKind, InputOption, ExternalOption, ModuleFormat, ModuleType, InternalModuleFormat, LoadResult, TransformResult, ResolveIdResult, PluginContext, TransformPluginContext, ObjectHook, RenderedChunk, PreRenderedChunk, SourceMap, SourceDescription, PartialNull, PartialResolvedId, ResolvedId, ModuleOptions, ModuleInfo, MinimalPluginContext, EmittedFile, EmittedAsset, CustomPluginOptions, AsyncPluginHooks, ParallelPluginHooks, FunctionPluginHooks, ExistingRawSourceMap, SourceMapInput, OutputBundle, };
23
+ export type { RolldownOutputAsset, RolldownOutputChunk, RolldownOptions, RolldownOutput, RolldownBuild, InputOptions, NormalizedInputOptions, OutputOptions, NormalizedOutputOptions, Plugin, RolldownPlugin, DefineParallelPluginResult, ConfigExport, ImportKind, InputOption, ExternalOption, ModuleFormat, ModuleType, InternalModuleFormat, LoadResult, TransformResult, ResolveIdResult, PluginContext, TransformPluginContext, ObjectHook, RenderedChunk, PreRenderedChunk, SourceMap, SourceDescription, PartialNull, PartialResolvedId, ResolvedId, ModuleOptions, ModuleInfo, MinimalPluginContext, EmittedFile, EmittedAsset, CustomPluginOptions, AsyncPluginHooks, ParallelPluginHooks, FunctionPluginHooks, ExistingRawSourceMap, SourceMapInput, OutputBundle, JsxOptions, };
24
24
  export type { RolldownOutput as RollupOutput, RolldownOptions as RollupOptions, RolldownBuild as RollupBuild, RolldownOutputChunk as OutputChunk, RolldownOutputAsset as OutputAsset, };
25
25
  export type { RollupError, RollupLog, LoggingFunction } from './rollup';
@@ -3,6 +3,31 @@ import { z } from 'zod';
3
3
  import { TreeshakingOptions } from '../treeshake';
4
4
  declare const inputOptionSchema: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodRecord<z.ZodString, z.ZodString>]>;
5
5
  declare const externalSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodOptional<z.ZodString>, z.ZodBoolean], z.ZodUnknown>, z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodVoid, z.ZodNull]>, z.ZodUndefined]>, z.ZodBoolean]>>]>;
6
+ declare const jsxOptionsSchema: z.ZodObject<{
7
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"automatic">]>>;
8
+ factory: z.ZodOptional<z.ZodString>;
9
+ fragment: z.ZodOptional<z.ZodString>;
10
+ importSource: z.ZodOptional<z.ZodString>;
11
+ jsxImportSource: z.ZodOptional<z.ZodString>;
12
+ refresh: z.ZodOptional<z.ZodBoolean>;
13
+ development: z.ZodOptional<z.ZodBoolean>;
14
+ }, "strict", z.ZodTypeAny, {
15
+ mode?: "classic" | "automatic" | undefined;
16
+ factory?: string | undefined;
17
+ fragment?: string | undefined;
18
+ importSource?: string | undefined;
19
+ jsxImportSource?: string | undefined;
20
+ refresh?: boolean | undefined;
21
+ development?: boolean | undefined;
22
+ }, {
23
+ mode?: "classic" | "automatic" | undefined;
24
+ factory?: string | undefined;
25
+ fragment?: string | undefined;
26
+ importSource?: string | undefined;
27
+ jsxImportSource?: string | undefined;
28
+ refresh?: boolean | undefined;
29
+ development?: boolean | undefined;
30
+ }>;
6
31
  export declare const inputOptionsSchema: z.ZodObject<{
7
32
  input: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>, z.ZodRecord<z.ZodString, z.ZodString>]>>;
8
33
  plugins: z.ZodOptional<z.ZodArray<z.ZodType<RolldownPluginRec, z.ZodTypeDef, RolldownPluginRec>, "many">>;
@@ -68,6 +93,31 @@ export declare const inputOptionsSchema: z.ZodObject<{
68
93
  define: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
69
94
  inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
70
95
  profilerNames: z.ZodOptional<z.ZodBoolean>;
96
+ jsx: z.ZodOptional<z.ZodObject<{
97
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"automatic">]>>;
98
+ factory: z.ZodOptional<z.ZodString>;
99
+ fragment: z.ZodOptional<z.ZodString>;
100
+ importSource: z.ZodOptional<z.ZodString>;
101
+ jsxImportSource: z.ZodOptional<z.ZodString>;
102
+ refresh: z.ZodOptional<z.ZodBoolean>;
103
+ development: z.ZodOptional<z.ZodBoolean>;
104
+ }, "strict", z.ZodTypeAny, {
105
+ mode?: "classic" | "automatic" | undefined;
106
+ factory?: string | undefined;
107
+ fragment?: string | undefined;
108
+ importSource?: string | undefined;
109
+ jsxImportSource?: string | undefined;
110
+ refresh?: boolean | undefined;
111
+ development?: boolean | undefined;
112
+ }, {
113
+ mode?: "classic" | "automatic" | undefined;
114
+ factory?: string | undefined;
115
+ fragment?: string | undefined;
116
+ importSource?: string | undefined;
117
+ jsxImportSource?: string | undefined;
118
+ refresh?: boolean | undefined;
119
+ development?: boolean | undefined;
120
+ }>>;
71
121
  }, "strict", z.ZodTypeAny, {
72
122
  input?: string | string[] | Record<string, string> | undefined;
73
123
  plugins?: RolldownPluginRec[] | undefined;
@@ -92,6 +142,15 @@ export declare const inputOptionsSchema: z.ZodObject<{
92
142
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
93
143
  onLog?: ((args_0: "info" | "debug" | "warn", args_1: any, args_2: (args_0: "info" | "debug" | "warn" | "error", args_1: any, ...args: unknown[]) => unknown, ...args: unknown[]) => unknown) | undefined;
94
144
  onwarn?: ((args_0: any, args_1: (args_0: any, ...args: unknown[]) => unknown, ...args: unknown[]) => unknown) | undefined;
145
+ jsx?: {
146
+ mode?: "classic" | "automatic" | undefined;
147
+ factory?: string | undefined;
148
+ fragment?: string | undefined;
149
+ importSource?: string | undefined;
150
+ jsxImportSource?: string | undefined;
151
+ refresh?: boolean | undefined;
152
+ development?: boolean | undefined;
153
+ } | undefined;
95
154
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
96
155
  experimental?: {
97
156
  enableComposingJsPlugins?: boolean | undefined;
@@ -125,6 +184,15 @@ export declare const inputOptionsSchema: z.ZodObject<{
125
184
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
126
185
  onLog?: ((args_0: "info" | "debug" | "warn", args_1: any, args_2: (args_0: "info" | "debug" | "warn" | "error", args_1: any, ...args: unknown[]) => unknown, ...args: unknown[]) => unknown) | undefined;
127
186
  onwarn?: ((args_0: any, args_1: (args_0: any, ...args: unknown[]) => unknown, ...args: unknown[]) => unknown) | undefined;
187
+ jsx?: {
188
+ mode?: "classic" | "automatic" | undefined;
189
+ factory?: string | undefined;
190
+ fragment?: string | undefined;
191
+ importSource?: string | undefined;
192
+ jsxImportSource?: string | undefined;
193
+ refresh?: boolean | undefined;
194
+ development?: boolean | undefined;
195
+ } | undefined;
128
196
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
129
197
  experimental?: {
130
198
  enableComposingJsPlugins?: boolean | undefined;
@@ -200,6 +268,31 @@ export declare const inputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extend
200
268
  define: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
201
269
  inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
202
270
  profilerNames: z.ZodOptional<z.ZodBoolean>;
271
+ jsx: z.ZodOptional<z.ZodObject<{
272
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"classic">, z.ZodLiteral<"automatic">]>>;
273
+ factory: z.ZodOptional<z.ZodString>;
274
+ fragment: z.ZodOptional<z.ZodString>;
275
+ importSource: z.ZodOptional<z.ZodString>;
276
+ jsxImportSource: z.ZodOptional<z.ZodString>;
277
+ refresh: z.ZodOptional<z.ZodBoolean>;
278
+ development: z.ZodOptional<z.ZodBoolean>;
279
+ }, "strict", z.ZodTypeAny, {
280
+ mode?: "classic" | "automatic" | undefined;
281
+ factory?: string | undefined;
282
+ fragment?: string | undefined;
283
+ importSource?: string | undefined;
284
+ jsxImportSource?: string | undefined;
285
+ refresh?: boolean | undefined;
286
+ development?: boolean | undefined;
287
+ }, {
288
+ mode?: "classic" | "automatic" | undefined;
289
+ factory?: string | undefined;
290
+ fragment?: string | undefined;
291
+ importSource?: string | undefined;
292
+ jsxImportSource?: string | undefined;
293
+ refresh?: boolean | undefined;
294
+ development?: boolean | undefined;
295
+ }>>;
203
296
  }, {
204
297
  external: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
205
298
  inject: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -211,6 +304,15 @@ export declare const inputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extend
211
304
  shimMissingExports?: boolean | undefined;
212
305
  treeshake?: boolean | undefined;
213
306
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
307
+ jsx?: {
308
+ mode?: "classic" | "automatic" | undefined;
309
+ factory?: string | undefined;
310
+ fragment?: string | undefined;
311
+ importSource?: string | undefined;
312
+ jsxImportSource?: string | undefined;
313
+ refresh?: boolean | undefined;
314
+ development?: boolean | undefined;
315
+ } | undefined;
214
316
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
215
317
  define?: Record<string, string> | undefined;
216
318
  inject?: Record<string, string> | undefined;
@@ -221,6 +323,15 @@ export declare const inputCliOptionsSchema: z.ZodObject<Omit<z.objectUtil.extend
221
323
  shimMissingExports?: boolean | undefined;
222
324
  treeshake?: boolean | undefined;
223
325
  logLevel?: "info" | "debug" | "warn" | "silent" | undefined;
326
+ jsx?: {
327
+ mode?: "classic" | "automatic" | undefined;
328
+ factory?: string | undefined;
329
+ fragment?: string | undefined;
330
+ importSource?: string | undefined;
331
+ jsxImportSource?: string | undefined;
332
+ refresh?: boolean | undefined;
333
+ development?: boolean | undefined;
334
+ } | undefined;
224
335
  moduleTypes?: Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty"> | undefined;
225
336
  define?: Record<string, string> | undefined;
226
337
  inject?: Record<string, string> | undefined;
@@ -255,4 +366,5 @@ interface OverwriteInputOptionsWithDoc {
255
366
  export type InputOption = z.infer<typeof inputOptionSchema>;
256
367
  export type InputOptions = Omit<RawInputOptions, keyof OverwriteInputOptionsWithDoc> & OverwriteInputOptionsWithDoc;
257
368
  export type ExternalOption = z.infer<typeof externalSchema>;
369
+ export type JsxOptions = z.infer<typeof jsxOptionsSchema>;
258
370
  export {};
@@ -4,3 +4,4 @@ import type { Plugin } from './index';
4
4
  import { PluginContextData } from './plugin-context-data';
5
5
  import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
6
6
  export declare function bindingifyWatchChange(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['watchChange']>;
7
+ export declare function bindingifyCloseWatcher(plugin: Plugin, options: NormalizedInputOptions, pluginContextData: PluginContextData): PluginHookWithBindingExt<BindingPluginOptions['closeWatcher']>;
@@ -80,6 +80,7 @@ export interface FunctionPluginHooks {
80
80
  [DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
81
81
  event: ChangeEvent;
82
82
  }) => void;
83
+ [DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
83
84
  }
84
85
  export type ChangeEvent = 'create' | 'update' | 'delete';
85
86
  export type PluginOrder = 'pre' | 'post' | null;
@@ -1,11 +1,12 @@
1
1
  import type { OutputOptions } from './options/output-options';
2
2
  import type { RolldownOutput } from './types/rolldown-output';
3
3
  import type { InputOptions } from './options/input-options';
4
+ import { Watcher } from './watcher';
4
5
  export declare class RolldownBuild {
5
6
  #private;
6
7
  constructor(inputOptions: InputOptions);
7
8
  generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
8
9
  write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
9
10
  close(): Promise<void>;
10
- watch(): Promise<void>;
11
+ watch(): Promise<Watcher>;
11
12
  }
@@ -1,7 +1,8 @@
1
1
  import type { InputOptions } from './options/input-options';
2
2
  import { RolldownBuild } from './rolldown-build';
3
+ import { Watcher } from './watcher';
3
4
  export declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
4
- export declare const watch: (input: InputOptions) => Promise<void>;
5
+ export declare const watch: (input: InputOptions) => Promise<Watcher>;
5
6
  /**
6
7
  * @description
7
8
  * This is an experimental API. It's behavior may change in the future.
@@ -0,0 +1,9 @@
1
+ import { BindingWatcher } from './binding';
2
+ export declare class Watcher {
3
+ closed: boolean;
4
+ controller: AbortController;
5
+ inner: BindingWatcher;
6
+ constructor(inner: BindingWatcher);
7
+ close(): Promise<void>;
8
+ watch(): void;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown",
3
- "version": "0.13.2-snapshot-46ac3fb-20241015003358",
3
+ "version": "0.13.2-snapshot-e5c8b2f-20241017003312",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "require": "./dist/cjs/parallel-plugin.cjs",
45
45
  "import": "./dist/esm/parallel-plugin.mjs"
46
46
  },
47
+ "./watcher-worker": "./dist/shared/watcher-worker.js",
47
48
  "./package.json": "./package.json"
48
49
  },
49
50
  "imports": {
@@ -103,21 +104,21 @@
103
104
  "why-is-node-running": "^3.0.0",
104
105
  "zod-to-json-schema": "^3.23.2",
105
106
  "@rolldown/testing": "0.0.1",
106
- "rolldown": "0.13.2-snapshot-46ac3fb-20241015003358"
107
+ "rolldown": "0.13.2-snapshot-e5c8b2f-20241017003312"
107
108
  },
108
109
  "optionalDependencies": {
109
- "@rolldown/binding-darwin-arm64": "0.13.2-snapshot-46ac3fb-20241015003358",
110
- "@rolldown/binding-darwin-x64": "0.13.2-snapshot-46ac3fb-20241015003358",
111
- "@rolldown/binding-linux-arm-gnueabihf": "0.13.2-snapshot-46ac3fb-20241015003358",
112
- "@rolldown/binding-freebsd-x64": "0.13.2-snapshot-46ac3fb-20241015003358",
113
- "@rolldown/binding-linux-arm64-gnu": "0.13.2-snapshot-46ac3fb-20241015003358",
114
- "@rolldown/binding-linux-arm64-musl": "0.13.2-snapshot-46ac3fb-20241015003358",
115
- "@rolldown/binding-linux-x64-gnu": "0.13.2-snapshot-46ac3fb-20241015003358",
116
- "@rolldown/binding-wasm32-wasi": "0.13.2-snapshot-46ac3fb-20241015003358",
117
- "@rolldown/binding-linux-x64-musl": "0.13.2-snapshot-46ac3fb-20241015003358",
118
- "@rolldown/binding-win32-ia32-msvc": "0.13.2-snapshot-46ac3fb-20241015003358",
119
- "@rolldown/binding-win32-x64-msvc": "0.13.2-snapshot-46ac3fb-20241015003358",
120
- "@rolldown/binding-win32-arm64-msvc": "0.13.2-snapshot-46ac3fb-20241015003358"
110
+ "@rolldown/binding-darwin-arm64": "0.13.2-snapshot-e5c8b2f-20241017003312",
111
+ "@rolldown/binding-freebsd-x64": "0.13.2-snapshot-e5c8b2f-20241017003312",
112
+ "@rolldown/binding-linux-arm-gnueabihf": "0.13.2-snapshot-e5c8b2f-20241017003312",
113
+ "@rolldown/binding-darwin-x64": "0.13.2-snapshot-e5c8b2f-20241017003312",
114
+ "@rolldown/binding-linux-arm64-gnu": "0.13.2-snapshot-e5c8b2f-20241017003312",
115
+ "@rolldown/binding-linux-arm64-musl": "0.13.2-snapshot-e5c8b2f-20241017003312",
116
+ "@rolldown/binding-linux-x64-gnu": "0.13.2-snapshot-e5c8b2f-20241017003312",
117
+ "@rolldown/binding-linux-x64-musl": "0.13.2-snapshot-e5c8b2f-20241017003312",
118
+ "@rolldown/binding-wasm32-wasi": "0.13.2-snapshot-e5c8b2f-20241017003312",
119
+ "@rolldown/binding-win32-arm64-msvc": "0.13.2-snapshot-e5c8b2f-20241017003312",
120
+ "@rolldown/binding-win32-ia32-msvc": "0.13.2-snapshot-e5c8b2f-20241017003312",
121
+ "@rolldown/binding-win32-x64-msvc": "0.13.2-snapshot-e5c8b2f-20241017003312"
121
122
  },
122
123
  "scripts": {
123
124
  "# Scrips for binding #": "_",