rolldown 1.0.0-beta.46 → 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 (30) hide show
  1. package/dist/cli-setup.mjs +2 -2
  2. package/dist/cli.mjs +23 -10
  3. package/dist/config.d.mts +3 -2
  4. package/dist/config.mjs +7 -5
  5. package/dist/experimental-index.d.mts +18 -58
  6. package/dist/experimental-index.mjs +47 -112
  7. package/dist/filter-index.d.mts +3 -2
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/index.d.mts +3 -2
  10. package/dist/index.mjs +6 -4
  11. package/dist/parallel-plugin-worker.mjs +7 -5
  12. package/dist/parallel-plugin.d.mts +3 -2
  13. package/dist/parse-ast-index.d.mts +1 -1
  14. package/dist/parse-ast-index.mjs +3 -2
  15. package/dist/plugins-index.d.mts +31 -0
  16. package/dist/plugins-index.mjs +41 -0
  17. package/dist/shared/{binding-DOZoR4bu.mjs → binding-Drb7x8Xk.mjs} +28 -47
  18. package/dist/shared/{binding-CCMrV5an.d.mts → binding-TAvxYaaL.d.mts} +49 -58
  19. package/dist/shared/constructors-CPzYu5kE.mjs +68 -0
  20. package/dist/shared/constructors-DlLr_UMo.d.mts +32 -0
  21. package/dist/shared/{define-config-Czc1YEBi.d.mts → define-config-De0wBOd9.d.mts} +4 -62
  22. package/dist/shared/{load-config-Brje6-4J.mjs → load-config-CgaGIE8O.mjs} +1 -1
  23. package/dist/shared/{parse-ast-index-oPgrkdqc.mjs → logs-CSQ_UMWp.mjs} +2 -124
  24. package/dist/shared/normalize-string-or-regex-C20xiVob.mjs +47 -0
  25. package/dist/shared/parse-ast-index-khff6py4.mjs +82 -0
  26. package/dist/shared/{prompt-YGfbLmz5.mjs → prompt-sxF8x3Tv.mjs} +1 -1
  27. package/dist/shared/{src-D1weNlnG.mjs → src-cg9B-h5W.mjs} +234 -203
  28. package/dist/shared/utils-CzdPrevI.d.mts +18 -0
  29. package/package.json +18 -18
  30. /package/dist/shared/{misc-usdOVIou.mjs → misc-DpQNcSw4.mjs} +0 -0
@@ -1,8 +1,11 @@
1
- import { n as __toESM, t as require_binding } from "./binding-DOZoR4bu.mjs";
2
- import { a as logCycleLoading, c as logDeprecatedInject, d as logInputHookInOutputPlugin, f as logInvalidLogPosition, h as styleText, i as error, l as logDeprecatedKeepNames, m as logPluginError, o as logDeprecatedDefine, p as logMultiplyNotifyOption, r as augmentCodeLocation, s as logDeprecatedDropLabels, t as parseAst, u as logDeprecatedProfilerNames } from "./parse-ast-index-oPgrkdqc.mjs";
3
- import { a as unreachable, i as unimplemented, o as unsupported, r as noop, t as arraify } from "./misc-usdOVIou.mjs";
1
+ import { t as require_binding } from "./binding-Drb7x8Xk.mjs";
2
+ import { a as logInvalidLogPosition, c as logPluginError, i as logInputHookInOutputPlugin, n as error, o as logMultiplyNotifyOption, r as logCycleLoading, t as augmentCodeLocation } from "./logs-CSQ_UMWp.mjs";
3
+ import { n as BuiltinPlugin, r as bindingifyBuiltInPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-C20xiVob.mjs";
4
+ import { a as unreachable, i as unimplemented, o as unsupported, r as noop, t as arraify } from "./misc-DpQNcSw4.mjs";
5
+ import { t as parseAst } from "./parse-ast-index-khff6py4.mjs";
4
6
  import { Worker, isMainThread } from "node:worker_threads";
5
7
  import path from "node:path";
8
+ import { styleText } from "node:util";
6
9
  import * as filter from "@rolldown/pluginutils";
7
10
  import fsp from "node:fs/promises";
8
11
  import os from "node:os";
@@ -209,9 +212,9 @@ const { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new Signa
209
212
 
210
213
  //#endregion
211
214
  //#region src/setup.ts
212
- var import_binding$8 = /* @__PURE__ */ __toESM(require_binding(), 1);
215
+ var import_binding$7 = require_binding();
213
216
  if (isMainThread) {
214
- const subscriberGuard = (0, import_binding$8.initTraceSubscriber)();
217
+ const subscriberGuard = (0, import_binding$7.initTraceSubscriber)();
215
218
  onExit(() => {
216
219
  subscriberGuard?.close();
217
220
  });
@@ -219,41 +222,9 @@ if (isMainThread) {
219
222
 
220
223
  //#endregion
221
224
  //#region package.json
222
- var version = "1.0.0-beta.46";
225
+ var version = "1.0.0-beta.48";
223
226
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
224
227
 
225
- //#endregion
226
- //#region src/builtin-plugin/utils.ts
227
- var import_binding$7 = /* @__PURE__ */ __toESM(require_binding(), 1);
228
- var BuiltinPlugin = class {
229
- constructor(name, _options) {
230
- this.name = name;
231
- this._options = _options;
232
- }
233
- };
234
- function makeBuiltinPluginCallable(plugin) {
235
- let callablePlugin = new import_binding$7.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
236
- const wrappedPlugin = plugin;
237
- for (const key in callablePlugin) wrappedPlugin[key] = async function(...args$1) {
238
- try {
239
- return await callablePlugin[key](...args$1);
240
- } catch (e$1) {
241
- if (e$1 instanceof Error && !e$1.stack?.includes("at ")) Error.captureStackTrace(e$1, wrappedPlugin[key]);
242
- return error(logPluginError(e$1, plugin.name, {
243
- hook: key,
244
- id: key === "transform" ? args$1[2] : void 0
245
- }));
246
- }
247
- };
248
- return wrappedPlugin;
249
- }
250
- function bindingifyBuiltInPlugin(plugin) {
251
- return {
252
- __name: plugin.name,
253
- options: plugin._options
254
- };
255
- }
256
-
257
228
  //#endregion
258
229
  //#region src/log/logging.ts
259
230
  const LOG_LEVEL_SILENT = "silent";
@@ -1651,6 +1622,17 @@ function flattenValibotSchema(schema, result = {}, prefix = "") {
1651
1622
  return result;
1652
1623
  }
1653
1624
 
1625
+ //#endregion
1626
+ //#region src/utils/style-text.ts
1627
+ /**
1628
+ * Cross-platform styleText utility that works in both Node.js and browser environments
1629
+ * In Node.js, it uses the native `styleText` from `node:util`
1630
+ * In browser, it provides empty styling functions for compatibility
1631
+ */
1632
+ function styleText$1(...args$1) {
1633
+ return styleText(...args$1);
1634
+ }
1635
+
1654
1636
  //#endregion
1655
1637
  //#region src/utils/validator.ts
1656
1638
  const StringOrRegExpSchema = union([string(), instance(RegExp)]);
@@ -1747,8 +1729,8 @@ const TransformOptionsSchema = object({
1747
1729
  JsxOptionsSchema
1748
1730
  ])),
1749
1731
  target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment")),
1750
- define: optional(record(string(), string())),
1751
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
1732
+ define: pipe(optional(record(string(), string())), description("Define global variables")),
1733
+ inject: pipe(optional(record(string(), union([string(), tuple([string(), string()])]))), description("Inject import statements on demand")),
1752
1734
  dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names"))
1753
1735
  });
1754
1736
  const WatchOptionsSchema = strictObject({
@@ -1873,11 +1855,11 @@ const InputOptionsSchema = strictObject({
1873
1855
  literal("browser"),
1874
1856
  literal("neutral"),
1875
1857
  literal("node")
1876
- ])), description(`Platform for which the code should be generated (node, ${styleText("underline", "browser")}, neutral)`)),
1858
+ ])), description(`Platform for which the code should be generated (node, ${styleText$1("underline", "browser")}, neutral)`)),
1877
1859
  shimMissingExports: pipe(optional(boolean()), description("Create shim variables for missing exports")),
1878
1860
  treeshake: optional(TreeshakingOptionsSchema),
1879
1861
  optimization: optional(OptimizationOptionsSchema),
1880
- logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${styleText("dim", "silent")}, ${styleText(["underline", "gray"], "info")}, debug, ${styleText("yellow", "warn")})`)),
1862
+ logLevel: pipe(optional(LogLevelOptionSchema), description(`Log level (${styleText$1("dim", "silent")}, ${styleText$1(["underline", "gray"], "info")}, debug, ${styleText$1("yellow", "warn")})`)),
1881
1863
  onLog: optional(OnLogSchema),
1882
1864
  onwarn: optional(OnwarnSchema),
1883
1865
  moduleTypes: pipe(optional(ModuleTypesSchema), description("Module types for customized extensions")),
@@ -1902,14 +1884,9 @@ const InputOptionsSchema = strictObject({
1902
1884
  })])),
1903
1885
  nativeMagicString: optional(boolean())
1904
1886
  })),
1905
- define: pipe(optional(record(string(), string())), description("Define global variables")),
1906
- inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
1907
- profilerNames: optional(boolean()),
1908
1887
  transform: optional(TransformOptionsSchema),
1909
1888
  watch: optional(union([WatchOptionsSchema, literal(false)])),
1910
- dropLabels: pipe(optional(array(string())), description("Remove labeled statements with these label names")),
1911
1889
  checks: optional(ChecksOptionsSchema),
1912
- keepNames: pipe(optional(boolean()), description("Keep function/class name")),
1913
1890
  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.")),
1914
1891
  preserveEntrySignatures: pipe(optional(union([
1915
1892
  literal("strict"),
@@ -1922,7 +1899,6 @@ const InputOptionsSchema = strictObject({
1922
1899
  const InputCliOverrideSchema = strictObject({
1923
1900
  input: pipe(optional(array(string())), description("Entry file")),
1924
1901
  external: pipe(optional(array(string())), description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
1925
- inject: pipe(optional(record(string(), string())), description("Inject import statements on demand")),
1926
1902
  treeshake: pipe(optional(boolean()), description("enable treeshaking")),
1927
1903
  makeAbsoluteExternalsRelative: pipe(optional(boolean()), description("Prevent normalization of external imports")),
1928
1904
  preserveEntrySignatures: pipe(optional(literal(false)), description("Avoid facade chunks for entry points")),
@@ -1937,7 +1913,6 @@ const InputCliOptionsSchema = omit(strictObject({
1937
1913
  "onLog",
1938
1914
  "resolve",
1939
1915
  "experimental",
1940
- "profilerNames",
1941
1916
  "watch"
1942
1917
  ]);
1943
1918
  const ModuleFormatSchema = union([
@@ -1997,18 +1972,18 @@ const OutputOptionsSchema = strictObject({
1997
1972
  literal("named"),
1998
1973
  literal("default"),
1999
1974
  literal("none")
2000
- ])), description(`Specify a export mode (${styleText("underline", "auto")}, named, default, none)`)),
1975
+ ])), description(`Specify a export mode (${styleText$1("underline", "auto")}, named, default, none)`)),
2001
1976
  hashCharacters: pipe(optional(union([
2002
1977
  literal("base64"),
2003
1978
  literal("base36"),
2004
1979
  literal("hex")
2005
1980
  ])), description("Use the specified character set for file hashes")),
2006
- format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${styleText("underline", "esm")}, cjs, and iife)`)),
1981
+ format: pipe(optional(ModuleFormatSchema), description(`Output format of the generated bundle (supports ${styleText$1("underline", "esm")}, cjs, and iife)`)),
2007
1982
  sourcemap: pipe(optional(union([
2008
1983
  boolean(),
2009
1984
  literal("inline"),
2010
1985
  literal("hidden")
2011
- ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${styleText("bold", "pass the `-s` on the last argument if you want to generate `.map` file")})`)),
1986
+ ])), description(`Generate sourcemap (\`-s inline\` for inline, or ${styleText$1("bold", "pass the `-s` on the last argument if you want to generate `.map` file")})`)),
2012
1987
  sourcemapBaseUrl: pipe(optional(string()), description("Base URL used to prefix sourcemap paths")),
2013
1988
  sourcemapDebugIds: pipe(optional(boolean()), description("Inject sourcemap debug IDs")),
2014
1989
  sourcemapIgnoreList: optional(union([
@@ -2055,7 +2030,7 @@ const OutputOptionsSchema = strictObject({
2055
2030
  keepNames: pipe(optional(boolean()), description("Keep function and class names after bundling"))
2056
2031
  });
2057
2032
  const getAddonDescription = (placement, wrapper) => {
2058
- return `Code to insert the ${styleText("bold", placement)} of the bundled file (${styleText("bold", wrapper)} the wrapper function)`;
2033
+ return `Code to insert the ${styleText$1("bold", placement)} of the bundled file (${styleText$1("bold", wrapper)} the wrapper function)`;
2059
2034
  };
2060
2035
  const OutputCliOverrideSchema = strictObject({
2061
2036
  assetFileNames: pipe(optional(string()), description("Name pattern for asset files")),
@@ -2139,33 +2114,72 @@ function getCliSchemaInfo() {
2139
2114
  }
2140
2115
 
2141
2116
  //#endregion
2142
- //#region src/decorators/lazy.ts
2117
+ //#region src/types/plain-object-like.ts
2143
2118
  const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
2144
- const LAZY_CACHE_PREFIX = "__cached_";
2145
2119
  /**
2146
- * Legacy decorator that makes a getter lazy-evaluated and cached.
2147
- * Also auto-registers the field for batch prefetching.
2120
+ * Base class for classes that use `@lazyProp` decorated properties.
2121
+ *
2122
+ * **Design Pattern in Rolldown:**
2123
+ * This is a common pattern in Rolldown due to its three-layer architecture:
2124
+ * TypeScript API → NAPI Bindings → Rust Core
2125
+ *
2126
+ * **Why we use getters:**
2127
+ * For performance - to lazily fetch data from Rust bindings only when needed,
2128
+ * rather than eagerly fetching all data during object construction.
2129
+ *
2130
+ * **The problem:**
2131
+ * Getters defined on class prototypes are non-enumerable by default, which breaks:
2132
+ * - Object spread operators ({...obj})
2133
+ * - Object.keys() and similar methods
2134
+ * - Standard JavaScript object semantics
2135
+ *
2136
+ * **The solution:**
2137
+ * This base class automatically converts `@lazyProp` decorated getters into
2138
+ * own enumerable getters on each instance during construction.
2139
+ *
2140
+ * **Result:**
2141
+ * Objects get both lazy-loading performance benefits AND plain JavaScript object behavior.
2148
2142
  *
2149
2143
  * @example
2150
2144
  * ```typescript
2151
- * class MyClass {
2152
- * @lazy
2153
- * get expensiveValue() {
2154
- * return someExpensiveComputation();
2145
+ * class MyClass extends PlainObjectLike {
2146
+ * @lazyProp
2147
+ * get myProp() {
2148
+ * return fetchFromRustBinding();
2155
2149
  * }
2156
2150
  * }
2157
2151
  * ```
2158
2152
  */
2159
- function lazy(target, propertyKey, descriptor) {
2160
- if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Set();
2161
- target.constructor[LAZY_FIELDS_KEY].add(propertyKey);
2162
- const originalGetter = descriptor.get;
2163
- const cacheKey = LAZY_CACHE_PREFIX + propertyKey;
2164
- descriptor.get = function() {
2165
- if (!(cacheKey in this)) this[cacheKey] = originalGetter.call(this);
2166
- return this[cacheKey];
2167
- };
2168
- return descriptor;
2153
+ var PlainObjectLike = class {
2154
+ constructor() {
2155
+ setupLazyProperties(this);
2156
+ }
2157
+ };
2158
+ /**
2159
+ * Set up lazy properties as own getters on an instance.
2160
+ * This is called automatically by the `PlainObjectLike` base class constructor.
2161
+ *
2162
+ * @param instance - The instance to set up lazy properties on
2163
+ * @internal
2164
+ */
2165
+ function setupLazyProperties(instance$1) {
2166
+ const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2167
+ if (!lazyFields) return;
2168
+ for (const [propertyKey, originalGetter] of lazyFields.entries()) {
2169
+ let cachedValue;
2170
+ let hasValue = false;
2171
+ Object.defineProperty(instance$1, propertyKey, {
2172
+ get() {
2173
+ if (!hasValue) {
2174
+ cachedValue = originalGetter.call(this);
2175
+ hasValue = true;
2176
+ }
2177
+ return cachedValue;
2178
+ },
2179
+ enumerable: true,
2180
+ configurable: true
2181
+ });
2182
+ }
2169
2183
  }
2170
2184
  /**
2171
2185
  * Get all lazy field names from a class instance.
@@ -2174,28 +2188,46 @@ function lazy(target, propertyKey, descriptor) {
2174
2188
  * @returns Set of lazy property names
2175
2189
  */
2176
2190
  function getLazyFields(instance$1) {
2177
- return instance$1.constructor[LAZY_FIELDS_KEY] || /* @__PURE__ */ new Set();
2191
+ const lazyFields = instance$1.constructor[LAZY_FIELDS_KEY];
2192
+ return lazyFields ? new Set(lazyFields.keys()) : /* @__PURE__ */ new Set();
2178
2193
  }
2179
2194
 
2180
2195
  //#endregion
2181
- //#region src/decorators/non-enumerable.ts
2196
+ //#region src/decorators/lazy.ts
2182
2197
  /**
2183
- * Decorator that makes a property or method non-enumerable.
2184
- * This hides the property from enumeration (e.g., Object.keys(), for...in loops).
2198
+ * Decorator that marks a getter as lazy-evaluated and cached.
2199
+ *
2200
+ * **What "lazy" means here:**
2201
+ * 1. Data is lazily fetched from Rust bindings only when the property is accessed (not eagerly on construction)
2202
+ * 2. Once fetched, the data is cached for subsequent accesses (performance optimization)
2203
+ * 3. Despite being a getter, it behaves like a plain object property (enumerable, appears in Object.keys())
2204
+ *
2205
+ * **Important**: Properties decorated with `@lazyProp` are defined as own enumerable
2206
+ * properties on each instance (not on the prototype). This ensures they:
2207
+ * - Appear in Object.keys() and Object.getOwnPropertyNames()
2208
+ * - Are included in object spreads ({...obj})
2209
+ * - Are enumerable in for...in loops
2210
+ *
2211
+ * Classes using this decorator must extend `PlainObjectLike` base class.
2185
2212
  *
2186
2213
  * @example
2187
2214
  * ```typescript
2188
- * class MyClass {
2189
- * @nonEnumerable
2190
- * hiddenMethod() {
2191
- * return 'This method will not show up in Object.keys()';
2215
+ * class MyClass extends PlainObjectLike {
2216
+ * @lazyProp
2217
+ * get expensiveValue() {
2218
+ * return someExpensiveComputation();
2192
2219
  * }
2193
2220
  * }
2194
2221
  * ```
2195
2222
  */
2196
- function nonEnumerable(target, propertyKey, descriptor) {
2197
- descriptor.enumerable = false;
2198
- return descriptor;
2223
+ function lazyProp(target, propertyKey, descriptor) {
2224
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Map();
2225
+ const originalGetter = descriptor.get;
2226
+ target.constructor[LAZY_FIELDS_KEY].set(propertyKey, originalGetter);
2227
+ return {
2228
+ enumerable: false,
2229
+ configurable: true
2230
+ };
2199
2231
  }
2200
2232
 
2201
2233
  //#endregion
@@ -2218,9 +2250,10 @@ function __decorate(decorators, target, key, desc) {
2218
2250
 
2219
2251
  //#endregion
2220
2252
  //#region src/types/output-asset-impl.ts
2221
- var OutputAssetImpl = class {
2253
+ var OutputAssetImpl = class extends PlainObjectLike {
2222
2254
  type = "asset";
2223
2255
  constructor(bindingAsset) {
2256
+ super();
2224
2257
  this.bindingAsset = bindingAsset;
2225
2258
  }
2226
2259
  get fileName() {
@@ -2249,13 +2282,12 @@ var OutputAssetImpl = class {
2249
2282
  for (const field of getLazyFields(this)) this[field];
2250
2283
  }
2251
2284
  };
2252
- __decorate([lazy], OutputAssetImpl.prototype, "fileName", null);
2253
- __decorate([lazy], OutputAssetImpl.prototype, "originalFileName", null);
2254
- __decorate([lazy], OutputAssetImpl.prototype, "originalFileNames", null);
2255
- __decorate([lazy], OutputAssetImpl.prototype, "name", null);
2256
- __decorate([lazy], OutputAssetImpl.prototype, "names", null);
2257
- __decorate([lazy], OutputAssetImpl.prototype, "source", null);
2258
- __decorate([nonEnumerable], OutputAssetImpl.prototype, "__rolldown_external_memory_handle__", null);
2285
+ __decorate([lazyProp], OutputAssetImpl.prototype, "fileName", null);
2286
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileName", null);
2287
+ __decorate([lazyProp], OutputAssetImpl.prototype, "originalFileNames", null);
2288
+ __decorate([lazyProp], OutputAssetImpl.prototype, "name", null);
2289
+ __decorate([lazyProp], OutputAssetImpl.prototype, "names", null);
2290
+ __decorate([lazyProp], OutputAssetImpl.prototype, "source", null);
2259
2291
 
2260
2292
  //#endregion
2261
2293
  //#region src/utils/transform-rendered-module.ts
@@ -2324,9 +2356,10 @@ function transformChunkModules(modules) {
2324
2356
 
2325
2357
  //#endregion
2326
2358
  //#region src/types/output-chunk-impl.ts
2327
- var OutputChunkImpl = class {
2359
+ var OutputChunkImpl = class extends PlainObjectLike {
2328
2360
  type = "chunk";
2329
2361
  constructor(bindingChunk) {
2362
+ super();
2330
2363
  this.bindingChunk = bindingChunk;
2331
2364
  }
2332
2365
  get fileName() {
@@ -2380,21 +2413,20 @@ var OutputChunkImpl = class {
2380
2413
  for (const field of getLazyFields(this)) this[field];
2381
2414
  }
2382
2415
  };
2383
- __decorate([lazy], OutputChunkImpl.prototype, "fileName", null);
2384
- __decorate([lazy], OutputChunkImpl.prototype, "name", null);
2385
- __decorate([lazy], OutputChunkImpl.prototype, "exports", null);
2386
- __decorate([lazy], OutputChunkImpl.prototype, "isEntry", null);
2387
- __decorate([lazy], OutputChunkImpl.prototype, "facadeModuleId", null);
2388
- __decorate([lazy], OutputChunkImpl.prototype, "isDynamicEntry", null);
2389
- __decorate([lazy], OutputChunkImpl.prototype, "sourcemapFileName", null);
2390
- __decorate([lazy], OutputChunkImpl.prototype, "preliminaryFileName", null);
2391
- __decorate([lazy], OutputChunkImpl.prototype, "code", null);
2392
- __decorate([lazy], OutputChunkImpl.prototype, "modules", null);
2393
- __decorate([lazy], OutputChunkImpl.prototype, "imports", null);
2394
- __decorate([lazy], OutputChunkImpl.prototype, "dynamicImports", null);
2395
- __decorate([lazy], OutputChunkImpl.prototype, "moduleIds", null);
2396
- __decorate([lazy], OutputChunkImpl.prototype, "map", null);
2397
- __decorate([nonEnumerable], OutputChunkImpl.prototype, "__rolldown_external_memory_handle__", null);
2416
+ __decorate([lazyProp], OutputChunkImpl.prototype, "fileName", null);
2417
+ __decorate([lazyProp], OutputChunkImpl.prototype, "name", null);
2418
+ __decorate([lazyProp], OutputChunkImpl.prototype, "exports", null);
2419
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isEntry", null);
2420
+ __decorate([lazyProp], OutputChunkImpl.prototype, "facadeModuleId", null);
2421
+ __decorate([lazyProp], OutputChunkImpl.prototype, "isDynamicEntry", null);
2422
+ __decorate([lazyProp], OutputChunkImpl.prototype, "sourcemapFileName", null);
2423
+ __decorate([lazyProp], OutputChunkImpl.prototype, "preliminaryFileName", null);
2424
+ __decorate([lazyProp], OutputChunkImpl.prototype, "code", null);
2425
+ __decorate([lazyProp], OutputChunkImpl.prototype, "modules", null);
2426
+ __decorate([lazyProp], OutputChunkImpl.prototype, "imports", null);
2427
+ __decorate([lazyProp], OutputChunkImpl.prototype, "dynamicImports", null);
2428
+ __decorate([lazyProp], OutputChunkImpl.prototype, "moduleIds", null);
2429
+ __decorate([lazyProp], OutputChunkImpl.prototype, "map", null);
2398
2430
 
2399
2431
  //#endregion
2400
2432
  //#region src/types/sourcemap.ts
@@ -2574,8 +2606,9 @@ function collectChangedBundle(changed, bundle) {
2574
2606
 
2575
2607
  //#endregion
2576
2608
  //#region src/types/rolldown-output-impl.ts
2577
- var RolldownOutputImpl = class {
2609
+ var RolldownOutputImpl = class extends PlainObjectLike {
2578
2610
  constructor(bindingOutputs) {
2611
+ super();
2579
2612
  this.bindingOutputs = bindingOutputs;
2580
2613
  }
2581
2614
  get output() {
@@ -2593,8 +2626,7 @@ var RolldownOutputImpl = class {
2593
2626
  return { freed: true };
2594
2627
  }
2595
2628
  };
2596
- __decorate([lazy], RolldownOutputImpl.prototype, "output", null);
2597
- __decorate([nonEnumerable], RolldownOutputImpl.prototype, "__rolldown_external_memory_handle__", null);
2629
+ __decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
2598
2630
 
2599
2631
  //#endregion
2600
2632
  //#region src/utils/error.ts
@@ -2863,7 +2895,7 @@ function bindingifyRenderChunkFilter(filterOption) {
2863
2895
 
2864
2896
  //#endregion
2865
2897
  //#region src/plugin/bindingify-plugin-hook-meta.ts
2866
- var import_binding$6 = /* @__PURE__ */ __toESM(require_binding(), 1);
2898
+ var import_binding$6 = require_binding();
2867
2899
  function bindingifyPluginHookMeta(options) {
2868
2900
  return { order: bindingPluginOrder(options.order) };
2869
2901
  }
@@ -3031,7 +3063,7 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
3031
3063
 
3032
3064
  //#endregion
3033
3065
  //#region src/plugin/bindingify-build-hooks.ts
3034
- var import_binding$5 = /* @__PURE__ */ __toESM(require_binding(), 1);
3066
+ var import_binding$5 = require_binding();
3035
3067
  function bindingifyBuildStart(args$1) {
3036
3068
  const hook = args$1.plugin.buildStart;
3037
3069
  if (!hook) return {};
@@ -3127,11 +3159,15 @@ function bindingifyTransform(args$1) {
3127
3159
  const { handler, meta, options } = normalizeHook(hook);
3128
3160
  return {
3129
3161
  plugin: async (ctx, code, id, meta$1) => {
3162
+ let magicStringInstance, astInstance;
3130
3163
  Object.defineProperties(meta$1, {
3131
3164
  magicString: { get() {
3132
- return new import_binding$5.BindingMagicString(code);
3165
+ if (magicStringInstance) return magicStringInstance;
3166
+ magicStringInstance = new import_binding$5.BindingMagicString(code);
3167
+ return magicStringInstance;
3133
3168
  } },
3134
3169
  ast: { get() {
3170
+ if (astInstance) return astInstance;
3135
3171
  let lang = "js";
3136
3172
  switch (meta$1.moduleType) {
3137
3173
  case "js":
@@ -3142,10 +3178,11 @@ function bindingifyTransform(args$1) {
3142
3178
  break;
3143
3179
  default: break;
3144
3180
  }
3145
- return parseAst(code, {
3181
+ astInstance = parseAst(code, {
3146
3182
  astType: meta$1.moduleType.includes("ts") ? "ts" : "js",
3147
3183
  lang
3148
3184
  });
3185
+ return astInstance;
3149
3186
  } }
3150
3187
  });
3151
3188
  const transformCtx = new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id, code, args$1.onLog, args$1.logLevel, args$1.watchMode);
@@ -3585,9 +3622,10 @@ function wrapHandlers(plugin) {
3585
3622
 
3586
3623
  //#endregion
3587
3624
  //#region src/options/normalized-input-options.ts
3588
- var NormalizedInputOptionsImpl = class {
3625
+ var NormalizedInputOptionsImpl = class extends PlainObjectLike {
3589
3626
  inner;
3590
3627
  constructor(inner, onLog) {
3628
+ super();
3591
3629
  this.onLog = onLog;
3592
3630
  this.inner = inner;
3593
3631
  }
@@ -3607,11 +3645,17 @@ var NormalizedInputOptionsImpl = class {
3607
3645
  return this.inner.context;
3608
3646
  }
3609
3647
  };
3648
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "shimMissingExports", null);
3649
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "input", null);
3650
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "cwd", null);
3651
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "platform", null);
3652
+ __decorate([lazyProp], NormalizedInputOptionsImpl.prototype, "context", null);
3610
3653
 
3611
3654
  //#endregion
3612
3655
  //#region src/options/normalized-output-options.ts
3613
- var NormalizedOutputOptionsImpl = class {
3656
+ var NormalizedOutputOptionsImpl = class extends PlainObjectLike {
3614
3657
  constructor(inner, outputOptions, normalizedOutputPlugins) {
3658
+ super();
3615
3659
  this.inner = inner;
3616
3660
  this.outputOptions = outputOptions;
3617
3661
  this.normalizedOutputPlugins = normalizedOutputPlugins;
@@ -3731,6 +3775,42 @@ var NormalizedOutputOptionsImpl = class {
3731
3775
  return this.inner.minifyInternalExports ?? false;
3732
3776
  }
3733
3777
  };
3778
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "dir", null);
3779
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "entryFileNames", null);
3780
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "chunkFileNames", null);
3781
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "assetFileNames", null);
3782
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "format", null);
3783
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "exports", null);
3784
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemap", null);
3785
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapBaseUrl", null);
3786
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssEntryFileNames", null);
3787
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "cssChunkFileNames", null);
3788
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "shimMissingExports", null);
3789
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "name", null);
3790
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "file", null);
3791
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "inlineDynamicImports", null);
3792
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "externalLiveBindings", null);
3793
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "banner", null);
3794
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "footer", null);
3795
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "intro", null);
3796
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "outro", null);
3797
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "esModule", null);
3798
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "extend", null);
3799
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "globals", null);
3800
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "paths", null);
3801
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "hashCharacters", null);
3802
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapDebugIds", null);
3803
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapIgnoreList", null);
3804
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "sourcemapPathTransform", null);
3805
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minify", null);
3806
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "legalComments", null);
3807
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "polyfillRequire", null);
3808
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "plugins", null);
3809
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModules", null);
3810
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "preserveModulesRoot", null);
3811
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "virtualDirname", null);
3812
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "topLevelVar", null);
3813
+ __decorate([lazyProp], NormalizedOutputOptionsImpl.prototype, "minifyInternalExports", null);
3734
3814
  function normalizeAddon(value) {
3735
3815
  if (typeof value === "function") return value;
3736
3816
  return () => value || "";
@@ -3833,17 +3913,6 @@ var PluginContextData = class {
3833
3913
  }
3834
3914
  };
3835
3915
 
3836
- //#endregion
3837
- //#region src/utils/normalize-string-or-regex.ts
3838
- function normalizedStringOrRegex(pattern) {
3839
- if (!pattern) return;
3840
- if (!isReadonlyArray(pattern)) return [pattern];
3841
- return pattern;
3842
- }
3843
- function isReadonlyArray(input) {
3844
- return Array.isArray(input);
3845
- }
3846
-
3847
3916
  //#endregion
3848
3917
  //#region src/utils/normalize-transform-options.ts
3849
3918
  /**
@@ -3851,26 +3920,11 @@ function isReadonlyArray(input) {
3851
3920
  *
3852
3921
  * Prioritizes values from `transform.define`, `transform.inject`, and `transform.dropLabels` over deprecated top-level options.
3853
3922
  */
3854
- function normalizeTransformOptions(inputOptions, onLog) {
3923
+ function normalizeTransformOptions(inputOptions) {
3855
3924
  const transform = inputOptions.transform;
3856
- let define;
3857
- if (transform?.define) define = Object.entries(transform.define);
3858
- else if (inputOptions.define) {
3859
- onLog(LOG_LEVEL_WARN, logDeprecatedDefine());
3860
- define = Object.entries(inputOptions.define);
3861
- }
3862
- let inject;
3863
- if (transform?.inject) inject = transform.inject;
3864
- else if (inputOptions.inject) {
3865
- onLog(LOG_LEVEL_WARN, logDeprecatedInject());
3866
- inject = inputOptions.inject;
3867
- }
3868
- let dropLabels;
3869
- if (transform?.dropLabels) dropLabels = transform.dropLabels;
3870
- else if (inputOptions.dropLabels) {
3871
- onLog(LOG_LEVEL_WARN, logDeprecatedDropLabels());
3872
- dropLabels = inputOptions.dropLabels;
3873
- }
3925
+ const define = transform?.define ? Object.entries(transform.define) : void 0;
3926
+ const inject = transform?.inject;
3927
+ const dropLabels = transform?.dropLabels;
3874
3928
  let oxcTransformOptions;
3875
3929
  if (transform) {
3876
3930
  const { define: _define, inject: _inject, dropLabels: _dropLabels,...rest } = transform;
@@ -3889,7 +3943,7 @@ function normalizeTransformOptions(inputOptions, onLog) {
3889
3943
 
3890
3944
  //#endregion
3891
3945
  //#region src/utils/bindingify-input-options.ts
3892
- var import_binding$4 = /* @__PURE__ */ __toESM(require_binding(), 1);
3946
+ var import_binding$4 = require_binding();
3893
3947
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3894
3948
  const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3895
3949
  const plugins = rawPlugins.map((plugin) => {
@@ -3897,19 +3951,7 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
3897
3951
  if (plugin instanceof BuiltinPlugin) return bindingifyBuiltInPlugin(plugin);
3898
3952
  return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode);
3899
3953
  });
3900
- const normalizedTransform = normalizeTransformOptions(inputOptions, onLog);
3901
- let profilerNames;
3902
- if (outputOptions.generatedCode?.profilerNames !== void 0) profilerNames = outputOptions.generatedCode.profilerNames;
3903
- else if (inputOptions.profilerNames !== void 0) {
3904
- onLog(LOG_LEVEL_WARN, logDeprecatedProfilerNames());
3905
- profilerNames = inputOptions.profilerNames;
3906
- }
3907
- let keepNames;
3908
- if (outputOptions.keepNames !== void 0) keepNames = outputOptions.keepNames;
3909
- else if (inputOptions.keepNames !== void 0) {
3910
- onLog(LOG_LEVEL_WARN, logDeprecatedKeepNames());
3911
- keepNames = inputOptions.keepNames;
3912
- }
3954
+ const normalizedTransform = normalizeTransformOptions(inputOptions);
3913
3955
  return {
3914
3956
  input: bindingifyInput(inputOptions.input),
3915
3957
  plugins,
@@ -3925,11 +3967,11 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normali
3925
3967
  define: normalizedTransform.define,
3926
3968
  inject: bindingifyInject(normalizedTransform.inject),
3927
3969
  experimental: bindingifyExperimental(inputOptions.experimental),
3928
- profilerNames,
3970
+ profilerNames: outputOptions.generatedCode?.profilerNames,
3929
3971
  transform: normalizedTransform.oxcTransformOptions,
3930
3972
  watch: bindingifyWatch(inputOptions.watch),
3931
3973
  dropLabels: normalizedTransform.dropLabels,
3932
- keepNames,
3974
+ keepNames: outputOptions.keepNames,
3933
3975
  checks: inputOptions.checks,
3934
3976
  deferSyncScanData: () => {
3935
3977
  let ret = [];
@@ -4251,7 +4293,7 @@ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
4251
4293
 
4252
4294
  //#endregion
4253
4295
  //#region src/utils/initialize-parallel-plugins.ts
4254
- var import_binding$3 = /* @__PURE__ */ __toESM(require_binding(), 1);
4296
+ var import_binding$3 = require_binding();
4255
4297
  async function initializeParallelPlugins(plugins) {
4256
4298
  const pluginInfos = [];
4257
4299
  for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
@@ -4342,68 +4384,57 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4342
4384
 
4343
4385
  //#endregion
4344
4386
  //#region src/api/rolldown/rolldown-build.ts
4345
- var import_binding$2 = /* @__PURE__ */ __toESM(require_binding());
4387
+ var import_binding$2 = require_binding();
4346
4388
  Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4347
4389
  var RolldownBuild = class RolldownBuild {
4348
4390
  #inputOptions;
4349
4391
  #bundler;
4350
- #bundlerImpl;
4392
+ #stopWorkers;
4351
4393
  static asyncRuntimeShutdown = false;
4352
4394
  constructor(inputOptions) {
4353
4395
  this.#inputOptions = inputOptions;
4354
4396
  this.#bundler = new import_binding$2.BindingBundler();
4355
4397
  }
4356
4398
  get closed() {
4357
- return this.#bundlerImpl?.impl.closed ?? true;
4358
- }
4359
- async #getBundlerWithStopWorker(outputOptions) {
4360
- if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4361
- const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4362
- if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding$2.startAsyncRuntime)();
4363
- try {
4364
- return this.#bundlerImpl = {
4365
- impl: this.#bundler.createImpl(option.bundlerOptions),
4366
- stopWorkers: option.stopWorkers,
4367
- shutdown: () => {
4368
- (0, import_binding$2.shutdownAsyncRuntime)();
4369
- RolldownBuild.asyncRuntimeShutdown = true;
4370
- }
4371
- };
4372
- } catch (e$1) {
4373
- await option.stopWorkers?.();
4374
- throw e$1;
4375
- }
4376
- }
4377
- async scan() {
4378
- const { impl } = await this.#getBundlerWithStopWorker({});
4379
- unwrapBindingResult(await impl.scan());
4399
+ return this.#bundler.closed;
4380
4400
  }
4381
4401
  async generate(outputOptions = {}) {
4382
- validateOption("output", outputOptions);
4383
- const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4384
- return new RolldownOutputImpl(unwrapBindingResult(await impl.generate()));
4402
+ return this.#build(false, outputOptions);
4385
4403
  }
4386
4404
  async write(outputOptions = {}) {
4387
- validateOption("output", outputOptions);
4388
- const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4389
- return new RolldownOutputImpl(unwrapBindingResult(await impl.write()));
4405
+ return this.#build(true, outputOptions);
4390
4406
  }
4391
4407
  /**
4392
4408
  * Close the build and free resources.
4393
4409
  */
4394
4410
  async close() {
4395
- if (this.#bundlerImpl) {
4396
- await this.#bundlerImpl.stopWorkers?.();
4397
- await this.#bundlerImpl.impl.close();
4398
- this.#bundlerImpl.shutdown();
4399
- this.#bundlerImpl = void 0;
4400
- }
4411
+ await this.#stopWorkers?.();
4412
+ await this.#bundler.close();
4413
+ (0, import_binding$2.shutdownAsyncRuntime)();
4414
+ RolldownBuild.asyncRuntimeShutdown = true;
4415
+ this.#stopWorkers = void 0;
4401
4416
  }
4402
4417
  async [Symbol.asyncDispose]() {
4403
4418
  await this.close();
4404
4419
  }
4405
4420
  get watchFiles() {
4406
- return this.#bundlerImpl?.impl.getWatchFiles() ?? Promise.resolve([]);
4421
+ return Promise.resolve(this.#bundler.getWatchFiles());
4422
+ }
4423
+ async #build(isWrite, outputOptions) {
4424
+ validateOption("output", outputOptions);
4425
+ await this.#stopWorkers?.();
4426
+ const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4427
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding$2.startAsyncRuntime)();
4428
+ try {
4429
+ this.#stopWorkers = option.stopWorkers;
4430
+ let output;
4431
+ if (isWrite) output = await this.#bundler.write(option.bundlerOptions);
4432
+ else output = await this.#bundler.generate(option.bundlerOptions);
4433
+ return new RolldownOutputImpl(unwrapBindingResult(output));
4434
+ } catch (e$1) {
4435
+ await option.stopWorkers?.();
4436
+ throw e$1;
4437
+ }
4407
4438
  }
4408
4439
  };
4409
4440
 
@@ -4505,7 +4536,7 @@ var WatcherEmitter = class {
4505
4536
 
4506
4537
  //#endregion
4507
4538
  //#region src/api/watch/watcher.ts
4508
- var import_binding$1 = /* @__PURE__ */ __toESM(require_binding(), 1);
4539
+ var import_binding$1 = require_binding();
4509
4540
  var Watcher = class {
4510
4541
  closed;
4511
4542
  inner;
@@ -4568,8 +4599,8 @@ function defineConfig(config) {
4568
4599
 
4569
4600
  //#endregion
4570
4601
  //#region src/index.ts
4571
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
4602
+ var import_binding = require_binding();
4572
4603
  const VERSION = version;
4573
4604
 
4574
4605
  //#endregion
4575
- export { version as C, description$1 as S, getOutputCliKeys as _, build as a, BuiltinPlugin as b, createBundlerOptions as c, bindingifyPlugin as d, normalizeBindingResult as f, getInputCliKeys as g, getCliSchemaInfo as h, watch as i, normalizedStringOrRegex as l, bindingifySourcemap$1 as m, import_binding as n, rolldown as o, transformToRollupOutput as p, defineConfig as r, RolldownBuild as s, VERSION as t, PluginContextData as u, validateCliOptions as v, onExit as w, makeBuiltinPluginCallable as x, PluginDriver as y };
4606
+ export { version as C, description$1 as S, getOutputCliKeys as _, build as a, styleText$1 as b, createBundlerOptions as c, normalizeBindingResult as d, unwrapBindingResult as f, getInputCliKeys as g, getCliSchemaInfo as h, watch as i, PluginContextData as l, bindingifySourcemap$1 as m, import_binding as n, rolldown as o, transformToRollupOutput as p, defineConfig as r, RolldownBuild as s, VERSION as t, bindingifyPlugin as u, validateCliOptions as v, onExit as w, PluginDriver as x, validateOption as y };