@rolldown/browser 1.0.0-beta.35 → 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/cli.mjs +96 -1069
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +4 -4
- package/dist/experimental-index.browser.mjs +493 -7
- package/dist/experimental-index.d.mts +43 -5
- package/dist/experimental-index.mjs +32 -9
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +3 -3
- package/dist/parallel-plugin-worker.mjs +4 -5
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/rolldown-binding.wasi-browser.js +1 -0
- package/dist/rolldown-binding.wasi.cjs +1 -0
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{binding-9k0egz6L.d.mts → binding-Cjs27cfu.d.mts} +1 -0
- package/dist/shared/{define-config-DhrkZ_o7.d.cts → define-config-DzsPS4fI.d.mts} +8 -8
- package/dist/shared/{dist-ByKQkexh.mjs → dist-CHTC3-kR.mjs} +1 -1
- package/dist/shared/{load-config-BCjD-AGJ.mjs → load-config-efyGD8HY.mjs} +4 -6
- package/dist/{cli.cjs → shared/logger-CiCY7ucm.mjs} +34 -817
- package/dist/shared/{parse-ast-index-C_CZT4St.mjs → parse-ast-index-C3TkGcEQ.mjs} +1 -1
- package/dist/shared/{prompt-C5jz26Zn.mjs → prompt-D2FxOcB5.mjs} +4 -7
- package/dist/shared/{src-B0RCtUy7.mjs → src-kVjGhYdF.mjs} +89 -70
- package/dist/{src-C8U06Im1.js → src-C2GHZXDs.js} +88 -70
- package/package.json +10 -24
- package/dist/cli.d.cts +0 -1
- package/dist/config.cjs +0 -12
- package/dist/config.d.cts +0 -10
- package/dist/experimental-index.cjs +0 -176
- package/dist/experimental-index.d.cts +0 -99
- package/dist/filter-index.cjs +0 -53
- package/dist/filter-index.d.cts +0 -4
- package/dist/index.cjs +0 -9
- package/dist/index.d.cts +0 -3
- package/dist/parallel-plugin-worker.cjs +0 -35
- package/dist/parallel-plugin-worker.d.cts +0 -1
- package/dist/parallel-plugin.cjs +0 -8
- package/dist/parallel-plugin.d.cts +0 -14
- package/dist/parse-ast-index.cjs +0 -4
- package/dist/parse-ast-index.d.cts +0 -8
- package/dist/shared/binding-D13M6Llu.d.cts +0 -1425
- package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
- package/dist/shared/define-config-DJXaSinS.d.mts +0 -1421
- package/dist/shared/dist-CK0hotcm.cjs +0 -240
- package/dist/shared/load-config-BJKhRKZL.cjs +0 -130
- package/dist/shared/parse-ast-index-J0xVKZRe.cjs +0 -327
- package/dist/shared/prompt-Q05EYrFb.cjs +0 -858
- package/dist/shared/src-Bd4BGX4v.cjs +0 -4788
package/dist/config.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./shared/binding-
|
|
2
|
-
import { ConfigExport, defineConfig } from "./shared/define-config-
|
|
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-
|
|
2
|
-
import "./shared/parse-ast-index-
|
|
3
|
-
import "./shared/dist-
|
|
4
|
-
import { loadConfig } from "./shared/load-config-
|
|
1
|
+
import { defineConfig, version } from "./shared/src-kVjGhYdF.mjs";
|
|
2
|
+
import "./shared/parse-ast-index-C3TkGcEQ.mjs";
|
|
3
|
+
import "./shared/dist-CHTC3-kR.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,
|
|
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
|
|
@@ -10,8 +10,14 @@ var DevEngine = class DevEngine {
|
|
|
10
10
|
const options = await createBundlerOptions(inputOptions, outputOptions, false);
|
|
11
11
|
const bindingDevOptions = {
|
|
12
12
|
onHmrUpdates: devOptions.onHmrUpdates,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
watch: devOptions.watch && {
|
|
14
|
+
usePolling: devOptions.watch.usePolling,
|
|
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
|
|
20
|
+
}
|
|
15
21
|
};
|
|
16
22
|
const inner = new BindingDevEngine(options.bundlerOptions, bindingDevOptions);
|
|
17
23
|
return new DevEngine(inner);
|
|
@@ -33,6 +39,16 @@ var DevEngine = class DevEngine {
|
|
|
33
39
|
async ensureLatestBuild() {
|
|
34
40
|
await this.#inner.ensureLatestBuild();
|
|
35
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
|
+
}
|
|
36
52
|
async invalidate(file, firstInvalidatedBy) {
|
|
37
53
|
return this.#inner.invalidate(file, firstInvalidatedBy);
|
|
38
54
|
}
|
|
@@ -66,7 +82,471 @@ function defineParallelPlugin(pluginPath) {
|
|
|
66
82
|
//#endregion
|
|
67
83
|
//#region src/builtin-plugin/alias-plugin.ts
|
|
68
84
|
function aliasPlugin(config) {
|
|
69
|
-
return
|
|
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;
|
|
70
550
|
}
|
|
71
551
|
|
|
72
552
|
//#endregion
|
|
@@ -94,10 +574,16 @@ function aliasPlugin(config) {
|
|
|
94
574
|
* ```
|
|
95
575
|
*/
|
|
96
576
|
function replacePlugin(values = {}, options = {}) {
|
|
577
|
+
let hasNonStringValues = false;
|
|
97
578
|
Object.keys(values).forEach((key) => {
|
|
98
|
-
|
|
579
|
+
const value = values[key];
|
|
580
|
+
if (typeof value !== "string") {
|
|
581
|
+
hasNonStringValues = true;
|
|
582
|
+
values[key] = String(value);
|
|
583
|
+
}
|
|
99
584
|
});
|
|
100
|
-
|
|
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", {
|
|
101
587
|
...options,
|
|
102
588
|
values
|
|
103
589
|
});
|
|
@@ -113,7 +599,7 @@ function transformPlugin(config) {
|
|
|
113
599
|
jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
|
|
114
600
|
jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
|
|
115
601
|
};
|
|
116
|
-
return
|
|
602
|
+
return new BuiltinPlugin("builtin:transform", config);
|
|
117
603
|
}
|
|
118
604
|
|
|
119
605
|
//#endregion
|
|
@@ -1,11 +1,45 @@
|
|
|
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-
|
|
2
|
-
import { BuiltinPlugin, InputOptions, OutputOptions, StringOrRegExp, defineParallelPlugin } from "./shared/define-config-
|
|
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
|
-
interface
|
|
6
|
-
|
|
5
|
+
interface DevWatchOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If `true`, use polling instead of native file system events for watching.
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
7
10
|
usePolling?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Poll interval in milliseconds (only used when usePolling is true).
|
|
13
|
+
* @default 100
|
|
14
|
+
*/
|
|
8
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;
|
|
39
|
+
}
|
|
40
|
+
interface DevOptions {
|
|
41
|
+
onHmrUpdates?: (updates: BindingHmrUpdate[], changedFiles: string[]) => void | Promise<void>;
|
|
42
|
+
watch?: DevWatchOptions;
|
|
9
43
|
}
|
|
10
44
|
//#endregion
|
|
11
45
|
//#region src/api/dev/dev-engine.d.ts
|
|
@@ -16,6 +50,10 @@ declare class DevEngine {
|
|
|
16
50
|
run(): Promise<void>;
|
|
17
51
|
ensureCurrentBuildFinish(): Promise<void>;
|
|
18
52
|
ensureLatestBuild(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Returns true if a new build is scheduled.
|
|
55
|
+
*/
|
|
56
|
+
scheduleBuildIfStale(): Promise<"scheduled" | "alreadyScheduled" | undefined>;
|
|
19
57
|
invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
|
|
20
58
|
}
|
|
21
59
|
//#endregion
|
|
@@ -96,4 +134,4 @@ type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exc
|
|
|
96
134
|
};
|
|
97
135
|
declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
|
|
98
136
|
//#endregion
|
|
99
|
-
export { DevEngine, type DevOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
|
|
137
|
+
export { DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
|