@rolldown/browser 1.0.0-beta.47 → 1.0.0-beta.48

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 (37) hide show
  1. package/dist/cli.mjs +22 -9
  2. package/dist/config.d.mts +3 -2
  3. package/dist/config.mjs +6 -4
  4. package/dist/constructors-EhfoQfqh.js +68 -0
  5. package/dist/experimental-index.browser.mjs +36 -106
  6. package/dist/experimental-index.d.mts +18 -58
  7. package/dist/experimental-index.mjs +39 -108
  8. package/dist/filter-index.d.mts +3 -2
  9. package/dist/filter-index.mjs +1 -1
  10. package/dist/index.browser.mjs +2 -1
  11. package/dist/index.d.mts +3 -2
  12. package/dist/index.mjs +5 -3
  13. package/dist/{shared/parse-ast-index-BiBzSGZe.mjs → normalize-string-or-regex-d47jXr3r.js} +38 -109
  14. package/dist/parallel-plugin-worker.mjs +5 -3
  15. package/dist/parallel-plugin.d.mts +3 -2
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +2 -1
  18. package/dist/plugins-index.browser.mjs +39 -0
  19. package/dist/plugins-index.d.mts +31 -0
  20. package/dist/plugins-index.mjs +40 -0
  21. package/dist/rolldown-binding.wasi-browser.js +1 -1
  22. package/dist/rolldown-binding.wasi.cjs +1 -1
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/shared/{binding-CRSqCQIK.d.mts → binding-B4uTNiw2.d.mts} +19 -49
  25. package/dist/shared/constructors-CaN9lKj2.d.mts +32 -0
  26. package/dist/shared/constructors-DcEzB0nc.mjs +68 -0
  27. package/dist/shared/{define-config-pfDd6Le4.d.mts → define-config-Dv3i4cxM.d.mts} +4 -62
  28. package/dist/shared/{load-config-D508WsWM.mjs → load-config-B-QIvCpC.mjs} +1 -1
  29. package/dist/shared/logs-CPsamAuj.mjs +181 -0
  30. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +46 -0
  31. package/dist/shared/parse-ast-index-D9jH_38U.mjs +81 -0
  32. package/dist/shared/{prompt-BDwA3jSr.mjs → prompt-Ckjl2FdJ.mjs} +1 -1
  33. package/dist/shared/{src-DE7RBSfl.mjs → src-CvsuRKGv.mjs} +218 -191
  34. package/dist/shared/utils-CduIqa7h.d.mts +18 -0
  35. package/dist/{src-Deywlnh0.js → src-DLQqj5Wo.js} +203 -405
  36. package/package.json +1 -1
  37. /package/dist/shared/{composable-filters-D_PY7Qa7.mjs → composable-filters-CBpK2Fbc.mjs} +0 -0
@@ -1,260 +1,8 @@
1
- import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingMagicString as BindingMagicString$1, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
1
+ import { a as augmentCodeLocation, c as logInputHookInOutputPlugin, d as logNoFileSystemInBrowser, f as logParseError, h as getCodeFrame, l as logInvalidLogPosition, m as locate, n as BuiltinPlugin, o as error, p as logPluginError, r as bindingifyBuiltInPlugin, s as logCycleLoading, t as normalizedStringOrRegex, u as logMultiplyNotifyOption } from "./normalize-string-or-regex-d47jXr3r.js";
2
+ import { BindingAttachDebugInfo, BindingBundler, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingMagicString as BindingMagicString$1, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
2
3
 
3
4
  //#region package.json
4
- var version = "1.0.0-beta.47";
5
-
6
- //#endregion
7
- //#region src/utils/code-frame.ts
8
- function spaces(index) {
9
- let result = "";
10
- while (index--) result += " ";
11
- return result;
12
- }
13
- function tabsToSpaces(value) {
14
- return value.replace(/^\t+/, (match) => match.split(" ").join(" "));
15
- }
16
- const LINE_TRUNCATE_LENGTH = 120;
17
- const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
18
- const ELLIPSIS = "...";
19
- function getCodeFrame(source, line, column) {
20
- let lines = source.split("\n");
21
- if (line > lines.length) return "";
22
- const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length + MIN_CHARACTERS_SHOWN_AFTER_LOCATION + 3, LINE_TRUNCATE_LENGTH);
23
- const frameStart = Math.max(0, line - 3);
24
- let frameEnd = Math.min(line + 2, lines.length);
25
- lines = lines.slice(frameStart, frameEnd);
26
- while (!/\S/.test(lines[lines.length - 1])) {
27
- lines.pop();
28
- frameEnd -= 1;
29
- }
30
- const digits = String(frameEnd).length;
31
- return lines.map((sourceLine, index) => {
32
- const isErrorLine = frameStart + index + 1 === line;
33
- let lineNumber = String(index + frameStart + 1);
34
- while (lineNumber.length < digits) lineNumber = ` ${lineNumber}`;
35
- let displayedLine = tabsToSpaces(sourceLine);
36
- if (displayedLine.length > maxLineLength) displayedLine = `${displayedLine.slice(0, maxLineLength - 3)}${ELLIPSIS}`;
37
- if (isErrorLine) {
38
- const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + "^";
39
- return `${lineNumber}: ${displayedLine}\n${indicator}`;
40
- }
41
- return `${lineNumber}: ${displayedLine}`;
42
- }).join("\n");
43
- }
44
-
45
- //#endregion
46
- //#region src/utils/style-text.ts
47
- function styleText(...args$1) {
48
- return args$1[1];
49
- }
50
-
51
- //#endregion
52
- //#region src/log/locate-character/index.js
53
- /** @typedef {import('./types').Location} Location */
54
- /**
55
- * @param {import('./types').Range} range
56
- * @param {number} index
57
- */
58
- function rangeContains(range, index) {
59
- return range.start <= index && index < range.end;
60
- }
61
- /**
62
- * @param {string} source
63
- * @param {import('./types').Options} [options]
64
- */
65
- function getLocator(source, options = {}) {
66
- const { offsetLine = 0, offsetColumn = 0 } = options;
67
- let start = 0;
68
- const ranges = source.split("\n").map((line, i$1) => {
69
- const end = start + line.length + 1;
70
- /** @type {import('./types').Range} */
71
- const range = {
72
- start,
73
- end,
74
- line: i$1
75
- };
76
- start = end;
77
- return range;
78
- });
79
- let i = 0;
80
- /**
81
- * @param {string | number} search
82
- * @param {number} [index]
83
- * @returns {Location | undefined}
84
- */
85
- function locator(search, index) {
86
- if (typeof search === "string") search = source.indexOf(search, index ?? 0);
87
- if (search === -1) return void 0;
88
- let range = ranges[i];
89
- const d = search >= range.end ? 1 : -1;
90
- while (range) {
91
- if (rangeContains(range, search)) return {
92
- line: offsetLine + range.line,
93
- column: offsetColumn + search - range.start,
94
- character: search
95
- };
96
- i += d;
97
- range = ranges[i];
98
- }
99
- }
100
- return locator;
101
- }
102
- /**
103
- * @param {string} source
104
- * @param {string | number} search
105
- * @param {import('./types').Options} [options]
106
- * @returns {Location | undefined}
107
- */
108
- function locate(source, search, options) {
109
- return getLocator(source, options)(search, options && options.startIndex);
110
- }
111
-
112
- //#endregion
113
- //#region src/log/logs.ts
114
- 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", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER", DEPRECATED_DEFINE = "DEPRECATED_DEFINE", DEPRECATED_INJECT = "DEPRECATED_INJECT", DEPRECATED_PROFILER_NAMES = "DEPRECATED_PROFILER_NAMES", DEPRECATED_KEEP_NAMES = "DEPRECATED_KEEP_NAMES", DEPRECATED_DROP_LABELS = "DEPRECATED_DROP_LABELS";
115
- function logParseError(message) {
116
- return {
117
- code: PARSE_ERROR,
118
- message
119
- };
120
- }
121
- function logInvalidLogPosition(pluginName) {
122
- return {
123
- code: INVALID_LOG_POSITION,
124
- 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.`
125
- };
126
- }
127
- function logInputHookInOutputPlugin(pluginName, hookName) {
128
- return {
129
- code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
130
- 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.`
131
- };
132
- }
133
- function logCycleLoading(pluginName, moduleId) {
134
- return {
135
- code: CYCLE_LOADING,
136
- message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`
137
- };
138
- }
139
- function logMultiplyNotifyOption() {
140
- return {
141
- code: MULTIPLY_NOTIFY_OPTION,
142
- message: `Found multiply notify option at watch options, using first one to start notify watcher.`
143
- };
144
- }
145
- function logNoFileSystemInBrowser(method) {
146
- return {
147
- code: NO_FS_IN_BROWSER,
148
- message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
149
- };
150
- }
151
- function logDeprecatedDefine() {
152
- return {
153
- code: DEPRECATED_DEFINE,
154
- message: `${styleText(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "define" option is deprecated. Use "transform.define" instead.`
155
- };
156
- }
157
- function logDeprecatedInject() {
158
- return {
159
- code: DEPRECATED_INJECT,
160
- message: `${styleText(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "inject" option is deprecated. Use "transform.inject" instead.`
161
- };
162
- }
163
- function logDeprecatedProfilerNames() {
164
- return {
165
- code: DEPRECATED_PROFILER_NAMES,
166
- message: "The top-level \"profilerNames\" option is deprecated. Use \"output.generatedCode.profilerNames\" instead."
167
- };
168
- }
169
- function logDeprecatedKeepNames() {
170
- return {
171
- code: DEPRECATED_KEEP_NAMES,
172
- message: "The top-level \"keepNames\" option is deprecated. Use \"output.keepNames\" instead."
173
- };
174
- }
175
- function logDeprecatedDropLabels() {
176
- return {
177
- code: DEPRECATED_DROP_LABELS,
178
- message: `${styleText(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "dropLabels" option is deprecated. Use "transform.dropLabels" instead.`
179
- };
180
- }
181
- function logPluginError(error$1, plugin, { hook, id: id$1 } = {}) {
182
- try {
183
- const code$1 = error$1.code;
184
- if (!error$1.pluginCode && code$1 != null && (typeof code$1 !== "string" || !code$1.startsWith("PLUGIN_"))) error$1.pluginCode = code$1;
185
- error$1.code = PLUGIN_ERROR;
186
- error$1.plugin = plugin;
187
- if (hook) error$1.hook = hook;
188
- if (id$1) error$1.id = id$1;
189
- } catch (_) {} finally {
190
- return error$1;
191
- }
192
- }
193
- function error(base) {
194
- if (!(base instanceof Error)) {
195
- base = Object.assign(new Error(base.message), base);
196
- Object.defineProperty(base, "name", {
197
- value: "RollupError",
198
- writable: true
199
- });
200
- }
201
- throw base;
202
- }
203
- function augmentCodeLocation(properties, pos, source, id$1) {
204
- if (typeof pos === "object") {
205
- const { line, column } = pos;
206
- properties.loc = {
207
- column,
208
- file: id$1,
209
- line
210
- };
211
- } else {
212
- properties.pos = pos;
213
- const location = locate(source, pos, { offsetLine: 1 });
214
- if (!location) return;
215
- const { line, column } = location;
216
- properties.loc = {
217
- column,
218
- file: id$1,
219
- line
220
- };
221
- }
222
- if (properties.frame === void 0) {
223
- const { line, column } = properties.loc;
224
- properties.frame = getCodeFrame(source, line, column);
225
- }
226
- }
227
-
228
- //#endregion
229
- //#region src/builtin-plugin/utils.ts
230
- var BuiltinPlugin = class {
231
- constructor(name, _options) {
232
- this.name = name;
233
- this._options = _options;
234
- }
235
- };
236
- function makeBuiltinPluginCallable(plugin) {
237
- let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
238
- const wrappedPlugin = plugin;
239
- for (const key in callablePlugin) wrappedPlugin[key] = async function(...args$1) {
240
- try {
241
- return await callablePlugin[key](...args$1);
242
- } catch (e$1) {
243
- if (e$1 instanceof Error && !e$1.stack?.includes("at ")) Error.captureStackTrace(e$1, wrappedPlugin[key]);
244
- return error(logPluginError(e$1, plugin.name, {
245
- hook: key,
246
- id: key === "transform" ? args$1[2] : void 0
247
- }));
248
- }
249
- };
250
- return wrappedPlugin;
251
- }
252
- function bindingifyBuiltInPlugin(plugin) {
253
- return {
254
- __name: plugin.name,
255
- options: plugin._options
256
- };
257
- }
5
+ var version = "1.0.0-beta.48";
258
6
 
259
7
  //#endregion
260
8
  //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
@@ -2031,6 +1779,12 @@ function safeParse(schema, input, config2) {
2031
1779
  };
2032
1780
  }
2033
1781
 
1782
+ //#endregion
1783
+ //#region src/utils/style-text.ts
1784
+ function styleText(...args$1) {
1785
+ return args$1[1];
1786
+ }
1787
+
2034
1788
  //#endregion
2035
1789
  //#region src/utils/validator.ts
2036
1790
  const StringOrRegExpSchema = union([string(), instance(RegExp)]);
@@ -2127,8 +1881,8 @@ const TransformOptionsSchema = object({
2127
1881
  JsxOptionsSchema
2128
1882
  ])),
2129
1883
  target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment")),
2130
- define: optional(record(string(), string())),
2131
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
1884
+ define: pipe(optional(record(string(), string())), description("Define global variables")),
1885
+ inject: pipe(optional(record(string(), union([string(), tuple([string(), string()])]))), description("Inject import statements on demand")),
2132
1886
  dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names"))
2133
1887
  });
2134
1888
  const WatchOptionsSchema = strictObject({
@@ -2282,14 +2036,9 @@ const InputOptionsSchema = strictObject({
2282
2036
  })])),
2283
2037
  nativeMagicString: optional(boolean())
2284
2038
  })),
2285
- define: pipe(optional(record(string(), string())), description("Define global variables")),
2286
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
2287
- profilerNames: optional(boolean()),
2288
2039
  transform: optional(TransformOptionsSchema),
2289
2040
  watch: optional(union([WatchOptionsSchema, literal(false)])),
2290
- dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
2291
2041
  checks: optional(ChecksOptionsSchema),
2292
- keepNames: pipe(optional(boolean()), description("Keep function/class name")),
2293
2042
  debug: pipe(optional(object({ sessionId: pipe(optional(string()), description("Used to name the build.")) })), description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.")),
2294
2043
  preserveEntrySignatures: pipe(optional(union([
2295
2044
  literal("strict"),
@@ -2302,7 +2051,6 @@ const InputOptionsSchema = strictObject({
2302
2051
  const InputCliOverrideSchema = strictObject({
2303
2052
  input: pipe(optional(array(string())), description("Entry file")),
2304
2053
  external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
2305
- inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
2306
2054
  treeshake: pipe(optional(boolean()), description("enable treeshaking")),
2307
2055
  makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
2308
2056
  preserveEntrySignatures: pipe(optional(literal(false)), description("Avoid facade chunks for entry points")),
@@ -2317,7 +2065,6 @@ const InputCliOptionsSchema = omit(strictObject({
2317
2065
  "onLog",
2318
2066
  "resolve",
2319
2067
  "experimental",
2320
- "profilerNames",
2321
2068
  "watch"
2322
2069
  ]);
2323
2070
  const ModuleFormatSchema = union([
@@ -2504,33 +2251,72 @@ function validateOption(key, options) {
2504
2251
  }
2505
2252
 
2506
2253
  //#endregion
2507
- //#region src/decorators/lazy.ts
2254
+ //#region src/types/plain-object-like.ts
2508
2255
  const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
2509
- const LAZY_CACHE_PREFIX = "__cached_";
2510
2256
  /**
2511
- * Legacy decorator that makes a getter lazy-evaluated and cached.
2512
- * Also auto-registers the field for batch prefetching.
2257
+ * Base class for classes that use `@lazyProp` decorated properties.
2258
+ *
2259
+ * **Design Pattern in Rolldown:**
2260
+ * This is a common pattern in Rolldown due to its three-layer architecture:
2261
+ * TypeScript API → NAPI Bindings → Rust Core
2262
+ *
2263
+ * **Why we use getters:**
2264
+ * For performance - to lazily fetch data from Rust bindings only when needed,
2265
+ * rather than eagerly fetching all data during object construction.
2266
+ *
2267
+ * **The problem:**
2268
+ * Getters defined on class prototypes are non-enumerable by default, which breaks:
2269
+ * - Object spread operators ({...obj})
2270
+ * - Object.keys() and similar methods
2271
+ * - Standard JavaScript object semantics
2272
+ *
2273
+ * **The solution:**
2274
+ * This base class automatically converts `@lazyProp` decorated getters into
2275
+ * own enumerable getters on each instance during construction.
2276
+ *
2277
+ * **Result:**
2278
+ * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
2513
2279
  *
2514
2280
  * @example
2515
2281
  * ```typescript
2516
- * class MyClass {
2517
- * @lazy
2518
- * get expensiveValue() {
2519
- * return someExpensiveComputation();
2282
+ * class MyClass extends PlainObjectLike {
2283
+ * @lazyProp
2284
+ * get myProp() {
2285
+ * return fetchFromRustBinding();
2520
2286
  * }
2521
2287
  * }
2522
2288
  * ```
2523
2289
  */
2524
- function lazy(target, propertyKey, descriptor) {
2525
- if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Set();
2526
- target.constructor[LAZY_FIELDS_KEY].add(propertyKey);
2527
- const originalGetter = descriptor.get;
2528
- const cacheKey = LAZY_CACHE_PREFIX + propertyKey;
2529
- descriptor.get = function() {
2530
- if (!(cacheKey in this)) this[cacheKey] = originalGetter.call(this);
2531
- return this[cacheKey];
2532
- };
2533
- return descriptor;
2290
+ var PlainObjectLike = class {
2291
+ constructor() {
2292
+ setupLazyProperties(this);
2293
+ }
2294
+ };
2295
+ /**
2296
+ * Set up lazy properties as own getters on an instance.
2297
+ * This is called automatically by the `PlainObjectLike` base class constructor.
2298
+ *
2299
+ * @param instance - The instance to set up lazy properties on
2300
+ * @internal
2301
+ */
2302
+ function setupLazyProperties(instance$1) {
2303
+ const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2304
+ if (!lazyFields) return;
2305
+ for (const [propertyKey, originalGetter] of lazyFields.entries()) {
2306
+ let cachedValue;
2307
+ let hasValue = false;
2308
+ Object.defineProperty(instance$1, propertyKey, {
2309
+ get() {
2310
+ if (!hasValue) {
2311
+ cachedValue = originalGetter.call(this);
2312
+ hasValue = true;
2313
+ }
2314
+ return cachedValue;
2315
+ },
2316
+ enumerable: true,
2317
+ configurable: true
2318
+ });
2319
+ }
2534
2320
  }
2535
2321
  /**
2536
2322
  * Get all lazy field names from a class instance.
@@ -2539,28 +2325,46 @@ function lazy(target, propertyKey, descriptor) {
2539
2325
  * @returns Set of lazy property names
2540
2326
  */
2541
2327
  function getLazyFields(instance$1) {
2542
- return instance$1.constructor[LAZY_FIELDS_KEY] || /* @__PURE__ */ new Set();
2328
+ const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2329
+ return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
2543
2330
  }
2544
2331
 
2545
2332
  //#endregion
2546
- //#region src/decorators/non-enumerable.ts
2333
+ //#region src/decorators/lazy.ts
2547
2334
  /**
2548
- * Decorator that makes a property or method non-enumerable.
2549
- * This hides the property from enumeration (e.g., Object.keys(), for...in loops).
2335
+ * Decorator that marks a getter as lazy-evaluated and cached.
2336
+ *
2337
+ * **What "lazy" means here:**
2338
+ * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
2339
+ * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
2340
+ * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
2341
+ *
2342
+ * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
2343
+ * properties on each instance (not on the prototype). This ensures they:
2344
+ * - Appear in Object.keys() and Object.getOwnPropertyNames()
2345
+ * - Are included in object spreads ({...obj})
2346
+ * - Are enumerable in for...in loops
2347
+ *
2348
+ * Classes using this decorator must extend `PlainObjectLike` base class.
2550
2349
  *
2551
2350
  * @example
2552
2351
  * ```typescript
2553
- * class MyClass {
2554
- * @nonEnumerable
2555
- * hiddenMethod() {
2556
- * return 'This method will not show up in Object.keys()';
2352
+ * class MyClass extends PlainObjectLike {
2353
+ * @lazyProp
2354
+ * get expensiveValue() {
2355
+ * return someExpensiveComputation();
2557
2356
  * }
2558
2357
  * }
2559
2358
  * ```
2560
2359
  */
2561
- function nonEnumerable(target, propertyKey, descriptor) {
2562
- descriptor.enumerable = false;
2563
- return descriptor;
2360
+ function lazyProp(target, propertyKey, descriptor) {
2361
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
2362
+ const originalGetter = descriptor.get;
2363
+ target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
2364
+ return {
2365
+ enumerable: false,
2366
+ configurable: true
2367
+ };
2564
2368
  }
2565
2369
 
2566
2370
  //#endregion
@@ -2583,9 +2387,10 @@ function __decorate(decorators, target, key, desc) {
2583
2387
 
2584
2388
  //#endregion
2585
2389
  //#region src/types/output-asset-impl.ts
2586
- var OutputAssetImpl = class {
2390
+ var OutputAssetImpl = class extends PlainObjectLike {
2587
2391
  type = "asset";
2588
2392
  constructor(bindingAsset) {
2393
+ super();
2589
2394
  this.bindingAsset = bindingAsset;
2590
2395
  }
2591
2396
  get fileName() {
@@ -2614,13 +2419,12 @@ var OutputAssetImpl = class {
2614
2419
  for (const field of getLazyFields(this)) this[field];
2615
2420
  }
2616
2421
  };
2617
- __decorate([lazy], OutputAssetImpl.prototype, "fileName", null);
2618
- __decorate([lazy], OutputAssetImpl.prototype, "originalFileName", null);
2619
- __decorate([lazy], OutputAssetImpl.prototype, "originalFileNames", null);
2620
- __decorate([lazy], OutputAssetImpl.prototype, "name", null);
2621
- __decorate([lazy], OutputAssetImpl.prototype, "names", null);
2622
- __decorate([lazy], OutputAssetImpl.prototype, "source", null);
2623
- __decorate([nonEnumerable], OutputAssetImpl.prototype, "__rolldown_external_memory_handle__", null);
2422
+ __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
2423
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
2424
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
2425
+ __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
2426
+ __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
2427
+ __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
2624
2428
 
2625
2429
  //#endregion
2626
2430
  //#region src/utils/transform-rendered-module.ts
@@ -2689,9 +2493,10 @@ function transformChunkModules(modules) {
2689
2493
 
2690
2494
  //#endregion
2691
2495
  //#region src/types/output-chunk-impl.ts
2692
- var OutputChunkImpl = class {
2496
+ var OutputChunkImpl = class extends PlainObjectLike {
2693
2497
  type = "chunk";
2694
2498
  constructor(bindingChunk) {
2499
+ super();
2695
2500
  this.bindingChunk = bindingChunk;
2696
2501
  }
2697
2502
  get fileName() {
@@ -2745,21 +2550,20 @@ var OutputChunkImpl = class {
2745
2550
  for (const field of getLazyFields(this)) this[field];
2746
2551
  }
2747
2552
  };
2748
- __decorate([lazy], OutputChunkImpl.prototype, "fileName", null);
2749
- __decorate([lazy], OutputChunkImpl.prototype, "name", null);
2750
- __decorate([lazy], OutputChunkImpl.prototype, "exports", null);
2751
- __decorate([lazy], OutputChunkImpl.prototype, "isEntry", null);
2752
- __decorate([lazy], OutputChunkImpl.prototype, "facadeModuleId", null);
2753
- __decorate([lazy], OutputChunkImpl.prototype, "isDynamicEntry", null);
2754
- __decorate([lazy], OutputChunkImpl.prototype, "sourcemapFileName", null);
2755
- __decorate([lazy], OutputChunkImpl.prototype, "preliminaryFileName", null);
2756
- __decorate([lazy], OutputChunkImpl.prototype, "code", null);
2757
- __decorate([lazy], OutputChunkImpl.prototype, "modules", null);
2758
- __decorate([lazy], OutputChunkImpl.prototype, "imports", null);
2759
- __decorate([lazy], OutputChunkImpl.prototype, "dynamicImports", null);
2760
- __decorate([lazy], OutputChunkImpl.prototype, "moduleIds", null);
2761
- __decorate([lazy], OutputChunkImpl.prototype, "map", null);
2762
- __decorate([nonEnumerable], OutputChunkImpl.prototype, "__rolldown_external_memory_handle__", null);
2553
+ __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
2554
+ __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
2555
+ __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
2556
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
2557
+ __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
2558
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
2559
+ __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
2560
+ __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
2561
+ __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
2562
+ __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
2563
+ __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
2564
+ __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
2565
+ __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
2566
+ __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
2763
2567
 
2764
2568
  //#endregion
2765
2569
  //#region src/types/sourcemap.ts
@@ -2939,8 +2743,9 @@ function collectChangedBundle(changed, bundle) {
2939
2743
 
2940
2744
  //#endregion
2941
2745
  //#region src/types/rolldown-output-impl.ts
2942
- var RolldownOutputImpl = class {
2746
+ var RolldownOutputImpl = class extends PlainObjectLike {
2943
2747
  constructor(bindingOutputs) {
2748
+ super();
2944
2749
  this.bindingOutputs = bindingOutputs;
2945
2750
  }
2946
2751
  get output() {
@@ -2958,8 +2763,7 @@ var RolldownOutputImpl = class {
2958
2763
  return { freed: true };
2959
2764
  }
2960
2765
  };
2961
- __decorate([lazy], RolldownOutputImpl.prototype, "output", null);
2962
- __decorate([nonEnumerable], RolldownOutputImpl.prototype, "__rolldown_external_memory_handle__", null);
2766
+ __decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
2963
2767
 
2964
2768
  //#endregion
2965
2769
  //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
@@ -4113,9 +3917,10 @@ function wrapHandlers(plugin) {
4113
3917
 
4114
3918
  //#endregion
4115
3919
  //#region src/options/normalized-input-options.ts
4116
- var NormalizedInputOptionsImpl = class {
3920
+ var NormalizedInputOptionsImpl = class extends PlainObjectLike {
4117
3921
  inner;
4118
3922
  constructor(inner, onLog) {
3923
+ super();
4119
3924
  this.onLog = onLog;
4120
3925
  this.inner = inner;
4121
3926
  }
@@ -4135,11 +3940,17 @@ var NormalizedInputOptionsImpl = class {
4135
3940
  return this.inner.context;
4136
3941
  }
4137
3942
  };
3943
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
3944
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
3945
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
3946
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
3947
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
4138
3948
 
4139
3949
  //#endregion
4140
3950
  //#region src/options/normalized-output-options.ts
4141
- var NormalizedOutputOptionsImpl = class {
3951
+ var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
4142
3952
  constructor(inner, outputOptions, normalizedOutputPlugins) {
3953
+ super();
4143
3954
  this.inner = inner;
4144
3955
  this.outputOptions = outputOptions;
4145
3956
  this.normalizedOutputPlugins = normalizedOutputPlugins;
@@ -4259,6 +4070,42 @@ var NormalizedOutputOptionsImpl = class {
4259
4070
  return this.inner.minifyInternalExports ?? false;
4260
4071
  }
4261
4072
  };
4073
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
4074
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
4075
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
4076
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
4077
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
4078
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
4079
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
4080
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
4081
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssEntryFileNames", null);
4082
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssChunkFileNames", null);
4083
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
4084
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
4085
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
4086
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
4087
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
4088
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
4089
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
4090
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
4091
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
4092
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
4093
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
4094
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
4095
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
4096
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
4097
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
4098
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
4099
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
4100
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
4101
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
4102
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
4103
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
4104
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
4105
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
4106
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
4107
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
4108
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
4262
4109
  function normalizeAddon(value) {
4263
4110
  if (typeof value === "function") return value;
4264
4111
  return () => value || "";
@@ -4361,17 +4208,6 @@ var PluginContextData = class {
4361
4208
  }
4362
4209
  };
4363
4210
 
4364
- //#endregion
4365
- //#region src/utils/normalize-string-or-regex.ts
4366
- function normalizedStringOrRegex(pattern) {
4367
- if (!pattern) return;
4368
- if (!isReadonlyArray(pattern)) return [pattern];
4369
- return pattern;
4370
- }
4371
- function isReadonlyArray(input) {
4372
- return Array.isArray(input);
4373
- }
4374
-
4375
4211
  //#endregion
4376
4212
  //#region src/utils/normalize-transform-options.ts
4377
4213
  /**
@@ -4379,26 +4215,11 @@ function isReadonlyArray(input) {
4379
4215
  *
4380
4216
  * Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
4381
4217
  */
4382
- function normalizeTransformOptions(inputOptions, onLog) {
4218
+ function normalizeTransformOptions(inputOptions) {
4383
4219
  const transform = inputOptions.transform;
4384
- let define;
4385
- if (transform?.define) define = Object.entries(transform.define);
4386
- else if (inputOptions.define) {
4387
- onLog(LOG_LEVEL_WARN, logDeprecatedDefine());
4388
- define = Object.entries(inputOptions.define);
4389
- }
4390
- let inject;
4391
- if (transform?.inject) inject = transform.inject;
4392
- else if (inputOptions.inject) {
4393
- onLog(LOG_LEVEL_WARN, logDeprecatedInject());
4394
- inject = inputOptions.inject;
4395
- }
4396
- let dropLabels;
4397
- if (transform?.dropLabels) dropLabels = transform.dropLabels;
4398
- else if (inputOptions.dropLabels) {
4399
- onLog(LOG_LEVEL_WARN, logDeprecatedDropLabels());
4400
- dropLabels = inputOptions.dropLabels;
4401
- }
4220
+ const define = transform?.define ? Object.entries(transform.define) : void 0;
4221
+ const inject = transform?.inject;
4222
+ const dropLabels = transform?.dropLabels;
4402
4223
  let oxcTransformOptions;
4403
4224
  if (transform) {
4404
4225
  const { define: _define, inject: _inject, dropLabels: _dropLabels,...rest } = transform;
@@ -4424,19 +4245,7 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
4424
4245
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
4425
4246
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
4426
4247
  });
4427
- const normalizedTransform = normalizeTransformOptions(inputOptions, onLog);
4428
- let profilerNames;
4429
- if (outputOptions.generatedCode?.profilerNames !== void 0) profilerNames = outputOptions.generatedCode.profilerNames;
4430
- else if (inputOptions.profilerNames !== void 0) {
4431
- onLog(LOG_LEVEL_WARN, logDeprecatedProfilerNames());
4432
- profilerNames = inputOptions.profilerNames;
4433
- }
4434
- let keepNames;
4435
- if (outputOptions.keepNames !== void 0) keepNames = outputOptions.keepNames;
4436
- else if (inputOptions.keepNames !== void 0) {
4437
- onLog(LOG_LEVEL_WARN, logDeprecatedKeepNames());
4438
- keepNames = inputOptions.keepNames;
4439
- }
4248
+ const normalizedTransform = normalizeTransformOptions(inputOptions);
4440
4249
  return {
4441
4250
  input: bindingifyInput(inputOptions.input),
4442
4251
  plugins,
@@ -4452,11 +4261,11 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
4452
4261
  define: normalizedTransform.define,
4453
4262
  inject: bindingifyInject(normalizedTransform.inject),
4454
4263
  experimental: bindingifyExperimental(inputOptions.experimental),
4455
- profilerNames,
4264
+ profilerNames: outputOptions.generatedCode?.profilerNames,
4456
4265
  transform: normalizedTransform.oxcTransformOptions,
4457
4266
  watch: bindingifyWatch(inputOptions.watch),
4458
4267
  dropLabels: normalizedTransform.dropLabels,
4459
- keepNames,
4268
+ keepNames: outputOptions.keepNames,
4460
4269
  checks: inputOptions.checks,
4461
4270
  deferSyncScanData: () => {
4462
4271
  let ret = [];
@@ -4810,63 +4619,52 @@ Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4810
4619
  var RolldownBuild = class RolldownBuild {
4811
4620
  #inputOptions;
4812
4621
  #bundler;
4813
- #bundlerImpl;
4622
+ #stopWorkers;
4814
4623
  static asyncRuntimeShutdown = false;
4815
4624
  constructor(inputOptions) {
4816
4625
  this.#inputOptions = inputOptions;
4817
4626
  this.#bundler = new BindingBundler();
4818
4627
  }
4819
4628
  get closed() {
4820
- return this.#bundlerImpl?.impl.closed ?? true;
4821
- }
4822
- async #getBundlerWithStopWorker(outputOptions) {
4823
- if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4824
- const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4825
- if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
4826
- try {
4827
- return this.#bundlerImpl = {
4828
- impl: this.#bundler.createImpl(option.bundlerOptions),
4829
- stopWorkers: option.stopWorkers,
4830
- shutdown: () => {
4831
- shutdownAsyncRuntime();
4832
- RolldownBuild.asyncRuntimeShutdown = true;
4833
- }
4834
- };
4835
- } catch (e$1) {
4836
- await option.stopWorkers?.();
4837
- throw e$1;
4838
- }
4839
- }
4840
- async scan() {
4841
- const { impl } = await this.#getBundlerWithStopWorker({});
4842
- unwrapBindingResult(await impl.scan());
4629
+ return this.#bundler.closed;
4843
4630
  }
4844
4631
  async generate(outputOptions = {}) {
4845
- validateOption("output", outputOptions);
4846
- const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4847
- return new RolldownOutputImpl(unwrapBindingResult(await impl.generate()));
4632
+ return this.#build(false, outputOptions);
4848
4633
  }
4849
4634
  async write(outputOptions = {}) {
4850
- validateOption("output", outputOptions);
4851
- const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4852
- return new RolldownOutputImpl(unwrapBindingResult(await impl.write()));
4635
+ return this.#build(true, outputOptions);
4853
4636
  }
4854
4637
  /**
4855
4638
  * Close the build and free resources.
4856
4639
  */
4857
4640
  async close() {
4858
- if (this.#bundlerImpl) {
4859
- await this.#bundlerImpl.stopWorkers?.();
4860
- await this.#bundlerImpl.impl.close();
4861
- this.#bundlerImpl.shutdown();
4862
- this.#bundlerImpl = void 0;
4863
- }
4641
+ await this.#stopWorkers?.();
4642
+ await this.#bundler.close();
4643
+ shutdownAsyncRuntime();
4644
+ RolldownBuild.asyncRuntimeShutdown = true;
4645
+ this.#stopWorkers = void 0;
4864
4646
  }
4865
4647
  async [Symbol.asyncDispose]() {
4866
4648
  await this.close();
4867
4649
  }
4868
4650
  get watchFiles() {
4869
- return this.#bundlerImpl?.impl.getWatchFiles() ?? Promise.resolve([]);
4651
+ return Promise.resolve(this.#bundler.getWatchFiles());
4652
+ }
4653
+ async #build(isWrite, outputOptions) {
4654
+ validateOption("output", outputOptions);
4655
+ await this.#stopWorkers?.();
4656
+ const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4657
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
4658
+ try {
4659
+ this.#stopWorkers = option.stopWorkers;
4660
+ let output;
4661
+ if (isWrite) output = await this.#bundler.write(option.bundlerOptions);
4662
+ else output = await this.#bundler.generate(option.bundlerOptions);
4663
+ return new RolldownOutputImpl(unwrapBindingResult(output));
4664
+ } catch (e$1) {
4665
+ await option.stopWorkers?.();
4666
+ throw e$1;
4667
+ }
4870
4668
  }
4871
4669
  };
4872
4670
 
@@ -5033,4 +4831,4 @@ function defineConfig(config) {
5033
4831
  const VERSION = version;
5034
4832
 
5035
4833
  //#endregion
5036
- export { build as a, createBundlerOptions as c, transformToRollupOutput as d, bindingifySourcemap$1 as f, makeBuiltinPluginCallable as h, watch as i, normalizedStringOrRegex as l, BuiltinPlugin as m, VERSION as n, rolldown as o, PluginDriver as p, defineConfig as r, RolldownBuild as s, BindingMagicString$1 as t, normalizeBindingResult as u };
4834
+ export { build as a, createBundlerOptions as c, transformToRollupOutput as d, bindingifySourcemap$1 as f, watch as i, normalizeBindingResult as l, PluginDriver as m, VERSION as n, rolldown as o, validateOption as p, defineConfig as r, RolldownBuild as s, BindingMagicString$1 as t, unwrapBindingResult as u };