@rolldown/browser 1.0.0-beta.36 → 1.0.0-beta.37

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/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import "./shared/binding-wK0CRIMb.mjs";
2
- import { ConfigExport, defineConfig } from "./shared/define-config-BcNhk996.mjs";
1
+ import "./shared/binding-Cjs27cfu.mjs";
2
+ import { ConfigExport, defineConfig } from "./shared/define-config-DzsPS4fI.mjs";
3
3
 
4
4
  //#region src/utils/load-config.d.ts
5
5
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
package/dist/config.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { defineConfig, version } from "./shared/src-Dc4fRARy.mjs";
1
+ import { defineConfig, version } from "./shared/src-kVjGhYdF.mjs";
2
2
  import "./shared/parse-ast-index-C3TkGcEQ.mjs";
3
3
  import "./shared/dist-CHTC3-kR.mjs";
4
- import { loadConfig } from "./shared/load-config-M8Gvqt1X.mjs";
4
+ import { loadConfig } from "./shared/load-config-efyGD8HY.mjs";
5
5
 
6
6
  //#region src/config.ts
7
7
  const VERSION = version;
@@ -1,4 +1,4 @@
1
- import { PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBuiltinPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./src-Cl6h35QH.js";
1
+ import { BuiltinPlugin, PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./src-C2GHZXDs.js";
2
2
  import { BindingBundler, BindingDevEngine, ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi-browser.js";
3
3
 
4
4
  //#region src/api/dev/dev-engine.ts
@@ -12,7 +12,11 @@ var DevEngine = class DevEngine {
12
12
  onHmrUpdates: devOptions.onHmrUpdates,
13
13
  watch: devOptions.watch && {
14
14
  usePolling: devOptions.watch.usePolling,
15
- pollInterval: devOptions.watch.pollInterval
15
+ pollInterval: devOptions.watch.pollInterval,
16
+ useDebounce: devOptions.watch.useDebounce,
17
+ debounceDuration: devOptions.watch.debounceDuration,
18
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
19
+ debounceTickRate: devOptions.watch.debounceTickRate
16
20
  }
17
21
  };
18
22
  const inner = new BindingDevEngine(options.bundlerOptions, bindingDevOptions);
@@ -35,6 +39,16 @@ var DevEngine = class DevEngine {
35
39
  async ensureLatestBuild() {
36
40
  await this.#inner.ensureLatestBuild();
37
41
  }
42
+ /**
43
+ * Returns true if a new build is scheduled.
44
+ */
45
+ async scheduleBuildIfStale() {
46
+ const scheduled = await this.#inner.scheduleBuildIfStale();
47
+ if (scheduled) {
48
+ scheduled.wait().catch(() => {});
49
+ return scheduled.alreadyScheduled() ? "alreadyScheduled" : "scheduled";
50
+ }
51
+ }
38
52
  async invalidate(file, firstInvalidatedBy) {
39
53
  return this.#inner.invalidate(file, firstInvalidatedBy);
40
54
  }
@@ -68,7 +82,471 @@ function defineParallelPlugin(pluginPath) {
68
82
  //#endregion
69
83
  //#region src/builtin-plugin/alias-plugin.ts
70
84
  function aliasPlugin(config) {
71
- return createBuiltinPlugin("builtin:alias", config);
85
+ return new BuiltinPlugin("builtin:alias", config);
86
+ }
87
+
88
+ //#endregion
89
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
90
+ const LogLevels = {
91
+ silent: Number.NEGATIVE_INFINITY,
92
+ fatal: 0,
93
+ error: 0,
94
+ warn: 1,
95
+ log: 2,
96
+ info: 3,
97
+ success: 3,
98
+ fail: 3,
99
+ ready: 3,
100
+ start: 3,
101
+ box: 3,
102
+ debug: 4,
103
+ trace: 5,
104
+ verbose: Number.POSITIVE_INFINITY
105
+ };
106
+ const LogTypes = {
107
+ silent: { level: -1 },
108
+ fatal: { level: LogLevels.fatal },
109
+ error: { level: LogLevels.error },
110
+ warn: { level: LogLevels.warn },
111
+ log: { level: LogLevels.log },
112
+ info: { level: LogLevels.info },
113
+ success: { level: LogLevels.success },
114
+ fail: { level: LogLevels.fail },
115
+ ready: { level: LogLevels.info },
116
+ start: { level: LogLevels.info },
117
+ box: { level: LogLevels.info },
118
+ debug: { level: LogLevels.debug },
119
+ trace: { level: LogLevels.trace },
120
+ verbose: { level: LogLevels.verbose }
121
+ };
122
+ function isPlainObject$1(value) {
123
+ if (value === null || typeof value !== "object") return false;
124
+ const prototype = Object.getPrototypeOf(value);
125
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
126
+ if (Symbol.iterator in value) return false;
127
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
128
+ return true;
129
+ }
130
+ function _defu(baseObject, defaults, namespace = ".", merger) {
131
+ if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
132
+ const object = Object.assign({}, defaults);
133
+ for (const key in baseObject) {
134
+ if (key === "__proto__" || key === "constructor") continue;
135
+ const value = baseObject[key];
136
+ if (value === null || value === void 0) continue;
137
+ if (merger && merger(object, key, value, namespace)) continue;
138
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
139
+ else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
140
+ else object[key] = value;
141
+ }
142
+ return object;
143
+ }
144
+ function createDefu(merger) {
145
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
146
+ }
147
+ const defu = createDefu();
148
+ function isPlainObject(obj) {
149
+ return Object.prototype.toString.call(obj) === "[object Object]";
150
+ }
151
+ function isLogObj(arg) {
152
+ if (!isPlainObject(arg)) return false;
153
+ if (!arg.message && !arg.args) return false;
154
+ if (arg.stack) return false;
155
+ return true;
156
+ }
157
+ let paused = false;
158
+ const queue = [];
159
+ var Consola = class Consola {
160
+ options;
161
+ _lastLog;
162
+ _mockFn;
163
+ /**
164
+ * Creates an instance of Consola with specified options or defaults.
165
+ *
166
+ * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
167
+ */
168
+ constructor(options = {}) {
169
+ const types = options.types || LogTypes;
170
+ this.options = defu({
171
+ ...options,
172
+ defaults: { ...options.defaults },
173
+ level: _normalizeLogLevel(options.level, types),
174
+ reporters: [...options.reporters || []]
175
+ }, {
176
+ types: LogTypes,
177
+ throttle: 1e3,
178
+ throttleMin: 5,
179
+ formatOptions: {
180
+ date: true,
181
+ colors: false,
182
+ compact: true
183
+ }
184
+ });
185
+ for (const type in types) {
186
+ const defaults = {
187
+ type,
188
+ ...this.options.defaults,
189
+ ...types[type]
190
+ };
191
+ this[type] = this._wrapLogFn(defaults);
192
+ this[type].raw = this._wrapLogFn(defaults, true);
193
+ }
194
+ if (this.options.mockFn) this.mockTypes();
195
+ this._lastLog = {};
196
+ }
197
+ /**
198
+ * Gets the current log level of the Consola instance.
199
+ *
200
+ * @returns {number} The current log level.
201
+ */
202
+ get level() {
203
+ return this.options.level;
204
+ }
205
+ /**
206
+ * Sets the minimum log level that will be output by the instance.
207
+ *
208
+ * @param {number} level - The new log level to set.
209
+ */
210
+ set level(level) {
211
+ this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
212
+ }
213
+ /**
214
+ * Displays a prompt to the user and returns the response.
215
+ * Throw an error if `prompt` is not supported by the current configuration.
216
+ *
217
+ * @template T
218
+ * @param {string} message - The message to display in the prompt.
219
+ * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
220
+ * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
221
+ */
222
+ prompt(message, opts) {
223
+ if (!this.options.prompt) throw new Error("prompt is not supported!");
224
+ return this.options.prompt(message, opts);
225
+ }
226
+ /**
227
+ * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
228
+ *
229
+ * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
230
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
231
+ */
232
+ create(options) {
233
+ const instance = new Consola({
234
+ ...this.options,
235
+ ...options
236
+ });
237
+ if (this._mockFn) instance.mockTypes(this._mockFn);
238
+ return instance;
239
+ }
240
+ /**
241
+ * Creates a new Consola instance with the specified default log object properties.
242
+ *
243
+ * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
244
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
245
+ */
246
+ withDefaults(defaults) {
247
+ return this.create({
248
+ ...this.options,
249
+ defaults: {
250
+ ...this.options.defaults,
251
+ ...defaults
252
+ }
253
+ });
254
+ }
255
+ /**
256
+ * Creates a new Consola instance with a specified tag, which will be included in every log.
257
+ *
258
+ * @param {string} tag - The tag to include in each log of the new instance.
259
+ * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
260
+ */
261
+ withTag(tag) {
262
+ return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
263
+ }
264
+ /**
265
+ * Adds a custom reporter to the Consola instance.
266
+ * Reporters will be called for each log message, depending on their implementation and log level.
267
+ *
268
+ * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
269
+ * @returns {Consola} The current Consola instance.
270
+ */
271
+ addReporter(reporter) {
272
+ this.options.reporters.push(reporter);
273
+ return this;
274
+ }
275
+ /**
276
+ * Removes a custom reporter from the Consola instance.
277
+ * If no reporter is specified, all reporters will be removed.
278
+ *
279
+ * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
280
+ * @returns {Consola} The current Consola instance.
281
+ */
282
+ removeReporter(reporter) {
283
+ if (reporter) {
284
+ const i = this.options.reporters.indexOf(reporter);
285
+ if (i !== -1) return this.options.reporters.splice(i, 1);
286
+ } else this.options.reporters.splice(0);
287
+ return this;
288
+ }
289
+ /**
290
+ * Replaces all reporters of the Consola instance with the specified array of reporters.
291
+ *
292
+ * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
293
+ * @returns {Consola} The current Consola instance.
294
+ */
295
+ setReporters(reporters) {
296
+ this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
297
+ return this;
298
+ }
299
+ wrapAll() {
300
+ this.wrapConsole();
301
+ this.wrapStd();
302
+ }
303
+ restoreAll() {
304
+ this.restoreConsole();
305
+ this.restoreStd();
306
+ }
307
+ /**
308
+ * Overrides console methods with Consola logging methods for consistent logging.
309
+ */
310
+ wrapConsole() {
311
+ for (const type in this.options.types) {
312
+ if (!console["__" + type]) console["__" + type] = console[type];
313
+ console[type] = this[type].raw;
314
+ }
315
+ }
316
+ /**
317
+ * Restores the original console methods, removing Consola overrides.
318
+ */
319
+ restoreConsole() {
320
+ for (const type in this.options.types) if (console["__" + type]) {
321
+ console[type] = console["__" + type];
322
+ delete console["__" + type];
323
+ }
324
+ }
325
+ /**
326
+ * Overrides standard output and error streams to redirect them through Consola.
327
+ */
328
+ wrapStd() {
329
+ this._wrapStream(this.options.stdout, "log");
330
+ this._wrapStream(this.options.stderr, "log");
331
+ }
332
+ _wrapStream(stream, type) {
333
+ if (!stream) return;
334
+ if (!stream.__write) stream.__write = stream.write;
335
+ stream.write = (data) => {
336
+ this[type].raw(String(data).trim());
337
+ };
338
+ }
339
+ /**
340
+ * Restores the original standard output and error streams, removing the Consola redirection.
341
+ */
342
+ restoreStd() {
343
+ this._restoreStream(this.options.stdout);
344
+ this._restoreStream(this.options.stderr);
345
+ }
346
+ _restoreStream(stream) {
347
+ if (!stream) return;
348
+ if (stream.__write) {
349
+ stream.write = stream.__write;
350
+ delete stream.__write;
351
+ }
352
+ }
353
+ /**
354
+ * Pauses logging, queues incoming logs until resumed.
355
+ */
356
+ pauseLogs() {
357
+ paused = true;
358
+ }
359
+ /**
360
+ * Resumes logging, processing any queued logs.
361
+ */
362
+ resumeLogs() {
363
+ paused = false;
364
+ const _queue = queue.splice(0);
365
+ for (const item of _queue) item[0]._logFn(item[1], item[2]);
366
+ }
367
+ /**
368
+ * Replaces logging methods with mocks if a mock function is provided.
369
+ *
370
+ * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
371
+ */
372
+ mockTypes(mockFn) {
373
+ const _mockFn = mockFn || this.options.mockFn;
374
+ this._mockFn = _mockFn;
375
+ if (typeof _mockFn !== "function") return;
376
+ for (const type in this.options.types) {
377
+ this[type] = _mockFn(type, this.options.types[type]) || this[type];
378
+ this[type].raw = this[type];
379
+ }
380
+ }
381
+ _wrapLogFn(defaults, isRaw) {
382
+ return (...args) => {
383
+ if (paused) {
384
+ queue.push([
385
+ this,
386
+ defaults,
387
+ args,
388
+ isRaw
389
+ ]);
390
+ return;
391
+ }
392
+ return this._logFn(defaults, args, isRaw);
393
+ };
394
+ }
395
+ _logFn(defaults, args, isRaw) {
396
+ if ((defaults.level || 0) > this.level) return false;
397
+ const logObj = {
398
+ date: /* @__PURE__ */ new Date(),
399
+ args: [],
400
+ ...defaults,
401
+ level: _normalizeLogLevel(defaults.level, this.options.types)
402
+ };
403
+ if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
404
+ else logObj.args = [...args];
405
+ if (logObj.message) {
406
+ logObj.args.unshift(logObj.message);
407
+ delete logObj.message;
408
+ }
409
+ if (logObj.additional) {
410
+ if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
411
+ logObj.args.push("\n" + logObj.additional.join("\n"));
412
+ delete logObj.additional;
413
+ }
414
+ logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
415
+ logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
416
+ const resolveLog = (newLog = false) => {
417
+ const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
418
+ if (this._lastLog.object && repeated > 0) {
419
+ const args2 = [...this._lastLog.object.args];
420
+ if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
421
+ this._log({
422
+ ...this._lastLog.object,
423
+ args: args2
424
+ });
425
+ this._lastLog.count = 1;
426
+ }
427
+ if (newLog) {
428
+ this._lastLog.object = logObj;
429
+ this._log(logObj);
430
+ }
431
+ };
432
+ clearTimeout(this._lastLog.timeout);
433
+ const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
434
+ this._lastLog.time = logObj.date;
435
+ if (diffTime < this.options.throttle) try {
436
+ const serializedLog = JSON.stringify([
437
+ logObj.type,
438
+ logObj.tag,
439
+ logObj.args
440
+ ]);
441
+ const isSameLog = this._lastLog.serialized === serializedLog;
442
+ this._lastLog.serialized = serializedLog;
443
+ if (isSameLog) {
444
+ this._lastLog.count = (this._lastLog.count || 0) + 1;
445
+ if (this._lastLog.count > this.options.throttleMin) {
446
+ this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
447
+ return;
448
+ }
449
+ }
450
+ } catch {}
451
+ resolveLog(true);
452
+ }
453
+ _log(logObj) {
454
+ for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
455
+ }
456
+ };
457
+ function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
458
+ if (input === void 0) return defaultLevel;
459
+ if (typeof input === "number") return input;
460
+ if (types[input] && types[input].level !== void 0) return types[input].level;
461
+ return defaultLevel;
462
+ }
463
+ Consola.prototype.add = Consola.prototype.addReporter;
464
+ Consola.prototype.remove = Consola.prototype.removeReporter;
465
+ Consola.prototype.clear = Consola.prototype.removeReporter;
466
+ Consola.prototype.withScope = Consola.prototype.withTag;
467
+ Consola.prototype.mock = Consola.prototype.mockTypes;
468
+ Consola.prototype.pause = Consola.prototype.pauseLogs;
469
+ Consola.prototype.resume = Consola.prototype.resumeLogs;
470
+ function createConsola$1(options = {}) {
471
+ return new Consola(options);
472
+ }
473
+
474
+ //#endregion
475
+ //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/browser.mjs
476
+ var BrowserReporter = class {
477
+ options;
478
+ defaultColor;
479
+ levelColorMap;
480
+ typeColorMap;
481
+ constructor(options) {
482
+ this.options = { ...options };
483
+ this.defaultColor = "#7f8c8d";
484
+ this.levelColorMap = {
485
+ 0: "#c0392b",
486
+ 1: "#f39c12",
487
+ 3: "#00BCD4"
488
+ };
489
+ this.typeColorMap = { success: "#2ecc71" };
490
+ }
491
+ _getLogFn(level) {
492
+ if (level < 1) return console.__error || console.error;
493
+ if (level === 1) return console.__warn || console.warn;
494
+ return console.__log || console.log;
495
+ }
496
+ log(logObj) {
497
+ const consoleLogFn = this._getLogFn(logObj.level);
498
+ const type = logObj.type === "log" ? "" : logObj.type;
499
+ const tag = logObj.tag || "";
500
+ const style = `
501
+ background: ${this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor};
502
+ border-radius: 0.5em;
503
+ color: white;
504
+ font-weight: bold;
505
+ padding: 2px 0.5em;
506
+ `;
507
+ const badge = `%c${[tag, type].filter(Boolean).join(":")}`;
508
+ if (typeof logObj.args[0] === "string") consoleLogFn(`${badge}%c ${logObj.args[0]}`, style, "", ...logObj.args.slice(1));
509
+ else consoleLogFn(badge, style, ...logObj.args);
510
+ }
511
+ };
512
+ function createConsola(options = {}) {
513
+ return createConsola$1({
514
+ reporters: options.reporters || [new BrowserReporter({})],
515
+ prompt(message, options2 = {}) {
516
+ if (options2.type === "confirm") return Promise.resolve(confirm(message));
517
+ return Promise.resolve(prompt(message));
518
+ },
519
+ ...options
520
+ });
521
+ }
522
+ const consola = createConsola();
523
+
524
+ //#endregion
525
+ //#region src/cli/logger.ts
526
+ /**
527
+ * Console logger
528
+ */
529
+ const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
530
+ function createTestingLogger() {
531
+ const types = [
532
+ "silent",
533
+ "fatal",
534
+ "error",
535
+ "warn",
536
+ "log",
537
+ "info",
538
+ "success",
539
+ "fail",
540
+ "ready",
541
+ "start",
542
+ "box",
543
+ "debug",
544
+ "trace",
545
+ "verbose"
546
+ ];
547
+ const ret = Object.create(null);
548
+ for (const type of types) ret[type] = console.log;
549
+ return ret;
72
550
  }
73
551
 
74
552
  //#endregion
@@ -96,10 +574,16 @@ function aliasPlugin(config) {
96
574
  * ```
97
575
  */
98
576
  function replacePlugin(values = {}, options = {}) {
577
+ let hasNonStringValues = false;
99
578
  Object.keys(values).forEach((key) => {
100
- values[key] = values[key].toString();
579
+ const value = values[key];
580
+ if (typeof value !== "string") {
581
+ hasNonStringValues = true;
582
+ values[key] = String(value);
583
+ }
101
584
  });
102
- return createBuiltinPlugin("builtin:replace", {
585
+ if (hasNonStringValues) logger.warn("Some values provided to `replacePlugin` are not strings. They will be converted to strings, but for better performance consider converting them manually.");
586
+ return new BuiltinPlugin("builtin:replace", {
103
587
  ...options,
104
588
  values
105
589
  });
@@ -115,7 +599,7 @@ function transformPlugin(config) {
115
599
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
116
600
  jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
117
601
  };
118
- return createBuiltinPlugin("builtin:transform", config);
602
+ return new BuiltinPlugin("builtin:transform", config);
119
603
  }
120
604
 
121
605
  //#endregion
@@ -1,13 +1,44 @@
1
- import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingHmrUpdate, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding-wK0CRIMb.mjs";
2
- import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-BcNhk996.mjs";
1
+ import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingDynamicImportVarsPluginConfig, BindingEsmExternalRequirePluginConfig, BindingHmrUpdate, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWasmHelperPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding-Cjs27cfu.mjs";
2
+ import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-DzsPS4fI.mjs";
3
3
 
4
4
  //#region src/api/dev/dev-options.d.ts
5
5
  interface DevWatchOptions {
6
+ /**
7
+ * If `true`, use polling instead of native file system events for watching.
8
+ * @default false
9
+ */
6
10
  usePolling?: boolean;
11
+ /**
12
+ * Poll interval in milliseconds (only used when usePolling is true).
13
+ * @default 100
14
+ */
7
15
  pollInterval?: number;
16
+ /**
17
+ * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
18
+ * @default true
19
+ */
20
+ useDebounce?: boolean;
21
+ /**
22
+ * Debounce duration in milliseconds (only used when useDebounce is true).
23
+ * @default 10
24
+ */
25
+ debounceDuration?: number;
26
+ /**
27
+ * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
28
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
29
+ * @default false
30
+ */
31
+ compareContentsForPolling?: boolean;
32
+ /**
33
+ * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
34
+ * Controls how frequently the debouncer checks for events to process.
35
+ * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
36
+ * @default undefined (auto-select)
37
+ */
38
+ debounceTickRate?: number;
8
39
  }
9
40
  interface DevOptions {
10
- onHmrUpdates?: (updates: BindingHmrUpdate[]) => void | Promise<void>;
41
+ onHmrUpdates?: (updates: BindingHmrUpdate[], changedFiles: string[]) => void | Promise<void>;
11
42
  watch?: DevWatchOptions;
12
43
  }
13
44
  //#endregion
@@ -19,6 +50,10 @@ declare class DevEngine {
19
50
  run(): Promise<void>;
20
51
  ensureCurrentBuildFinish(): Promise<void>;
21
52
  ensureLatestBuild(): Promise<void>;
53
+ /**
54
+ * Returns true if a new build is scheduled.
55
+ */
56
+ scheduleBuildIfStale(): Promise<"scheduled" | "alreadyScheduled" | undefined>;
22
57
  invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
23
58
  }
24
59
  //#endregion
@@ -1,6 +1,7 @@
1
- import { PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBuiltinPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./shared/src-Dc4fRARy.mjs";
1
+ import { BuiltinPlugin, PluginDriver, assetPlugin, buildImportAnalysisPlugin, createBundlerImpl, createBundlerOptions, dynamicImportVarsPlugin, esmExternalRequirePlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./shared/src-kVjGhYdF.mjs";
2
2
  import "./shared/parse-ast-index-C3TkGcEQ.mjs";
3
3
  import "./shared/dist-CHTC3-kR.mjs";
4
+ import { logger } from "./shared/logger-CiCY7ucm.mjs";
4
5
  import { BindingBundler, BindingDevEngine, ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi.cjs";
5
6
  import { pathToFileURL } from "node:url";
6
7
 
@@ -15,7 +16,11 @@ var DevEngine = class DevEngine {
15
16
  onHmrUpdates: devOptions.onHmrUpdates,
16
17
  watch: devOptions.watch && {
17
18
  usePolling: devOptions.watch.usePolling,
18
- pollInterval: devOptions.watch.pollInterval
19
+ pollInterval: devOptions.watch.pollInterval,
20
+ useDebounce: devOptions.watch.useDebounce,
21
+ debounceDuration: devOptions.watch.debounceDuration,
22
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
23
+ debounceTickRate: devOptions.watch.debounceTickRate
19
24
  }
20
25
  };
21
26
  const inner = new BindingDevEngine(options.bundlerOptions, bindingDevOptions);
@@ -38,6 +43,16 @@ var DevEngine = class DevEngine {
38
43
  async ensureLatestBuild() {
39
44
  await this.#inner.ensureLatestBuild();
40
45
  }
46
+ /**
47
+ * Returns true if a new build is scheduled.
48
+ */
49
+ async scheduleBuildIfStale() {
50
+ const scheduled = await this.#inner.scheduleBuildIfStale();
51
+ if (scheduled) {
52
+ scheduled.wait().catch(() => {});
53
+ return scheduled.alreadyScheduled() ? "alreadyScheduled" : "scheduled";
54
+ }
55
+ }
41
56
  async invalidate(file, firstInvalidatedBy) {
42
57
  return this.#inner.invalidate(file, firstInvalidatedBy);
43
58
  }
@@ -76,7 +91,7 @@ function defineParallelPlugin(pluginPath) {
76
91
  //#endregion
77
92
  //#region src/builtin-plugin/alias-plugin.ts
78
93
  function aliasPlugin(config) {
79
- return createBuiltinPlugin("builtin:alias", config);
94
+ return new BuiltinPlugin("builtin:alias", config);
80
95
  }
81
96
 
82
97
  //#endregion
@@ -104,10 +119,16 @@ function aliasPlugin(config) {
104
119
  * ```
105
120
  */
106
121
  function replacePlugin(values = {}, options = {}) {
122
+ let hasNonStringValues = false;
107
123
  Object.keys(values).forEach((key) => {
108
- values[key] = values[key].toString();
124
+ const value = values[key];
125
+ if (typeof value !== "string") {
126
+ hasNonStringValues = true;
127
+ values[key] = String(value);
128
+ }
109
129
  });
110
- return createBuiltinPlugin("builtin:replace", {
130
+ if (hasNonStringValues) logger.warn("Some values provided to `replacePlugin` are not strings. They will be converted to strings, but for better performance consider converting them manually.");
131
+ return new BuiltinPlugin("builtin:replace", {
111
132
  ...options,
112
133
  values
113
134
  });
@@ -123,7 +144,7 @@ function transformPlugin(config) {
123
144
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
124
145
  jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
125
146
  };
126
- return createBuiltinPlugin("builtin:transform", config);
147
+ return new BuiltinPlugin("builtin:transform", config);
127
148
  }
128
149
 
129
150
  //#endregion
@@ -1,4 +1,4 @@
1
- import "./shared/binding-wK0CRIMb.mjs";
2
- import { withFilter } from "./shared/define-config-BcNhk996.mjs";
1
+ import "./shared/binding-Cjs27cfu.mjs";
2
+ import { withFilter } from "./shared/define-config-DzsPS4fI.mjs";
3
3
  import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
4
4
  export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };