@rollipop/rolldown 0.0.0-beta.1 → 0.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cli-setup.mjs +1 -1
  2. package/dist/cli.mjs +37 -37
  3. package/dist/config.d.mts +2 -2
  4. package/dist/config.mjs +7 -7
  5. package/dist/experimental-index.d.mts +4 -62
  6. package/dist/experimental-index.mjs +7 -40
  7. package/dist/experimental-runtime-types.d.ts +12 -1
  8. package/dist/filter-index.d.mts +2 -2
  9. package/dist/filter-index.mjs +1 -1
  10. package/dist/index.d.mts +2 -2
  11. package/dist/index.mjs +7 -7
  12. package/dist/parallel-plugin-worker.mjs +4 -4
  13. package/dist/parallel-plugin.d.mts +2 -2
  14. package/dist/parse-ast-index.d.mts +1 -1
  15. package/dist/parse-ast-index.mjs +2 -2
  16. package/dist/plugins-index.d.mts +3 -3
  17. package/dist/plugins-index.mjs +3 -3
  18. package/dist/shared/{binding-kAegJ1Bj.d.mts → binding-C9YdqoUG.d.mts} +2 -120
  19. package/dist/shared/{binding-BGro4B9r.mjs → binding-uOeDeDzp.mjs} +26 -27
  20. package/dist/shared/{bindingify-input-options-Cbn4Fx-U.mjs → bindingify-input-options-CuBDHglZ.mjs} +573 -21
  21. package/dist/shared/{constructors-BaMrri8j.d.mts → constructors-D9F4Aj4h.d.mts} +3 -5
  22. package/dist/shared/{constructors-g6aWFjfR.mjs → constructors-DmSv3tnW.mjs} +2 -8
  23. package/dist/shared/{define-config-C0bKR4ot.d.mts → define-config-glNgjHCc.d.mts} +6 -1
  24. package/dist/shared/{load-config-CSb1tL9s.mjs → load-config-Bo3y98vw.mjs} +1 -1
  25. package/dist/shared/{logs-cyjC0SDv.mjs → logs-N5Akftom.mjs} +2 -2
  26. package/dist/shared/normalize-string-or-regex-0f6WITto.mjs +61 -0
  27. package/dist/shared/{parse-ast-index-oopYDFzI.mjs → parse-ast-index-B0iVLbj6.mjs} +2 -2
  28. package/dist/shared/{prompt-5sWCM0jm.mjs → prompt-BZ-QjPVS.mjs} +45 -45
  29. package/dist/shared/{rolldown-build-CENRTWd-.mjs → rolldown-build-BqHWBpp7.mjs} +15 -13
  30. package/dist/shared/{rolldown-DA9aR8tX.mjs → rolldown-mAJGca5O.mjs} +1 -1
  31. package/dist/shared/{watch-CjiZ0BRX.mjs → watch-Ce8bKBAn.mjs} +5 -6
  32. package/package.json +11 -11
  33. package/dist/shared/normalize-string-or-regex-CjC3YBVf.mjs +0 -670
  34. /package/dist/shared/{misc-DpjTMcQQ.mjs → misc-0HsaOsAX.mjs} +0 -0
@@ -1,670 +0,0 @@
1
- import { n as __toESM, t as require_binding } from "./binding-BGro4B9r.mjs";
2
- import { a as logInvalidLogPosition, c as logPluginError, n as error } from "./logs-cyjC0SDv.mjs";
3
- import { r as noop } from "./misc-DpjTMcQQ.mjs";
4
-
5
- //#region src/log/logging.ts
6
- const LOG_LEVEL_SILENT = "silent";
7
- const LOG_LEVEL_ERROR = "error";
8
- const LOG_LEVEL_WARN = "warn";
9
- const LOG_LEVEL_INFO = "info";
10
- const LOG_LEVEL_DEBUG = "debug";
11
- const logLevelPriority = {
12
- [LOG_LEVEL_DEBUG]: 0,
13
- [LOG_LEVEL_INFO]: 1,
14
- [LOG_LEVEL_WARN]: 2,
15
- [LOG_LEVEL_SILENT]: 3
16
- };
17
-
18
- //#endregion
19
- //#region src/log/log-handler.ts
20
- const normalizeLog = (log) => typeof log === "string" ? { message: log } : typeof log === "function" ? normalizeLog(log()) : log;
21
- function getLogHandler(level, code, logger, pluginName, logLevel) {
22
- if (logLevelPriority[level] < logLevelPriority[logLevel]) return noop;
23
- return (log, pos) => {
24
- if (pos != null) logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
25
- log = normalizeLog(log);
26
- if (log.code && !log.pluginCode) log.pluginCode = log.code;
27
- log.code = code;
28
- log.plugin = pluginName;
29
- logger(level, log);
30
- };
31
- }
32
-
33
- //#endregion
34
- //#region package.json
35
- var version = "0.0.0-beta.1";
36
- var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
37
-
38
- //#endregion
39
- //#region src/version.ts
40
- /** @category Plugin APIs */
41
- const VERSION = version;
42
-
43
- //#endregion
44
- //#region src/plugin/minimal-plugin-context.ts
45
- var MinimalPluginContextImpl = class {
46
- info;
47
- warn;
48
- debug;
49
- meta;
50
- constructor(onLog, logLevel, pluginName, watchMode, hookName) {
51
- this.pluginName = pluginName;
52
- this.hookName = hookName;
53
- this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
54
- this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
55
- this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
56
- this.meta = {
57
- rollupVersion: "4.23.0",
58
- rolldownVersion: VERSION,
59
- watchMode
60
- };
61
- }
62
- error(e) {
63
- return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
64
- }
65
- };
66
-
67
- //#endregion
68
- //#region src/types/plain-object-like.ts
69
- const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
70
- /**
71
- * Base class for classes that use `@lazyProp` decorated properties.
72
- *
73
- * **Design Pattern in Rolldown:**
74
- * This is a common pattern in Rolldown due to its three-layer architecture:
75
- * TypeScript API → NAPI Bindings → Rust Core
76
- *
77
- * **Why we use getters:**
78
- * For performance - to lazily fetch data from Rust bindings only when needed,
79
- * rather than eagerly fetching all data during object construction.
80
- *
81
- * **The problem:**
82
- * Getters defined on class prototypes are non-enumerable by default, which breaks:
83
- * - Object spread operators ({...obj})
84
- * - Object.keys() and similar methods
85
- * - Standard JavaScript object semantics
86
- *
87
- * **The solution:**
88
- * This base class automatically converts `@lazyProp` decorated getters into
89
- * own enumerable getters on each instance during construction.
90
- *
91
- * **Result:**
92
- * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
93
- *
94
- * @example
95
- * ```typescript
96
- * class MyClass extends PlainObjectLike {
97
- * @lazyProp
98
- * get myProp() {
99
- * return fetchFromRustBinding();
100
- * }
101
- * }
102
- * ```
103
- */
104
- var PlainObjectLike = class {
105
- constructor() {
106
- setupLazyProperties(this);
107
- }
108
- };
109
- /**
110
- * Set up lazy properties as own getters on an instance.
111
- * This is called automatically by the `PlainObjectLike` base class constructor.
112
- *
113
- * @param instance - The instance to set up lazy properties on
114
- * @internal
115
- */
116
- function setupLazyProperties(instance) {
117
- const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
118
- if (!lazyFields) return;
119
- for (const [propertyKey, originalGetter] of lazyFields.entries()) {
120
- let cachedValue;
121
- let hasValue = false;
122
- Object.defineProperty(instance, propertyKey, {
123
- get() {
124
- if (!hasValue) {
125
- cachedValue = originalGetter.call(this);
126
- hasValue = true;
127
- }
128
- return cachedValue;
129
- },
130
- enumerable: true,
131
- configurable: true
132
- });
133
- }
134
- }
135
- /**
136
- * Get all lazy field names from a class instance.
137
- *
138
- * @param instance - Instance to inspect
139
- * @returns Set of lazy property names
140
- */
141
- function getLazyFields(instance) {
142
- const lazyFields = instance.constructor[LAZY_FIELDS_KEY];
143
- return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
144
- }
145
-
146
- //#endregion
147
- //#region src/decorators/lazy.ts
148
- /**
149
- * Decorator that marks a getter as lazy-evaluated and cached.
150
- *
151
- * **What "lazy" means here:**
152
- * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
153
- * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
154
- * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
155
- *
156
- * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
157
- * properties on each instance (not on the prototype). This ensures they:
158
- * - Appear in Object.keys() and Object.getOwnPropertyNames()
159
- * - Are included in object spreads ({...obj})
160
- * - Are enumerable in for...in loops
161
- *
162
- * Classes using this decorator must extend `PlainObjectLike` base class.
163
- *
164
- * @example
165
- * ```typescript
166
- * class MyClass extends PlainObjectLike {
167
- * @lazyProp
168
- * get expensiveValue() {
169
- * return someExpensiveComputation();
170
- * }
171
- * }
172
- * ```
173
- */
174
- function lazyProp(target, propertyKey, descriptor) {
175
- if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
176
- const originalGetter = descriptor.get;
177
- target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
178
- return {
179
- enumerable: false,
180
- configurable: true
181
- };
182
- }
183
-
184
- //#endregion
185
- //#region src/utils/asset-source.ts
186
- function transformAssetSource(bindingAssetSource) {
187
- return bindingAssetSource.inner;
188
- }
189
- function bindingAssetSource(source) {
190
- return { inner: source };
191
- }
192
-
193
- //#endregion
194
- //#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
195
- function __decorate(decorators, target, key, desc) {
196
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
197
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
198
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
199
- return c > 3 && r && Object.defineProperty(target, key, r), r;
200
- }
201
-
202
- //#endregion
203
- //#region src/types/output-asset-impl.ts
204
- var OutputAssetImpl = class extends PlainObjectLike {
205
- type = "asset";
206
- constructor(bindingAsset) {
207
- super();
208
- this.bindingAsset = bindingAsset;
209
- }
210
- get fileName() {
211
- return this.bindingAsset.getFileName();
212
- }
213
- get originalFileName() {
214
- return this.bindingAsset.getOriginalFileName() || null;
215
- }
216
- get originalFileNames() {
217
- return this.bindingAsset.getOriginalFileNames();
218
- }
219
- get name() {
220
- return this.bindingAsset.getName() ?? void 0;
221
- }
222
- get names() {
223
- return this.bindingAsset.getNames();
224
- }
225
- get source() {
226
- return transformAssetSource(this.bindingAsset.getSource());
227
- }
228
- __rolldown_external_memory_handle__(keepDataAlive) {
229
- if (keepDataAlive) this.#evaluateAllLazyFields();
230
- return this.bindingAsset.dropInner();
231
- }
232
- #evaluateAllLazyFields() {
233
- for (const field of getLazyFields(this)) this[field];
234
- }
235
- };
236
- __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
237
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
238
- __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
239
- __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
240
- __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
241
- __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
242
-
243
- //#endregion
244
- //#region src/utils/transform-rendered-module.ts
245
- function transformToRenderedModule(bindingRenderedModule) {
246
- return {
247
- get code() {
248
- return bindingRenderedModule.code;
249
- },
250
- get renderedLength() {
251
- return bindingRenderedModule.code?.length || 0;
252
- },
253
- get renderedExports() {
254
- return bindingRenderedModule.renderedExports;
255
- }
256
- };
257
- }
258
-
259
- //#endregion
260
- //#region src/utils/transform-rendered-chunk.ts
261
- function transformRenderedChunk(chunk) {
262
- let modules = null;
263
- return {
264
- type: "chunk",
265
- get name() {
266
- return chunk.name;
267
- },
268
- get isEntry() {
269
- return chunk.isEntry;
270
- },
271
- get isDynamicEntry() {
272
- return chunk.isDynamicEntry;
273
- },
274
- get facadeModuleId() {
275
- return chunk.facadeModuleId;
276
- },
277
- get moduleIds() {
278
- return chunk.moduleIds;
279
- },
280
- get exports() {
281
- return chunk.exports;
282
- },
283
- get fileName() {
284
- return chunk.fileName;
285
- },
286
- get imports() {
287
- return chunk.imports;
288
- },
289
- get dynamicImports() {
290
- return chunk.dynamicImports;
291
- },
292
- get modules() {
293
- if (!modules) modules = transformChunkModules(chunk.modules);
294
- return modules;
295
- }
296
- };
297
- }
298
- function transformChunkModules(modules) {
299
- const result = {};
300
- for (let i = 0; i < modules.values.length; i++) {
301
- let key = modules.keys[i];
302
- const mod = modules.values[i];
303
- result[key] = transformToRenderedModule(mod);
304
- }
305
- return result;
306
- }
307
-
308
- //#endregion
309
- //#region src/types/output-chunk-impl.ts
310
- var OutputChunkImpl = class extends PlainObjectLike {
311
- type = "chunk";
312
- constructor(bindingChunk) {
313
- super();
314
- this.bindingChunk = bindingChunk;
315
- }
316
- get fileName() {
317
- return this.bindingChunk.getFileName();
318
- }
319
- get name() {
320
- return this.bindingChunk.getName();
321
- }
322
- get exports() {
323
- return this.bindingChunk.getExports();
324
- }
325
- get isEntry() {
326
- return this.bindingChunk.getIsEntry();
327
- }
328
- get facadeModuleId() {
329
- return this.bindingChunk.getFacadeModuleId() || null;
330
- }
331
- get isDynamicEntry() {
332
- return this.bindingChunk.getIsDynamicEntry();
333
- }
334
- get sourcemapFileName() {
335
- return this.bindingChunk.getSourcemapFileName() || null;
336
- }
337
- get preliminaryFileName() {
338
- return this.bindingChunk.getPreliminaryFileName();
339
- }
340
- get code() {
341
- return this.bindingChunk.getCode();
342
- }
343
- get modules() {
344
- return transformChunkModules(this.bindingChunk.getModules());
345
- }
346
- get imports() {
347
- return this.bindingChunk.getImports();
348
- }
349
- get dynamicImports() {
350
- return this.bindingChunk.getDynamicImports();
351
- }
352
- get moduleIds() {
353
- return this.bindingChunk.getModuleIds();
354
- }
355
- get map() {
356
- const mapString = this.bindingChunk.getMap();
357
- return mapString ? transformToRollupSourceMap(mapString) : null;
358
- }
359
- __rolldown_external_memory_handle__(keepDataAlive) {
360
- if (keepDataAlive) this.#evaluateAllLazyFields();
361
- return this.bindingChunk.dropInner();
362
- }
363
- #evaluateAllLazyFields() {
364
- for (const field of getLazyFields(this)) this[field];
365
- }
366
- };
367
- __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
368
- __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
369
- __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
370
- __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
371
- __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
372
- __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
373
- __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
374
- __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
375
- __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
376
- __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
377
- __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
378
- __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
379
- __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
380
- __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
381
-
382
- //#endregion
383
- //#region src/types/sourcemap.ts
384
- function bindingifySourcemap(map) {
385
- if (map == null) return;
386
- return { inner: typeof map === "string" ? map : {
387
- file: map.file ?? void 0,
388
- mappings: map.mappings,
389
- sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
390
- sources: map.sources?.map((s) => s ?? void 0),
391
- sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
392
- names: map.names,
393
- x_google_ignoreList: map.x_google_ignoreList,
394
- debugId: "debugId" in map ? map.debugId : void 0
395
- } };
396
- }
397
-
398
- //#endregion
399
- //#region src/utils/transform-to-rollup-output.ts
400
- function transformToRollupSourceMap(map) {
401
- const obj = {
402
- ...JSON.parse(map),
403
- toString() {
404
- return JSON.stringify(obj);
405
- },
406
- toUrl() {
407
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
408
- }
409
- };
410
- return obj;
411
- }
412
- function transformToRollupOutputChunk(bindingChunk) {
413
- return new OutputChunkImpl(bindingChunk);
414
- }
415
- function transformToMutableRollupOutputChunk(bindingChunk, changed) {
416
- const chunk = {
417
- type: "chunk",
418
- get code() {
419
- return bindingChunk.getCode();
420
- },
421
- fileName: bindingChunk.getFileName(),
422
- name: bindingChunk.getName(),
423
- get modules() {
424
- return transformChunkModules(bindingChunk.getModules());
425
- },
426
- get imports() {
427
- return bindingChunk.getImports();
428
- },
429
- get dynamicImports() {
430
- return bindingChunk.getDynamicImports();
431
- },
432
- exports: bindingChunk.getExports(),
433
- isEntry: bindingChunk.getIsEntry(),
434
- facadeModuleId: bindingChunk.getFacadeModuleId() || null,
435
- isDynamicEntry: bindingChunk.getIsDynamicEntry(),
436
- get moduleIds() {
437
- return bindingChunk.getModuleIds();
438
- },
439
- get map() {
440
- const map = bindingChunk.getMap();
441
- return map ? transformToRollupSourceMap(map) : null;
442
- },
443
- sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
444
- preliminaryFileName: bindingChunk.getPreliminaryFileName()
445
- };
446
- const cache = {};
447
- return new Proxy(chunk, {
448
- get(target, p) {
449
- if (p in cache) return cache[p];
450
- const value = target[p];
451
- cache[p] = value;
452
- return value;
453
- },
454
- set(_target, p, newValue) {
455
- cache[p] = newValue;
456
- changed.updated.add(bindingChunk.getFileName());
457
- return true;
458
- },
459
- has(target, p) {
460
- if (p in cache) return true;
461
- return p in target;
462
- }
463
- });
464
- }
465
- function transformToRollupOutputAsset(bindingAsset) {
466
- return new OutputAssetImpl(bindingAsset);
467
- }
468
- function transformToMutableRollupOutputAsset(bindingAsset, changed) {
469
- const asset = {
470
- type: "asset",
471
- fileName: bindingAsset.getFileName(),
472
- originalFileName: bindingAsset.getOriginalFileName() || null,
473
- originalFileNames: bindingAsset.getOriginalFileNames(),
474
- get source() {
475
- return transformAssetSource(bindingAsset.getSource());
476
- },
477
- name: bindingAsset.getName() ?? void 0,
478
- names: bindingAsset.getNames()
479
- };
480
- const cache = {};
481
- return new Proxy(asset, {
482
- get(target, p) {
483
- if (p in cache) return cache[p];
484
- const value = target[p];
485
- cache[p] = value;
486
- return value;
487
- },
488
- set(_target, p, newValue) {
489
- cache[p] = newValue;
490
- changed.updated.add(bindingAsset.getFileName());
491
- return true;
492
- }
493
- });
494
- }
495
- function transformToRollupOutput(output) {
496
- const { chunks, assets } = output;
497
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
498
- }
499
- function transformToMutableRollupOutput(output, changed) {
500
- const { chunks, assets } = output;
501
- return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
502
- }
503
- function transformToOutputBundle(context, output, changed) {
504
- const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
505
- return new Proxy(bundle, {
506
- set(_target, _p, _newValue, _receiver) {
507
- const originalStackTraceLimit = Error.stackTraceLimit;
508
- Error.stackTraceLimit = 2;
509
- const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
510
- const stack = new Error(message).stack ?? message;
511
- Error.stackTraceLimit = originalStackTraceLimit;
512
- context.warn({
513
- message: stack,
514
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
515
- });
516
- return true;
517
- },
518
- deleteProperty(target, property) {
519
- if (typeof property === "string") changed.deleted.add(property);
520
- return true;
521
- }
522
- });
523
- }
524
- function collectChangedBundle(changed, bundle) {
525
- const changes = {};
526
- for (const key in bundle) {
527
- if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
528
- const item = bundle[key];
529
- if (item.type === "asset") changes[key] = {
530
- filename: item.fileName,
531
- originalFileNames: item.originalFileNames,
532
- source: bindingAssetSource(item.source),
533
- names: item.names
534
- };
535
- else changes[key] = {
536
- code: item.code,
537
- filename: item.fileName,
538
- name: item.name,
539
- isEntry: item.isEntry,
540
- exports: item.exports,
541
- modules: {},
542
- imports: item.imports,
543
- dynamicImports: item.dynamicImports,
544
- facadeModuleId: item.facadeModuleId || void 0,
545
- isDynamicEntry: item.isDynamicEntry,
546
- moduleIds: item.moduleIds,
547
- map: bindingifySourcemap(item.map),
548
- sourcemapFilename: item.sourcemapFileName || void 0,
549
- preliminaryFilename: item.preliminaryFileName
550
- };
551
- }
552
- return {
553
- changes,
554
- deleted: changed.deleted
555
- };
556
- }
557
-
558
- //#endregion
559
- //#region src/builtin-plugin/utils.ts
560
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
561
- var BuiltinPlugin = class {
562
- /** Vite-specific option to control plugin ordering */
563
- enforce;
564
- constructor(name, _options) {
565
- this.name = name;
566
- this._options = _options;
567
- }
568
- };
569
- function makeBuiltinPluginCallable(plugin) {
570
- let callablePlugin = new import_binding.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
571
- const wrappedPlugin = plugin;
572
- for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
573
- try {
574
- return await callablePlugin[key](...args);
575
- } catch (e) {
576
- if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
577
- return error(logPluginError(e, plugin.name, {
578
- hook: key,
579
- id: key === "transform" ? args[2] : void 0
580
- }));
581
- }
582
- };
583
- return wrappedPlugin;
584
- }
585
- function bindingifyBuiltInPlugin(plugin) {
586
- return {
587
- __name: plugin.name,
588
- options: plugin._options
589
- };
590
- }
591
- function bindingifyManifestPlugin(plugin, pluginContextData) {
592
- const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
593
- return {
594
- __name: plugin.name,
595
- options: {
596
- ...options,
597
- isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
598
- return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
599
- } : void 0
600
- }
601
- };
602
- }
603
- function bindingifyCSSPostPlugin(plugin, pluginContextData) {
604
- const { isOutputOptionsForLegacyChunks, ...options } = plugin._options;
605
- return {
606
- __name: plugin.name,
607
- options: {
608
- ...options,
609
- isLegacy: isOutputOptionsForLegacyChunks ? (opts) => {
610
- return isOutputOptionsForLegacyChunks(pluginContextData.getOutputOptions(opts));
611
- } : void 0,
612
- cssScopeTo() {
613
- const cssScopeTo = {};
614
- for (const [id, opts] of pluginContextData.moduleOptionMap.entries()) if (opts?.meta.vite?.cssScopeTo) cssScopeTo[id] = opts.meta.vite.cssScopeTo;
615
- return cssScopeTo;
616
- }
617
- }
618
- };
619
- }
620
- function bindingifyViteHtmlPlugin(plugin, onLog, logLevel, watchMode, pluginContextData) {
621
- const { preHooks, normalHooks, postHooks, applyHtmlTransforms, ...options } = plugin._options;
622
- if (preHooks.length + normalHooks.length + postHooks.length > 0) return {
623
- __name: plugin.name,
624
- options: {
625
- ...options,
626
- transformIndexHtml: async (html, path, filename, hook, output, chunk) => {
627
- const pluginContext = new MinimalPluginContextImpl(onLog, logLevel, plugin.name, watchMode, "transformIndexHtml");
628
- const context = {
629
- path,
630
- filename,
631
- bundle: output ? transformToOutputBundle(pluginContext, output, {
632
- updated: /* @__PURE__ */ new Set(),
633
- deleted: /* @__PURE__ */ new Set()
634
- }) : void 0,
635
- chunk: chunk ? transformToRollupOutputChunk(chunk) : void 0
636
- };
637
- switch (hook) {
638
- case "transform": return await applyHtmlTransforms(html, preHooks, pluginContext, context);
639
- case "generateBundle": return await applyHtmlTransforms(html, [...normalHooks, ...postHooks], pluginContext, context);
640
- }
641
- },
642
- setModuleSideEffects(id) {
643
- let opts = pluginContextData.getModuleOption(id);
644
- pluginContextData.updateModuleOption(id, {
645
- moduleSideEffects: true,
646
- meta: opts.meta,
647
- invalidate: true
648
- });
649
- }
650
- }
651
- };
652
- return {
653
- __name: plugin.name,
654
- options: plugin._options
655
- };
656
- }
657
-
658
- //#endregion
659
- //#region src/utils/normalize-string-or-regex.ts
660
- function normalizedStringOrRegex(pattern) {
661
- if (!pattern) return;
662
- if (!isReadonlyArray(pattern)) return [pattern];
663
- return pattern;
664
- }
665
- function isReadonlyArray(input) {
666
- return Array.isArray(input);
667
- }
668
-
669
- //#endregion
670
- export { LOG_LEVEL_DEBUG as C, logLevelPriority as D, LOG_LEVEL_WARN as E, normalizeLog as S, LOG_LEVEL_INFO as T, PlainObjectLike as _, bindingifyManifestPlugin as a, description as b, collectChangedBundle as c, bindingifySourcemap as d, transformRenderedChunk as f, lazyProp as g, transformAssetSource as h, bindingifyCSSPostPlugin as i, transformToOutputBundle as l, bindingAssetSource as m, BuiltinPlugin as n, bindingifyViteHtmlPlugin as o, __decorate as p, bindingifyBuiltInPlugin as r, makeBuiltinPluginCallable as s, normalizedStringOrRegex as t, transformToRollupOutput as u, MinimalPluginContextImpl as v, LOG_LEVEL_ERROR as w, version as x, VERSION as y };