rolldown 1.0.0-beta.1-commit.1d4a330 → 1.0.0-beta.1-commit.298dd8b

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.
@@ -1,626 +1,15 @@
1
- import { createRequire } from "module";
2
- import { Buffer as Buffer$1 } from "node:buffer";
1
+ import { __toESM, augmentCodeLocation, colors, error, logCycleLoading, logInputHookInOutputPlugin, logInvalidLogPosition, logMinifyWarning, logMultiplyNotifyOption, logPluginError, require_binding } from "./binding-DLjQWzkm.mjs";
3
2
  import path from "node:path";
3
+ import { Buffer } from "node:buffer";
4
4
  import { Worker } from "node:worker_threads";
5
5
  import { availableParallelism } from "node:os";
6
6
  import * as v from "valibot";
7
- import { env } from "node:process";
8
- import * as tty from "tty";
9
7
  import { toJsonSchema } from "@valibot/to-json-schema";
10
8
 
11
- //#region rolldown:runtime
12
- var __create = Object.create;
13
- var __defProp = Object.defineProperty;
14
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
- var __getOwnPropNames = Object.getOwnPropertyNames;
16
- var __getProtoOf = Object.getPrototypeOf;
17
- var __hasOwnProp = Object.prototype.hasOwnProperty;
18
- var __commonJS = (cb, mod) => function() {
19
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
- };
21
- var __copyProps = (to, from, except, desc) => {
22
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
23
- key = keys[i];
24
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
25
- get: ((k) => from[k]).bind(null, key),
26
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
- });
28
- }
29
- return to;
30
- };
31
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
32
- value: mod,
33
- enumerable: true
34
- }) : target, mod));
35
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
-
37
- //#endregion
38
- //#region src/utils/define-config.ts
39
- function defineConfig(config) {
40
- return config;
41
- }
42
-
43
- //#endregion
44
- //#region src/utils/asset-source.ts
45
- function transformAssetSource(bindingAssetSource$1) {
46
- return bindingAssetSource$1.inner;
47
- }
48
- function bindingAssetSource(source) {
49
- return { inner: source };
50
- }
51
-
52
- //#endregion
53
- //#region src/types/sourcemap.ts
54
- function bindingifySourcemap$1(map) {
55
- if (map == null) return;
56
- return { inner: typeof map === "string" ? map : {
57
- file: map.file ?? undefined,
58
- mappings: map.mappings,
59
- sourceRoot: map.sourceRoot,
60
- sources: map.sources?.map((s) => s ?? undefined),
61
- sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
62
- names: map.names
63
- } };
64
- }
65
-
66
- //#endregion
67
- //#region src/utils/error.ts
68
- function normalizeErrors(rawErrors) {
69
- const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
70
- kind: e.kind,
71
- message: e.message,
72
- stack: undefined
73
- }));
74
- let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
75
- for (let i = 0; i < errors.length; i++) {
76
- if (i >= 5) {
77
- summary += "\n...";
78
- break;
79
- }
80
- summary += getErrorMessage(errors[i]) + "\n";
81
- }
82
- const wrapper = new Error(summary);
83
- Object.defineProperty(wrapper, "errors", {
84
- configurable: true,
85
- enumerable: true,
86
- get: () => errors,
87
- set: (value) => Object.defineProperty(wrapper, "errors", {
88
- configurable: true,
89
- enumerable: true,
90
- value
91
- })
92
- });
93
- return wrapper;
94
- }
95
- function getErrorMessage(e) {
96
- let s = "";
97
- if (e.plugin) s += `[plugin ${e.plugin}]`;
98
- const id = e.id ?? e.loc?.file;
99
- if (id) {
100
- s += " " + id;
101
- if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
102
- }
103
- if (s) s += "\n";
104
- const message = `${e.name ?? "Error"}: ${e.message}`;
105
- s += message;
106
- if (e.frame) s = joinNewLine(s, e.frame);
107
- if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
108
- return s;
109
- }
110
- function joinNewLine(s1, s2) {
111
- return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
112
- }
113
-
114
- //#endregion
115
- //#region src/utils/transform-rendered-module.ts
116
- function transformToRenderedModule(bindingRenderedModule) {
117
- return {
118
- get code() {
119
- return bindingRenderedModule.code;
120
- },
121
- get renderedLength() {
122
- return bindingRenderedModule.code?.length || 0;
123
- }
124
- };
125
- }
126
-
127
- //#endregion
128
- //#region src/utils/transform-rendered-chunk.ts
129
- function transformRenderedChunk(chunk) {
130
- return {
131
- get name() {
132
- return chunk.name;
133
- },
134
- get isEntry() {
135
- return chunk.isEntry;
136
- },
137
- get isDynamicEntry() {
138
- return chunk.isDynamicEntry;
139
- },
140
- get facadeModuleId() {
141
- return chunk.facadeModuleId;
142
- },
143
- get moduleIds() {
144
- return chunk.moduleIds;
145
- },
146
- get exports() {
147
- return chunk.exports;
148
- },
149
- get fileName() {
150
- return chunk.fileName;
151
- },
152
- get imports() {
153
- return chunk.imports;
154
- },
155
- get dynamicImports() {
156
- return chunk.dynamicImports;
157
- },
158
- get modules() {
159
- return transformChunkModules(chunk.modules);
160
- }
161
- };
162
- }
163
- function transformChunkModules(modules) {
164
- const result = {};
165
- for (const [id, index] of Object.entries(modules.idToIndex)) {
166
- let mod = modules.value[index];
167
- result[id] = transformToRenderedModule(mod);
168
- }
169
- return result;
170
- }
171
-
172
- //#endregion
173
- //#region src/utils/transform-to-rollup-output.ts
174
- function transformToRollupSourceMap(map) {
175
- const parsed = JSON.parse(map);
176
- const obj = {
177
- ...parsed,
178
- toString() {
179
- return JSON.stringify(obj);
180
- },
181
- toUrl() {
182
- return `data:application/json;charset=utf-8;base64,${Buffer$1.from(obj.toString(), "utf-8").toString("base64")}`;
183
- }
184
- };
185
- return obj;
186
- }
187
- function transformToRollupOutputChunk(bindingChunk, changed) {
188
- const chunk = {
189
- type: "chunk",
190
- get code() {
191
- return bindingChunk.code;
192
- },
193
- fileName: bindingChunk.fileName,
194
- name: bindingChunk.name,
195
- get modules() {
196
- return transformChunkModules(bindingChunk.modules);
197
- },
198
- get imports() {
199
- return bindingChunk.imports;
200
- },
201
- get dynamicImports() {
202
- return bindingChunk.dynamicImports;
203
- },
204
- exports: bindingChunk.exports,
205
- isEntry: bindingChunk.isEntry,
206
- facadeModuleId: bindingChunk.facadeModuleId || null,
207
- isDynamicEntry: bindingChunk.isDynamicEntry,
208
- get moduleIds() {
209
- return bindingChunk.moduleIds;
210
- },
211
- get map() {
212
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
213
- },
214
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
215
- preliminaryFileName: bindingChunk.preliminaryFileName
216
- };
217
- const cache = {};
218
- return new Proxy(chunk, {
219
- get(target, p) {
220
- if (p in cache) return cache[p];
221
- return target[p];
222
- },
223
- set(target, p, newValue) {
224
- cache[p] = newValue;
225
- changed?.updated.add(bindingChunk.fileName);
226
- return true;
227
- }
228
- });
229
- }
230
- function transformToRollupOutputAsset(bindingAsset, changed) {
231
- const asset = {
232
- type: "asset",
233
- fileName: bindingAsset.fileName,
234
- originalFileName: bindingAsset.originalFileName || null,
235
- originalFileNames: bindingAsset.originalFileNames,
236
- get source() {
237
- return transformAssetSource(bindingAsset.source);
238
- },
239
- name: bindingAsset.name ?? undefined,
240
- names: bindingAsset.names
241
- };
242
- const cache = {};
243
- return new Proxy(asset, {
244
- get(target, p) {
245
- if (p in cache) return cache[p];
246
- return target[p];
247
- },
248
- set(target, p, newValue) {
249
- cache[p] = newValue;
250
- changed?.updated.add(bindingAsset.fileName);
251
- return true;
252
- }
253
- });
254
- }
255
- function transformToRollupOutput(output, changed) {
256
- handleOutputErrors(output);
257
- const { chunks, assets } = output;
258
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
259
- }
260
- function handleOutputErrors(output) {
261
- const rawErrors = output.errors;
262
- if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
263
- }
264
- function transformToOutputBundle(output, changed) {
265
- const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
266
- return new Proxy(bundle, { deleteProperty(target, property) {
267
- if (typeof property === "string") changed.deleted.add(property);
268
- return true;
269
- } });
270
- }
271
- function collectChangedBundle(changed, bundle) {
272
- const assets = [];
273
- const chunks = [];
274
- for (const key in bundle) {
275
- if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
276
- const item = bundle[key];
277
- if (item.type === "asset") assets.push({
278
- filename: item.fileName,
279
- originalFileNames: item.originalFileNames,
280
- source: bindingAssetSource(item.source),
281
- names: item.names
282
- });
283
- else chunks.push({
284
- code: item.code,
285
- filename: item.fileName,
286
- name: item.name,
287
- isEntry: item.isEntry,
288
- exports: item.exports,
289
- modules: {},
290
- imports: item.imports,
291
- dynamicImports: item.dynamicImports,
292
- facadeModuleId: item.facadeModuleId || undefined,
293
- isDynamicEntry: item.isDynamicEntry,
294
- moduleIds: item.moduleIds,
295
- map: bindingifySourcemap$1(item.map),
296
- sourcemapFilename: item.sourcemapFileName || undefined,
297
- preliminaryFilename: item.preliminaryFileName
298
- });
299
- }
300
- return {
301
- assets,
302
- chunks,
303
- deleted: Array.from(changed.deleted)
304
- };
305
- }
306
-
307
- //#endregion
308
- //#region src/binding.js
309
- var require_binding = __commonJS({ "src/binding.js"(exports, module) {
310
- const { createRequire: createRequire$1 } = __require("node:module");
311
- const { readFileSync } = __require("node:fs");
312
- let nativeBinding = null;
313
- const loadErrors = [];
314
- const isMusl = () => {
315
- let musl = false;
316
- if (process.platform === "linux") {
317
- musl = isMuslFromFilesystem();
318
- if (musl === null) musl = isMuslFromReport();
319
- if (musl === null) musl = isMuslFromChildProcess();
320
- }
321
- return musl;
322
- };
323
- const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
324
- const isMuslFromFilesystem = () => {
325
- try {
326
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
327
- } catch {
328
- return null;
329
- }
330
- };
331
- const isMuslFromReport = () => {
332
- const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
333
- if (!report) return null;
334
- if (report.header && report.header.glibcVersionRuntime) return false;
335
- if (Array.isArray(report.sharedObjects)) {
336
- if (report.sharedObjects.some(isFileMusl)) return true;
337
- }
338
- return false;
339
- };
340
- const isMuslFromChildProcess = () => {
341
- try {
342
- return __require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
343
- } catch (e) {
344
- return false;
345
- }
346
- };
347
- function requireNative() {
348
- if (process.platform === "android") if (process.arch === "arm64") {
349
- try {
350
- return __require("./rolldown-binding.android-arm64.node");
351
- } catch (e) {
352
- loadErrors.push(e);
353
- }
354
- try {
355
- return __require("@rolldown/binding-android-arm64");
356
- } catch (e) {
357
- loadErrors.push(e);
358
- }
359
- } else if (process.arch === "arm") {
360
- try {
361
- return __require("./rolldown-binding.android-arm-eabi.node");
362
- } catch (e) {
363
- loadErrors.push(e);
364
- }
365
- try {
366
- return __require("@rolldown/binding-android-arm-eabi");
367
- } catch (e) {
368
- loadErrors.push(e);
369
- }
370
- } else loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`));
371
- else if (process.platform === "win32") if (process.arch === "x64") {
372
- try {
373
- return __require("./rolldown-binding.win32-x64-msvc.node");
374
- } catch (e) {
375
- loadErrors.push(e);
376
- }
377
- try {
378
- return __require("@rolldown/binding-win32-x64-msvc");
379
- } catch (e) {
380
- loadErrors.push(e);
381
- }
382
- } else if (process.arch === "ia32") {
383
- try {
384
- return __require("./rolldown-binding.win32-ia32-msvc.node");
385
- } catch (e) {
386
- loadErrors.push(e);
387
- }
388
- try {
389
- return __require("@rolldown/binding-win32-ia32-msvc");
390
- } catch (e) {
391
- loadErrors.push(e);
392
- }
393
- } else if (process.arch === "arm64") {
394
- try {
395
- return __require("./rolldown-binding.win32-arm64-msvc.node");
396
- } catch (e) {
397
- loadErrors.push(e);
398
- }
399
- try {
400
- return __require("@rolldown/binding-win32-arm64-msvc");
401
- } catch (e) {
402
- loadErrors.push(e);
403
- }
404
- } else loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`));
405
- else if (process.platform === "darwin") {
406
- try {
407
- return __require("./rolldown-binding.darwin-universal.node");
408
- } catch (e) {
409
- loadErrors.push(e);
410
- }
411
- try {
412
- return __require("@rolldown/binding-darwin-universal");
413
- } catch (e) {
414
- loadErrors.push(e);
415
- }
416
- if (process.arch === "x64") {
417
- try {
418
- return __require("./rolldown-binding.darwin-x64.node");
419
- } catch (e) {
420
- loadErrors.push(e);
421
- }
422
- try {
423
- return __require("@rolldown/binding-darwin-x64");
424
- } catch (e) {
425
- loadErrors.push(e);
426
- }
427
- } else if (process.arch === "arm64") {
428
- try {
429
- return __require("./rolldown-binding.darwin-arm64.node");
430
- } catch (e) {
431
- loadErrors.push(e);
432
- }
433
- try {
434
- return __require("@rolldown/binding-darwin-arm64");
435
- } catch (e) {
436
- loadErrors.push(e);
437
- }
438
- } else loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`));
439
- } else if (process.platform === "freebsd") if (process.arch === "x64") {
440
- try {
441
- return __require("./rolldown-binding.freebsd-x64.node");
442
- } catch (e) {
443
- loadErrors.push(e);
444
- }
445
- try {
446
- return __require("@rolldown/binding-freebsd-x64");
447
- } catch (e) {
448
- loadErrors.push(e);
449
- }
450
- } else if (process.arch === "arm64") {
451
- try {
452
- return __require("./rolldown-binding.freebsd-arm64.node");
453
- } catch (e) {
454
- loadErrors.push(e);
455
- }
456
- try {
457
- return __require("@rolldown/binding-freebsd-arm64");
458
- } catch (e) {
459
- loadErrors.push(e);
460
- }
461
- } else loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
462
- else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
463
- try {
464
- return __require("./rolldown-binding.linux-x64-musl.node");
465
- } catch (e) {
466
- loadErrors.push(e);
467
- }
468
- try {
469
- return __require("@rolldown/binding-linux-x64-musl");
470
- } catch (e) {
471
- loadErrors.push(e);
472
- }
473
- } else {
474
- try {
475
- return __require("./rolldown-binding.linux-x64-gnu.node");
476
- } catch (e) {
477
- loadErrors.push(e);
478
- }
479
- try {
480
- return __require("@rolldown/binding-linux-x64-gnu");
481
- } catch (e) {
482
- loadErrors.push(e);
483
- }
484
- }
485
- else if (process.arch === "arm64") if (isMusl()) {
486
- try {
487
- return __require("./rolldown-binding.linux-arm64-musl.node");
488
- } catch (e) {
489
- loadErrors.push(e);
490
- }
491
- try {
492
- return __require("@rolldown/binding-linux-arm64-musl");
493
- } catch (e) {
494
- loadErrors.push(e);
495
- }
496
- } else {
497
- try {
498
- return __require("./rolldown-binding.linux-arm64-gnu.node");
499
- } catch (e) {
500
- loadErrors.push(e);
501
- }
502
- try {
503
- return __require("@rolldown/binding-linux-arm64-gnu");
504
- } catch (e) {
505
- loadErrors.push(e);
506
- }
507
- }
508
- else if (process.arch === "arm") if (isMusl()) {
509
- try {
510
- return __require("./rolldown-binding.linux-arm-musleabihf.node");
511
- } catch (e) {
512
- loadErrors.push(e);
513
- }
514
- try {
515
- return __require("@rolldown/binding-linux-arm-musleabihf");
516
- } catch (e) {
517
- loadErrors.push(e);
518
- }
519
- } else {
520
- try {
521
- return __require("./rolldown-binding.linux-arm-gnueabihf.node");
522
- } catch (e) {
523
- loadErrors.push(e);
524
- }
525
- try {
526
- return __require("@rolldown/binding-linux-arm-gnueabihf");
527
- } catch (e) {
528
- loadErrors.push(e);
529
- }
530
- }
531
- else if (process.arch === "riscv64") if (isMusl()) {
532
- try {
533
- return __require("./rolldown-binding.linux-riscv64-musl.node");
534
- } catch (e) {
535
- loadErrors.push(e);
536
- }
537
- try {
538
- return __require("@rolldown/binding-linux-riscv64-musl");
539
- } catch (e) {
540
- loadErrors.push(e);
541
- }
542
- } else {
543
- try {
544
- return __require("./rolldown-binding.linux-riscv64-gnu.node");
545
- } catch (e) {
546
- loadErrors.push(e);
547
- }
548
- try {
549
- return __require("@rolldown/binding-linux-riscv64-gnu");
550
- } catch (e) {
551
- loadErrors.push(e);
552
- }
553
- }
554
- else if (process.arch === "ppc64") {
555
- try {
556
- return __require("./rolldown-binding.linux-ppc64-gnu.node");
557
- } catch (e) {
558
- loadErrors.push(e);
559
- }
560
- try {
561
- return __require("@rolldown/binding-linux-ppc64-gnu");
562
- } catch (e) {
563
- loadErrors.push(e);
564
- }
565
- } else if (process.arch === "s390x") {
566
- try {
567
- return __require("./rolldown-binding.linux-s390x-gnu.node");
568
- } catch (e) {
569
- loadErrors.push(e);
570
- }
571
- try {
572
- return __require("@rolldown/binding-linux-s390x-gnu");
573
- } catch (e) {
574
- loadErrors.push(e);
575
- }
576
- } else loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`));
577
- else loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
578
- }
579
- nativeBinding = requireNative();
580
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
581
- try {
582
- nativeBinding = __require("./rolldown-binding.wasi.cjs");
583
- } catch (err) {
584
- if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
585
- }
586
- if (!nativeBinding) try {
587
- nativeBinding = __require("@rolldown/binding-wasm32-wasi");
588
- } catch (err) {
589
- if (process.env.NAPI_RS_FORCE_WASI) loadErrors.push(err);
590
- }
591
- }
592
- if (!nativeBinding) {
593
- if (loadErrors.length > 0) throw new Error("Failed to load native binding", { cause: loadErrors });
594
- throw new Error(`Failed to load native binding`);
595
- }
596
- module.exports.BindingBundleEndEventData = nativeBinding.BindingBundleEndEventData;
597
- module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
598
- module.exports.BindingError = nativeBinding.BindingError;
599
- module.exports.BindingLog = nativeBinding.BindingLog;
600
- module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
601
- module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
602
- module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
603
- module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
604
- module.exports.BindingOutputs = nativeBinding.BindingOutputs;
605
- module.exports.BindingPluginContext = nativeBinding.BindingPluginContext;
606
- module.exports.BindingRenderedModule = nativeBinding.BindingRenderedModule;
607
- module.exports.BindingTransformPluginContext = nativeBinding.BindingTransformPluginContext;
608
- module.exports.BindingWatcher = nativeBinding.BindingWatcher;
609
- module.exports.BindingWatcherChangeData = nativeBinding.BindingWatcherChangeData;
610
- module.exports.BindingWatcherEvent = nativeBinding.BindingWatcherEvent;
611
- module.exports.Bundler = nativeBinding.Bundler;
612
- module.exports.ParallelJsPluginRegistry = nativeBinding.ParallelJsPluginRegistry;
613
- module.exports.RenderedChunk = nativeBinding.RenderedChunk;
614
- module.exports.BindingBuiltinPluginName = nativeBinding.BindingBuiltinPluginName;
615
- module.exports.BindingHookSideEffects = nativeBinding.BindingHookSideEffects;
616
- module.exports.BindingLogLevel = nativeBinding.BindingLogLevel;
617
- module.exports.BindingPluginOrder = nativeBinding.BindingPluginOrder;
618
- module.exports.HelperMode = nativeBinding.HelperMode;
619
- module.exports.isolatedDeclaration = nativeBinding.isolatedDeclaration;
620
- module.exports.registerPlugins = nativeBinding.registerPlugins;
621
- module.exports.Severity = nativeBinding.Severity;
622
- module.exports.transform = nativeBinding.transform;
623
- } });
9
+ //#region src/utils/define-config.ts
10
+ function defineConfig(config) {
11
+ return config;
12
+ }
624
13
 
625
14
  //#endregion
626
15
  //#region src/utils/misc.ts
@@ -657,173 +46,6 @@ const logLevelPriority = {
657
46
  [LOG_LEVEL_SILENT]: 3
658
47
  };
659
48
 
660
- //#endregion
661
- //#region src/utils/code-frame.ts
662
- function spaces(index) {
663
- let result = "";
664
- while (index--) result += " ";
665
- return result;
666
- }
667
- function tabsToSpaces(value) {
668
- return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
669
- }
670
- const LINE_TRUNCATE_LENGTH = 120;
671
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
672
- const ELLIPSIS = "...";
673
- function getCodeFrame(source, line, column) {
674
- let lines = source.split("\n");
675
- if (line > lines.length) return "";
676
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
677
- const frameStart = Math.max(0, line - 3);
678
- let frameEnd = Math.min(line + 2, lines.length);
679
- lines = lines.slice(frameStart, frameEnd);
680
- while (!/\S/.test(lines[lines.length - 1])) {
681
- lines.pop();
682
- frameEnd -= 1;
683
- }
684
- const digits = String(frameEnd).length;
685
- return lines.map((sourceLine, index) => {
686
- const isErrorLine = frameStart + index + 1 === line;
687
- let lineNumber = String(index + frameStart + 1);
688
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
689
- let displayedLine = tabsToSpaces(sourceLine);
690
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
691
- if (isErrorLine) {
692
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
693
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
694
- }
695
- return `${lineNumber}: ${displayedLine}`;
696
- }).join("\n");
697
- }
698
-
699
- //#endregion
700
- //#region src/log/locate-character/index.js
701
- /** @typedef {import('./types').Location} Location */
702
- /**
703
- * @param {import('./types').Range} range
704
- * @param {number} index
705
- */
706
- function rangeContains(range, index) {
707
- return range.start <= index && index < range.end;
708
- }
709
- function getLocator(source, options = {}) {
710
- const { offsetLine = 0, offsetColumn = 0 } = options;
711
- let start = 0;
712
- const ranges = source.split("\n").map((line, i$1) => {
713
- const end = start + line.length + 1;
714
- /** @type {import('./types').Range} */
715
- const range = {
716
- start,
717
- end,
718
- line: i$1
719
- };
720
- start = end;
721
- return range;
722
- });
723
- let i = 0;
724
- /**
725
- * @param {string | number} search
726
- * @param {number} [index]
727
- * @returns {Location | undefined}
728
- */
729
- function locator(search, index) {
730
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
731
- if (search === -1) return undefined;
732
- let range = ranges[i];
733
- const d = search >= range.end ? 1 : -1;
734
- while (range) {
735
- if (rangeContains(range, search)) return {
736
- line: offsetLine + range.line,
737
- column: offsetColumn + search - range.start,
738
- character: search
739
- };
740
- i += d;
741
- range = ranges[i];
742
- }
743
- }
744
- return locator;
745
- }
746
- function locate(source, search, options) {
747
- return getLocator(source, options)(search, options && options.startIndex);
748
- }
749
-
750
- //#endregion
751
- //#region src/log/logs.ts
752
- const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", MINIFY_WARNING = "MINIFY_WARNING";
753
- function logMinifyWarning() {
754
- return {
755
- code: MINIFY_WARNING,
756
- message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
757
- };
758
- }
759
- function logInvalidLogPosition(pluginName) {
760
- return {
761
- code: INVALID_LOG_POSITION,
762
- message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`
763
- };
764
- }
765
- function logInputHookInOutputPlugin(pluginName, hookName) {
766
- return {
767
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
768
- message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`
769
- };
770
- }
771
- function logCycleLoading(pluginName, moduleId) {
772
- return {
773
- code: CYCLE_LOADING,
774
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
775
- };
776
- }
777
- function logMultiplyNotifyOption() {
778
- return {
779
- code: MULTIPLY_NOTIFY_OPTION,
780
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
781
- };
782
- }
783
- function logPluginError(error$1, plugin, { hook, id } = {}) {
784
- const code = error$1.code;
785
- if (!error$1.pluginCode && code != null && (typeof code !== "string" || !code.startsWith("PLUGIN_"))) error$1.pluginCode = code;
786
- error$1.code = PLUGIN_ERROR;
787
- error$1.plugin = plugin;
788
- if (hook) error$1.hook = hook;
789
- if (id) error$1.id = id;
790
- return error$1;
791
- }
792
- function error(base) {
793
- if (!(base instanceof Error)) {
794
- base = Object.assign(new Error(base.message), base);
795
- Object.defineProperty(base, "name", {
796
- value: "RollupError",
797
- writable: true
798
- });
799
- }
800
- throw base;
801
- }
802
- function augmentCodeLocation(properties, pos, source, id) {
803
- if (typeof pos === "object") {
804
- const { line, column } = pos;
805
- properties.loc = {
806
- column,
807
- file: id,
808
- line
809
- };
810
- } else {
811
- properties.pos = pos;
812
- const location = locate(source, pos, { offsetLine: 1 });
813
- if (!location) return;
814
- const { line, column } = location;
815
- properties.loc = {
816
- column,
817
- file: id,
818
- line
819
- };
820
- }
821
- if (properties.frame === undefined) {
822
- const { line, column } = properties.loc;
823
- properties.frame = getCodeFrame(source, line, column);
824
- }
825
- }
826
-
827
49
  //#endregion
828
50
  //#region src/log/logHandler.ts
829
51
  const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
@@ -996,6 +218,15 @@ function viteResolvePlugin(config) {
996
218
  });
997
219
  return makeBuiltinPluginCallable(builtinPlugin);
998
220
  }
221
+ function moduleFederationPlugin(config) {
222
+ return new BuiltinPlugin("builtin:module-federation", {
223
+ ...config,
224
+ remotes: config.remotes && Object.values(config.remotes).map((entry) => {
225
+ if (typeof entry === "string") return { entry };
226
+ return entry;
227
+ })
228
+ });
229
+ }
999
230
 
1000
231
  //#endregion
1001
232
  //#region src/utils/async-flatten.ts
@@ -1066,101 +297,365 @@ const DEFINED_HOOK_NAMES = {
1066
297
  };
1067
298
 
1068
299
  //#endregion
1069
- //#region src/utils/normalize-plugin-option.ts
1070
- const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
1071
- function checkOutputPluginOption(plugins, onLog) {
1072
- for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
1073
- delete plugin[hook];
1074
- onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
1075
- }
1076
- return plugins;
300
+ //#region src/utils/normalize-plugin-option.ts
301
+ const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
302
+ function checkOutputPluginOption(plugins, onLog) {
303
+ for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
304
+ delete plugin[hook];
305
+ onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
306
+ }
307
+ return plugins;
308
+ }
309
+ function normalizePlugins(plugins, anonymousPrefix) {
310
+ for (const [index, plugin] of plugins.entries()) {
311
+ if ("_parallel" in plugin) continue;
312
+ if (plugin instanceof BuiltinPlugin) continue;
313
+ if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
314
+ }
315
+ return plugins;
316
+ }
317
+ const ANONYMOUS_PLUGIN_PREFIX = "at position ";
318
+ const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
319
+
320
+ //#endregion
321
+ //#region src/plugin/plugin-driver.ts
322
+ var PluginDriver = class {
323
+ static async callOptionsHook(inputOptions) {
324
+ const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
325
+ const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
326
+ const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
327
+ for (const plugin of plugins) {
328
+ const name = plugin.name || "unknown";
329
+ const options = plugin.options;
330
+ if (options) {
331
+ const { handler } = normalizeHook(options);
332
+ const result = await handler.call({
333
+ debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
334
+ error: (e) => error(logPluginError(normalizeLog(e), name, { hook: "onLog" })),
335
+ info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
336
+ meta: {
337
+ rollupVersion: "4.23.0",
338
+ rolldownVersion: VERSION,
339
+ watchMode: false
340
+ },
341
+ warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
342
+ pluginName: name
343
+ }, inputOptions);
344
+ if (result) inputOptions = result;
345
+ }
346
+ }
347
+ return inputOptions;
348
+ }
349
+ static callOutputOptionsHook(rawPlugins, outputOptions) {
350
+ const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
351
+ for (const plugin of sortedPlugins) {
352
+ const options = plugin.outputOptions;
353
+ if (options) {
354
+ const { handler } = normalizeHook(options);
355
+ const result = handler.call(null, outputOptions);
356
+ if (result) outputOptions = result;
357
+ }
358
+ }
359
+ return outputOptions;
360
+ }
361
+ };
362
+ function getObjectPlugins(plugins) {
363
+ return plugins.filter((plugin) => {
364
+ if (!plugin) return undefined;
365
+ if ("_parallel" in plugin) return undefined;
366
+ if (plugin instanceof BuiltinPlugin) return undefined;
367
+ return plugin;
368
+ });
369
+ }
370
+ function getSortedPlugins(hookName, plugins) {
371
+ const pre = [];
372
+ const normal = [];
373
+ const post = [];
374
+ for (const plugin of plugins) {
375
+ const hook = plugin[hookName];
376
+ if (hook) {
377
+ if (typeof hook === "object") {
378
+ if (hook.order === "pre") {
379
+ pre.push(plugin);
380
+ continue;
381
+ }
382
+ if (hook.order === "post") {
383
+ post.push(plugin);
384
+ continue;
385
+ }
386
+ }
387
+ normal.push(plugin);
388
+ }
389
+ }
390
+ return [
391
+ ...pre,
392
+ ...normal,
393
+ ...post
394
+ ];
395
+ }
396
+
397
+ //#endregion
398
+ //#region src/utils/asset-source.ts
399
+ function transformAssetSource(bindingAssetSource$1) {
400
+ return bindingAssetSource$1.inner;
401
+ }
402
+ function bindingAssetSource(source) {
403
+ return { inner: source };
404
+ }
405
+
406
+ //#endregion
407
+ //#region src/types/sourcemap.ts
408
+ function bindingifySourcemap$1(map) {
409
+ if (map == null) return;
410
+ return { inner: typeof map === "string" ? map : {
411
+ file: map.file ?? undefined,
412
+ mappings: map.mappings,
413
+ sourceRoot: map.sourceRoot,
414
+ sources: map.sources?.map((s) => s ?? undefined),
415
+ sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
416
+ names: map.names
417
+ } };
418
+ }
419
+
420
+ //#endregion
421
+ //#region src/utils/error.ts
422
+ function normalizeErrors(rawErrors) {
423
+ const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(new Error(), {
424
+ kind: e.kind,
425
+ message: e.message,
426
+ stack: undefined
427
+ }));
428
+ let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
429
+ for (let i = 0; i < errors.length; i++) {
430
+ if (i >= 5) {
431
+ summary += "\n...";
432
+ break;
433
+ }
434
+ summary += getErrorMessage(errors[i]) + "\n";
435
+ }
436
+ const wrapper = new Error(summary);
437
+ Object.defineProperty(wrapper, "errors", {
438
+ configurable: true,
439
+ enumerable: true,
440
+ get: () => errors,
441
+ set: (value) => Object.defineProperty(wrapper, "errors", {
442
+ configurable: true,
443
+ enumerable: true,
444
+ value
445
+ })
446
+ });
447
+ return wrapper;
448
+ }
449
+ function getErrorMessage(e) {
450
+ let s = "";
451
+ if (e.plugin) s += `[plugin ${e.plugin}]`;
452
+ const id = e.id ?? e.loc?.file;
453
+ if (id) {
454
+ s += " " + id;
455
+ if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
456
+ }
457
+ if (s) s += "\n";
458
+ const message = `${e.name ?? "Error"}: ${e.message}`;
459
+ s += message;
460
+ if (e.frame) s = joinNewLine(s, e.frame);
461
+ if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
462
+ return s;
463
+ }
464
+ function joinNewLine(s1, s2) {
465
+ return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
466
+ }
467
+
468
+ //#endregion
469
+ //#region src/utils/transform-rendered-module.ts
470
+ function transformToRenderedModule(bindingRenderedModule) {
471
+ return {
472
+ get code() {
473
+ return bindingRenderedModule.code;
474
+ },
475
+ get renderedLength() {
476
+ return bindingRenderedModule.code?.length || 0;
477
+ }
478
+ };
479
+ }
480
+
481
+ //#endregion
482
+ //#region src/utils/transform-rendered-chunk.ts
483
+ function transformRenderedChunk(chunk) {
484
+ return {
485
+ get name() {
486
+ return chunk.name;
487
+ },
488
+ get isEntry() {
489
+ return chunk.isEntry;
490
+ },
491
+ get isDynamicEntry() {
492
+ return chunk.isDynamicEntry;
493
+ },
494
+ get facadeModuleId() {
495
+ return chunk.facadeModuleId;
496
+ },
497
+ get moduleIds() {
498
+ return chunk.moduleIds;
499
+ },
500
+ get exports() {
501
+ return chunk.exports;
502
+ },
503
+ get fileName() {
504
+ return chunk.fileName;
505
+ },
506
+ get imports() {
507
+ return chunk.imports;
508
+ },
509
+ get dynamicImports() {
510
+ return chunk.dynamicImports;
511
+ },
512
+ get modules() {
513
+ return transformChunkModules(chunk.modules);
514
+ }
515
+ };
1077
516
  }
1078
- function normalizePlugins(plugins, anonymousPrefix) {
1079
- for (const [index, plugin] of plugins.entries()) {
1080
- if ("_parallel" in plugin) continue;
1081
- if (plugin instanceof BuiltinPlugin) continue;
1082
- if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
517
+ function transformChunkModules(modules) {
518
+ const result = {};
519
+ for (const [id, index] of Object.entries(modules.idToIndex)) {
520
+ let mod = modules.value[index];
521
+ result[id] = transformToRenderedModule(mod);
1083
522
  }
1084
- return plugins;
523
+ return result;
1085
524
  }
1086
- const ANONYMOUS_PLUGIN_PREFIX = "at position ";
1087
- const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
1088
525
 
1089
526
  //#endregion
1090
- //#region src/plugin/plugin-driver.ts
1091
- var PluginDriver = class {
1092
- async callOptionsHook(inputOptions) {
1093
- const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
1094
- const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
1095
- const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
1096
- for (const plugin of plugins) {
1097
- const name = plugin.name || "unknown";
1098
- const options = plugin.options;
1099
- if (options) {
1100
- const { handler } = normalizeHook(options);
1101
- const result = await handler.call({
1102
- debug: getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", logger, name, logLevel),
1103
- error: (e) => error(logPluginError(normalizeLog(e), name, { hook: "onLog" })),
1104
- info: getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", logger, name, logLevel),
1105
- meta: {
1106
- rollupVersion: "4.23.0",
1107
- rolldownVersion: VERSION,
1108
- watchMode: false
1109
- },
1110
- warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
1111
- pluginName: name
1112
- }, inputOptions);
1113
- if (result) inputOptions = result;
1114
- }
527
+ //#region src/utils/transform-to-rollup-output.ts
528
+ function transformToRollupSourceMap(map) {
529
+ const parsed = JSON.parse(map);
530
+ const obj = {
531
+ ...parsed,
532
+ toString() {
533
+ return JSON.stringify(obj);
534
+ },
535
+ toUrl() {
536
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
1115
537
  }
1116
- return inputOptions;
1117
- }
1118
- callOutputOptionsHook(rawPlugins, outputOptions) {
1119
- const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
1120
- for (const plugin of sortedPlugins) {
1121
- const options = plugin.outputOptions;
1122
- if (options) {
1123
- const { handler } = normalizeHook(options);
1124
- const result = handler.call(null, outputOptions);
1125
- if (result) outputOptions = result;
1126
- }
538
+ };
539
+ return obj;
540
+ }
541
+ function transformToRollupOutputChunk(bindingChunk, changed) {
542
+ const chunk = {
543
+ type: "chunk",
544
+ get code() {
545
+ return bindingChunk.code;
546
+ },
547
+ fileName: bindingChunk.fileName,
548
+ name: bindingChunk.name,
549
+ get modules() {
550
+ return transformChunkModules(bindingChunk.modules);
551
+ },
552
+ get imports() {
553
+ return bindingChunk.imports;
554
+ },
555
+ get dynamicImports() {
556
+ return bindingChunk.dynamicImports;
557
+ },
558
+ exports: bindingChunk.exports,
559
+ isEntry: bindingChunk.isEntry,
560
+ facadeModuleId: bindingChunk.facadeModuleId || null,
561
+ isDynamicEntry: bindingChunk.isDynamicEntry,
562
+ get moduleIds() {
563
+ return bindingChunk.moduleIds;
564
+ },
565
+ get map() {
566
+ return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
567
+ },
568
+ sourcemapFileName: bindingChunk.sourcemapFileName || null,
569
+ preliminaryFileName: bindingChunk.preliminaryFileName
570
+ };
571
+ const cache = {};
572
+ return new Proxy(chunk, {
573
+ get(target, p) {
574
+ if (p in cache) return cache[p];
575
+ return target[p];
576
+ },
577
+ set(target, p, newValue) {
578
+ cache[p] = newValue;
579
+ changed?.updated.add(bindingChunk.fileName);
580
+ return true;
1127
581
  }
1128
- return outputOptions;
1129
- }
1130
- };
1131
- function getObjectPlugins(plugins) {
1132
- return plugins.filter((plugin) => {
1133
- if (!plugin) return undefined;
1134
- if ("_parallel" in plugin) return undefined;
1135
- if (plugin instanceof BuiltinPlugin) return undefined;
1136
- return plugin;
1137
582
  });
1138
583
  }
1139
- function getSortedPlugins(hookName, plugins) {
1140
- const pre = [];
1141
- const normal = [];
1142
- const post = [];
1143
- for (const plugin of plugins) {
1144
- const hook = plugin[hookName];
1145
- if (hook) {
1146
- if (typeof hook === "object") {
1147
- if (hook.order === "pre") {
1148
- pre.push(plugin);
1149
- continue;
1150
- }
1151
- if (hook.order === "post") {
1152
- post.push(plugin);
1153
- continue;
1154
- }
1155
- }
1156
- normal.push(plugin);
584
+ function transformToRollupOutputAsset(bindingAsset, changed) {
585
+ const asset = {
586
+ type: "asset",
587
+ fileName: bindingAsset.fileName,
588
+ originalFileName: bindingAsset.originalFileName || null,
589
+ originalFileNames: bindingAsset.originalFileNames,
590
+ get source() {
591
+ return transformAssetSource(bindingAsset.source);
592
+ },
593
+ name: bindingAsset.name ?? undefined,
594
+ names: bindingAsset.names
595
+ };
596
+ const cache = {};
597
+ return new Proxy(asset, {
598
+ get(target, p) {
599
+ if (p in cache) return cache[p];
600
+ return target[p];
601
+ },
602
+ set(target, p, newValue) {
603
+ cache[p] = newValue;
604
+ changed?.updated.add(bindingAsset.fileName);
605
+ return true;
1157
606
  }
607
+ });
608
+ }
609
+ function transformToRollupOutput(output, changed) {
610
+ handleOutputErrors(output);
611
+ const { chunks, assets } = output;
612
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
613
+ }
614
+ function handleOutputErrors(output) {
615
+ const rawErrors = output.errors;
616
+ if (rawErrors.length > 0) throw normalizeErrors(rawErrors);
617
+ }
618
+ function transformToOutputBundle(output, changed) {
619
+ const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
620
+ return new Proxy(bundle, { deleteProperty(target, property) {
621
+ if (typeof property === "string") changed.deleted.add(property);
622
+ return true;
623
+ } });
624
+ }
625
+ function collectChangedBundle(changed, bundle) {
626
+ const assets = [];
627
+ const chunks = [];
628
+ for (const key in bundle) {
629
+ if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
630
+ const item = bundle[key];
631
+ if (item.type === "asset") assets.push({
632
+ filename: item.fileName,
633
+ originalFileNames: item.originalFileNames,
634
+ source: bindingAssetSource(item.source),
635
+ names: item.names
636
+ });
637
+ else chunks.push({
638
+ code: item.code,
639
+ filename: item.fileName,
640
+ name: item.name,
641
+ isEntry: item.isEntry,
642
+ exports: item.exports,
643
+ modules: {},
644
+ imports: item.imports,
645
+ dynamicImports: item.dynamicImports,
646
+ facadeModuleId: item.facadeModuleId || undefined,
647
+ isDynamicEntry: item.isDynamicEntry,
648
+ moduleIds: item.moduleIds,
649
+ map: bindingifySourcemap$1(item.map),
650
+ sourcemapFilename: item.sourcemapFileName || undefined,
651
+ preliminaryFilename: item.preliminaryFileName
652
+ });
1158
653
  }
1159
- return [
1160
- ...pre,
1161
- ...normal,
1162
- ...post
1163
- ];
654
+ return {
655
+ assets,
656
+ chunks,
657
+ deleted: Array.from(changed.deleted)
658
+ };
1164
659
  }
1165
660
 
1166
661
  //#endregion
@@ -1290,7 +785,8 @@ var PluginContext = class extends MinimalPluginContext {
1290
785
  };
1291
786
  }
1292
787
  emitFile(file) {
1293
- if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
788
+ if (file.type === "prebuilt-chunk") return unimplemented("PluginContext.emitFile with type prebuilt-chunk");
789
+ if (file.type === "chunk") return this.context.emitChunk(file);
1294
790
  return this.context.emitFile({
1295
791
  ...file,
1296
792
  originalFileName: file.originalFileName || undefined,
@@ -2643,83 +2139,6 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
2643
2139
  }
2644
2140
  }
2645
2141
 
2646
- //#endregion
2647
- //#region ../../node_modules/.pnpm/colorette@2.0.20/node_modules/colorette/index.js
2648
- const { env: env$1 = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
2649
- const isDisabled = "NO_COLOR" in env$1 || argv.includes("--no-color");
2650
- const isForced = "FORCE_COLOR" in env$1 || argv.includes("--color");
2651
- const isWindows = platform === "win32";
2652
- const isDumbTerminal = env$1.TERM === "dumb";
2653
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env$1.TERM && !isDumbTerminal;
2654
- const isCI = "CI" in env$1 && ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
2655
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
2656
- const replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
2657
- const clearBleed = (index, string, open, close, replace) => index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
2658
- const filterEmpty = (open, close, replace = open, at = open.length + 1) => (string) => string || !(string === "" || string === undefined) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
2659
- const init = (open, close, replace) => filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
2660
- const colors$1 = {
2661
- reset: init(0, 0),
2662
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
2663
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
2664
- italic: init(3, 23),
2665
- underline: init(4, 24),
2666
- inverse: init(7, 27),
2667
- hidden: init(8, 28),
2668
- strikethrough: init(9, 29),
2669
- black: init(30, 39),
2670
- red: init(31, 39),
2671
- green: init(32, 39),
2672
- yellow: init(33, 39),
2673
- blue: init(34, 39),
2674
- magenta: init(35, 39),
2675
- cyan: init(36, 39),
2676
- white: init(37, 39),
2677
- gray: init(90, 39),
2678
- bgBlack: init(40, 49),
2679
- bgRed: init(41, 49),
2680
- bgGreen: init(42, 49),
2681
- bgYellow: init(43, 49),
2682
- bgBlue: init(44, 49),
2683
- bgMagenta: init(45, 49),
2684
- bgCyan: init(46, 49),
2685
- bgWhite: init(47, 49),
2686
- blackBright: init(90, 39),
2687
- redBright: init(91, 39),
2688
- greenBright: init(92, 39),
2689
- yellowBright: init(93, 39),
2690
- blueBright: init(94, 39),
2691
- magentaBright: init(95, 39),
2692
- cyanBright: init(96, 39),
2693
- whiteBright: init(97, 39),
2694
- bgBlackBright: init(100, 49),
2695
- bgRedBright: init(101, 49),
2696
- bgGreenBright: init(102, 49),
2697
- bgYellowBright: init(103, 49),
2698
- bgBlueBright: init(104, 49),
2699
- bgMagentaBright: init(105, 49),
2700
- bgCyanBright: init(106, 49),
2701
- bgWhiteBright: init(107, 49)
2702
- };
2703
- const createColors = ({ useColor = isColorSupported } = {}) => useColor ? colors$1 : Object.keys(colors$1).reduce((colors$2, key) => ({
2704
- ...colors$2,
2705
- [key]: String
2706
- }), {});
2707
- const { reset, bold: bold$1, dim: dim$1, italic, underline: underline$1, inverse, hidden, strikethrough, black, red: red$1, green: green$1, yellow: yellow$1, blue, magenta, cyan: cyan$1, white, gray: gray$1, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, blackBright, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagentaBright, bgCyanBright, bgWhiteBright } = createColors();
2708
-
2709
- //#endregion
2710
- //#region src/cli/colors.ts
2711
- const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({ useColor: env.FORCE_COLOR !== "0" && !env.NO_COLOR });
2712
- const colors = {
2713
- bold,
2714
- cyan,
2715
- dim,
2716
- gray,
2717
- green,
2718
- red,
2719
- underline,
2720
- yellow
2721
- };
2722
-
2723
2142
  //#endregion
2724
2143
  //#region src/utils/validator.ts
2725
2144
  const StringOrRegExpSchema = v.union([v.string(), v.instance(RegExp)]);
@@ -2979,14 +2398,12 @@ function getJsonSchema() {
2979
2398
  //#endregion
2980
2399
  //#region src/utils/create-bundler-option.ts
2981
2400
  async function createBundlerOptions(inputOptions, outputOptions) {
2982
- const pluginDriver = new PluginDriver();
2983
- inputOptions = await pluginDriver.callOptionsHook(inputOptions);
2984
2401
  if (inputOptions.treeshake !== undefined) validateTreeShakingOptions(inputOptions.treeshake);
2985
2402
  const inputPlugins = await normalizePluginOption(inputOptions.plugins);
2986
2403
  const outputPlugins = await normalizePluginOption(outputOptions.plugins);
2987
2404
  const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
2988
2405
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
2989
- outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2406
+ outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2990
2407
  if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
2991
2408
  let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
2992
2409
  if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
@@ -3065,7 +2482,8 @@ var RolldownBuild = class {
3065
2482
  //#endregion
3066
2483
  //#region src/api/rolldown/index.ts
3067
2484
  const rolldown = async (input) => {
3068
- return new RolldownBuild(input);
2485
+ const inputOptions = await PluginDriver.callOptionsHook(input);
2486
+ return new RolldownBuild(inputOptions);
3069
2487
  };
3070
2488
 
3071
2489
  //#endregion
@@ -3163,7 +2581,10 @@ var Watcher = class {
3163
2581
  };
3164
2582
  async function createWatcher(emitter, input) {
3165
2583
  const options = arraify(input);
3166
- const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map((output) => createBundlerOptions(option, output))).flat());
2584
+ const bundlerOptions = await Promise.all(options.map((option) => arraify(option.output || {}).map(async (output) => {
2585
+ const inputOptions = await PluginDriver.callOptionsHook(option);
2586
+ return createBundlerOptions(inputOptions, output);
2587
+ })).flat());
3167
2588
  const notifyOptions = getValidNotifyOption(bundlerOptions);
3168
2589
  const bindingWatcher = new import_binding.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions);
3169
2590
  const watcher = new Watcher(emitter, bindingWatcher, bundlerOptions.map((option) => option.stopWorkers));
@@ -3190,7 +2611,7 @@ const watch = (input) => {
3190
2611
 
3191
2612
  //#endregion
3192
2613
  //#region package.json
3193
- var version = "1.0.0-beta.1-commit.1d4a330";
2614
+ var version = "1.0.0-beta.1-commit.298dd8b";
3194
2615
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
3195
2616
 
3196
2617
  //#endregion
@@ -3214,4 +2635,4 @@ async function build(options) {
3214
2635
  const VERSION = version;
3215
2636
 
3216
2637
  //#endregion
3217
- export { BuiltinPlugin, PluginContextData, VERSION, __toESM, arraify, bindingifyPlugin, build, buildImportAnalysisPlugin, colors, composeJsPlugins, createBundler, defineConfig, description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, require_binding, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch };
2638
+ export { BuiltinPlugin, PluginContextData, VERSION, arraify, bindingifyPlugin, build, buildImportAnalysisPlugin, composeJsPlugins, createBundler, defineConfig, description, dynamicImportVarsPlugin, getInputCliKeys, getJsonSchema, getOutputCliKeys, handleOutputErrors, importGlobPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, rolldown, validateCliOptions, version, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch };