rolldown 1.0.0-beta.9-commit.ca4e9dd → 1.0.0-rc.1

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 (68) hide show
  1. package/README.md +11 -0
  2. package/bin/cli.mjs +1 -0
  3. package/dist/cli-setup.mjs +17 -0
  4. package/dist/cli.mjs +1085 -1281
  5. package/dist/config.d.mts +2 -4
  6. package/dist/config.mjs +8 -5
  7. package/dist/experimental-index.d.mts +161 -76
  8. package/dist/experimental-index.mjs +227 -61
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +196 -4
  11. package/dist/filter-index.mjs +328 -4
  12. package/dist/get-log-filter.d.mts +7 -0
  13. package/dist/get-log-filter.mjs +48 -0
  14. package/dist/index.d.mts +4 -4
  15. package/dist/index.mjs +56 -5
  16. package/dist/parallel-plugin-worker.mjs +27 -33
  17. package/dist/parallel-plugin.d.mts +7 -8
  18. package/dist/parse-ast-index.d.mts +4 -5
  19. package/dist/parse-ast-index.mjs +2 -2
  20. package/dist/plugins-index.d.mts +30 -0
  21. package/dist/plugins-index.mjs +40 -0
  22. package/dist/shared/binding-B92Lq__Q.d.mts +1687 -0
  23. package/dist/shared/binding-C-UNREnT.mjs +585 -0
  24. package/dist/shared/bindingify-input-options-Cb-01HR1.mjs +2233 -0
  25. package/dist/shared/constructors-D_KFsTQ-.d.mts +28 -0
  26. package/dist/shared/constructors-aZ82R2dj.mjs +61 -0
  27. package/dist/shared/define-config-BVG4QvnP.mjs +7 -0
  28. package/dist/shared/define-config-DO4TBkJV.d.mts +3457 -0
  29. package/dist/shared/{load-config-Hg0usN_9.mjs → load-config-D6cey0o1.mjs} +23 -33
  30. package/dist/shared/logging-wIy4zY9I.d.mts +50 -0
  31. package/dist/shared/logs-NH298mHo.mjs +183 -0
  32. package/dist/shared/{misc-DGAe2XOW.mjs → misc-CCZIsXVO.mjs} +1 -7
  33. package/dist/shared/normalize-string-or-regex-Dq50a7l9.mjs +61 -0
  34. package/dist/shared/parse-ast-index-B6LAhWD8.mjs +99 -0
  35. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-tlfjalEt.mjs} +301 -308
  36. package/dist/shared/rolldown-CIC_OHw3.mjs +42 -0
  37. package/dist/shared/rolldown-build-KB1YaNe-.mjs +2369 -0
  38. package/dist/shared/watch-B2WRkpw2.mjs +379 -0
  39. package/package.json +86 -98
  40. package/dist/cli.cjs +0 -1748
  41. package/dist/config.cjs +0 -12
  42. package/dist/config.d.cts +0 -12
  43. package/dist/experimental-index.cjs +0 -132
  44. package/dist/experimental-index.d.cts +0 -96
  45. package/dist/filter-index.cjs +0 -105
  46. package/dist/filter-index.d.cts +0 -5
  47. package/dist/index.cjs +0 -9
  48. package/dist/index.d.cts +0 -4
  49. package/dist/parallel-plugin-worker.cjs +0 -33
  50. package/dist/parallel-plugin-worker.d.cts +0 -1
  51. package/dist/parallel-plugin.cjs +0 -8
  52. package/dist/parallel-plugin.d.cts +0 -15
  53. package/dist/parse-ast-index.cjs +0 -4
  54. package/dist/parse-ast-index.d.cts +0 -9
  55. package/dist/shared/binding.d-Dz3qQrbl.d.mts +0 -1682
  56. package/dist/shared/binding.d-QXzDcVmm.d.cts +0 -1682
  57. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  58. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  59. package/dist/shared/define-config.d-CUcDq_vm.d.cts +0 -1080
  60. package/dist/shared/define-config.d-qV1PzX_C.d.mts +0 -1080
  61. package/dist/shared/load-config-Cy3vMDpE.cjs +0 -125
  62. package/dist/shared/misc-BKp5iIef.cjs +0 -67
  63. package/dist/shared/parse-ast-index-0m6JgGc9.mjs +0 -655
  64. package/dist/shared/parse-ast-index-Cn_efzjO.cjs +0 -697
  65. package/dist/shared/prompt-uGrwvyp0.mjs +0 -854
  66. package/dist/shared/src-CqsZy-Xs.cjs +0 -4654
  67. package/dist/shared/src-sZov5fTK.mjs +0 -4704
  68. /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
package/dist/config.d.mts CHANGED
@@ -1,12 +1,10 @@
1
- import "./shared/binding.d-Dz3qQrbl.mjs";
2
- import { ConfigExport, defineConfig$1 as defineConfig } from "./shared/define-config.d-qV1PzX_C.mjs";
1
+ import "./shared/binding-B92Lq__Q.mjs";
2
+ import { r as defineConfig, t as ConfigExport } from "./shared/define-config-DO4TBkJV.mjs";
3
3
 
4
4
  //#region src/utils/load-config.d.ts
5
5
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
6
-
7
6
  //#endregion
8
7
  //#region src/config.d.ts
9
8
  declare const VERSION: string;
10
-
11
9
  //#endregion
12
10
  export { VERSION, defineConfig, loadConfig };
package/dist/config.mjs CHANGED
@@ -1,10 +1,13 @@
1
- import { defineConfig, version } from "./shared/src-sZov5fTK.mjs";
2
- import "./shared/parse-ast-index-0m6JgGc9.mjs";
3
- import "./shared/misc-DGAe2XOW.mjs";
4
- import { init_load_config, loadConfig } from "./shared/load-config-Hg0usN_9.mjs";
1
+ import "./shared/binding-C-UNREnT.mjs";
2
+ import "./shared/normalize-string-or-regex-Dq50a7l9.mjs";
3
+ import { w as version } from "./shared/bindingify-input-options-Cb-01HR1.mjs";
4
+ import "./shared/rolldown-build-KB1YaNe-.mjs";
5
+ import "./shared/parse-ast-index-B6LAhWD8.mjs";
6
+ import "./shared/rolldown-CIC_OHw3.mjs";
7
+ import { t as defineConfig } from "./shared/define-config-BVG4QvnP.mjs";
8
+ import { t as loadConfig } from "./shared/load-config-D6cey0o1.mjs";
5
9
 
6
10
  //#region src/config.ts
7
- init_load_config();
8
11
  const VERSION = version;
9
12
 
10
13
  //#endregion
@@ -1,96 +1,181 @@
1
- import { BindingReplacePluginConfig, BindingTransformPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult$1 as TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./shared/binding.d-Dz3qQrbl.mjs";
2
- import { BuiltinPlugin$1 as BuiltinPlugin, InputOptions, RolldownPlugin, assetPlugin$1 as assetPlugin, buildImportAnalysisPlugin$1 as buildImportAnalysisPlugin, defineParallelPlugin, dynamicImportVarsPlugin$1 as dynamicImportVarsPlugin, importGlobPlugin$1 as importGlobPlugin, isolatedDeclarationPlugin$1 as isolatedDeclarationPlugin, jsonPlugin$1 as jsonPlugin, loadFallbackPlugin$1 as loadFallbackPlugin, manifestPlugin$1 as manifestPlugin, moduleFederationPlugin$1 as moduleFederationPlugin, modulePreloadPolyfillPlugin$1 as modulePreloadPolyfillPlugin, reporterPlugin$1 as reporterPlugin, viteResolvePlugin$1 as viteResolvePlugin, wasmFallbackPlugin$1 as wasmFallbackPlugin, wasmHelperPlugin$1 as wasmHelperPlugin, webWorkerPostPlugin$1 as webWorkerPostPlugin } from "./shared/define-config.d-qV1PzX_C.mjs";
1
+ import { A as MinifyResult, B as isolatedDeclaration, D as IsolatedDeclarationsResult, E as IsolatedDeclarationsOptions, F as ResolveResult, G as transform, H as minify, I as ResolverFactory, K as transformSync, L as TransformOptions, M as ParseResult, N as ParserOptions, R as TransformResult, S as BindingViteTransformPluginConfig, U as minifySync, V as isolatedDeclarationSync, W as moduleRunnerTransform, _ as BindingViteManifestPluginConfig, j as NapiResolveOptions, k as MinifyOptions, l as BindingRebuildStrategy, n as BindingBundleState, r as BindingClientHmrUpdate, z as createTokioRuntime } from "./shared/binding-B92Lq__Q.mjs";
2
+ import { M as BuiltinPlugin, Mt as OutputOptions, Ut as freeExternalMemory, Vt as RolldownOutput, c as InputOptions, it as NormalizedOutputOptions, q as defineParallelPlugin } from "./shared/define-config-DO4TBkJV.mjs";
3
+ import { a as viteImportGlobPlugin, c as viteModulePreloadPolyfillPlugin, d as viteResolvePlugin, f as viteWasmFallbackPlugin, i as viteDynamicImportVarsPlugin, l as viteReactRefreshWrapperPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteJsonPlugin, p as viteWasmHelperPlugin, r as viteBuildImportAnalysisPlugin, s as viteLoadFallbackPlugin, u as viteReporterPlugin } from "./shared/constructors-D_KFsTQ-.mjs";
3
4
 
5
+ //#region src/api/dev/dev-options.d.ts
6
+ type DevOnHmrUpdates = (result: Error | {
7
+ updates: BindingClientHmrUpdate[];
8
+ changedFiles: string[];
9
+ }) => void | Promise<void>;
10
+ type DevOnOutput = (result: Error | RolldownOutput) => void | Promise<void>;
11
+ interface DevWatchOptions {
12
+ /**
13
+ * If `true`, files are not written to disk.
14
+ * @default false
15
+ */
16
+ skipWrite?: boolean;
17
+ /**
18
+ * If `true`, use polling instead of native file system events for watching.
19
+ * @default false
20
+ */
21
+ usePolling?: boolean;
22
+ /**
23
+ * Poll interval in milliseconds (only used when usePolling is true).
24
+ * @default 100
25
+ */
26
+ pollInterval?: number;
27
+ /**
28
+ * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
29
+ * @default true
30
+ */
31
+ useDebounce?: boolean;
32
+ /**
33
+ * Debounce duration in milliseconds (only used when useDebounce is true).
34
+ * @default 10
35
+ */
36
+ debounceDuration?: number;
37
+ /**
38
+ * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
39
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
40
+ * @default false
41
+ */
42
+ compareContentsForPolling?: boolean;
43
+ /**
44
+ * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
45
+ * Controls how frequently the debouncer checks for events to process.
46
+ * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
47
+ * @default undefined (auto-select)
48
+ */
49
+ debounceTickRate?: number;
50
+ }
51
+ interface DevOptions {
52
+ onHmrUpdates?: DevOnHmrUpdates;
53
+ onOutput?: DevOnOutput;
54
+ /**
55
+ * Strategy for triggering rebuilds after HMR updates.
56
+ * - `'always'`: Always trigger a rebuild after HMR updates
57
+ * - `'auto'`: Trigger rebuild only if HMR updates contain full reload updates
58
+ * - `'never'`: Never trigger rebuild after HMR updates (default)
59
+ * @default 'auto'
60
+ */
61
+ rebuildStrategy?: "always" | "auto" | "never";
62
+ watch?: DevWatchOptions;
63
+ }
64
+ //#endregion
65
+ //#region src/api/dev/dev-engine.d.ts
66
+ declare class DevEngine {
67
+ #private;
68
+ static create(inputOptions: InputOptions, outputOptions?: OutputOptions, devOptions?: DevOptions): Promise<DevEngine>;
69
+ private constructor();
70
+ run(): Promise<void>;
71
+ ensureCurrentBuildFinish(): Promise<void>;
72
+ getBundleState(): Promise<BindingBundleState>;
73
+ ensureLatestBuildOutput(): Promise<void>;
74
+ invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingClientHmrUpdate[]>;
75
+ registerModules(clientId: string, modules: string[]): Promise<void>;
76
+ removeClient(clientId: string): Promise<void>;
77
+ close(): Promise<void>;
78
+ /**
79
+ * Compile a lazy entry module and return HMR-style patch code.
80
+ *
81
+ * This is called when a dynamically imported module is first requested at runtime.
82
+ * The module was previously stubbed with a proxy, and now we need to compile the
83
+ * actual module and its dependencies.
84
+ *
85
+ * @param moduleId - The absolute file path of the module to compile
86
+ * @param clientId - The client ID requesting this compilation
87
+ * @returns The compiled JavaScript code as a string (HMR patch format)
88
+ */
89
+ compileEntry(moduleId: string, clientId: string): Promise<string>;
90
+ }
91
+ //#endregion
92
+ //#region src/api/dev/index.d.ts
93
+ declare const dev: typeof DevEngine.create;
94
+ //#endregion
4
95
  //#region src/api/experimental.d.ts
5
96
  /**
6
- * This is an experimental API. It's behavior may change in the future.
97
+ * This is an experimental API. Its behavior may change in the future.
98
+ *
99
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
100
+ * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
101
+ *
102
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
103
+ * ```ts
104
+ * import { scan } from 'rolldown/api/experimental';
7
105
  *
8
- * Calling this API will only execute the scan stage of rolldown.
106
+ * const cleanupPromise = await scan(...);
107
+ * await cleanupPromise;
108
+ * // Now all resources have been cleaned up.
109
+ * ```
9
110
  */
111
+ declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;
112
+ //#endregion
113
+ //#region src/utils/parse.d.ts
10
114
  /**
11
- * This is an experimental API. It's behavior may change in the future.
115
+ * Parse asynchronously.
12
116
  *
13
- * Calling this API will only execute the scan stage of rolldown.
117
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
14
118
  */
15
- declare const experimental_scan: (input: InputOptions) => Promise<void>;
16
-
17
- //#endregion
18
- //#region src/utils/compose-js-plugins.d.ts
19
- declare function composeJsPlugins(plugins: RolldownPlugin[]): RolldownPlugin[];
20
-
119
+ declare function parse(filename: string, sourceText: string, options?: ParserOptions | null): Promise<ParseResult>;
120
+ /** Parse synchronously. */
121
+ declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | null): ParseResult;
21
122
  //#endregion
22
123
  //#region src/builtin-plugin/alias-plugin.d.ts
23
- type AliasPluginAlias = {
24
- find: string | RegExp
25
- replacement: string
124
+ type ViteAliasPluginConfig = {
125
+ entries: {
126
+ find: string | RegExp;
127
+ replacement: string;
128
+ }[];
26
129
  };
27
- type AliasPluginConfig = {
28
- entries: AliasPluginAlias[]
130
+ declare function viteAliasPlugin(config: ViteAliasPluginConfig): BuiltinPlugin;
131
+ //#endregion
132
+ //#region src/builtin-plugin/transform-plugin.d.ts
133
+ type TransformPattern = string | RegExp | readonly (RegExp | string)[];
134
+ type TransformPluginConfig = Omit<BindingViteTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude" | "yarnPnp"> & {
135
+ include?: TransformPattern;
136
+ exclude?: TransformPattern;
137
+ jsxRefreshInclude?: TransformPattern;
138
+ jsxRefreshExclude?: TransformPattern;
29
139
  };
30
- declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
31
-
140
+ declare function viteTransformPlugin(config: TransformPluginConfig): BuiltinPlugin;
32
141
  //#endregion
33
- //#region src/builtin-plugin/replace-plugin.d.ts
142
+ //#region src/builtin-plugin/vite-manifest-plugin.d.ts
143
+ type ViteManifestPluginConfig = Omit<BindingViteManifestPluginConfig, "isLegacy"> & {
144
+ isOutputOptionsForLegacyChunks?: (outputOptions: NormalizedOutputOptions) => boolean;
145
+ };
146
+ declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPlugin;
147
+ //#endregion
148
+ //#region src/experimental-index.d.ts
34
149
  /**
35
- * Replaces targeted strings in files while bundling.
150
+ * In-memory file system for browser builds.
36
151
  *
37
- * @example
38
- * // Basic usage
39
- * ```js
40
- * replacePlugin({
41
- * 'process.env.NODE_ENV': JSON.stringify('production'),
42
- * __buildDate__: () => JSON.stringify(new Date()),
43
- * __buildVersion: 15
44
- * })
45
- * ```
46
- * @example
47
- * // With options
48
- * ```js
49
- * replacePlugin({
50
- * 'process.env.NODE_ENV': JSON.stringify('production'),
51
- * __buildDate__: () => JSON.stringify(new Date()),
52
- * __buildVersion: 15
53
- * }, {
54
- * preventAssignment: false,
55
- * })
56
- * ```
57
- */
58
- /**
59
- * Replaces targeted strings in files while bundling.
152
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
153
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
154
+ *
155
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
156
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
157
+ *
158
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
60
159
  *
61
160
  * @example
62
- * // Basic usage
63
- * ```js
64
- * replacePlugin({
65
- * 'process.env.NODE_ENV': JSON.stringify('production'),
66
- * __buildDate__: () => JSON.stringify(new Date()),
67
- * __buildVersion: 15
68
- * })
69
- * ```
70
- * @example
71
- * // With options
72
- * ```js
73
- * replacePlugin({
74
- * 'process.env.NODE_ENV': JSON.stringify('production'),
75
- * __buildDate__: () => JSON.stringify(new Date()),
76
- * __buildVersion: 15
77
- * }, {
78
- * preventAssignment: false,
79
- * })
161
+ * ```typescript
162
+ * import { memfs } from 'rolldown/experimental';
163
+ *
164
+ * // Write files to virtual filesystem before bundling
165
+ * memfs?.volume.fromJSON({
166
+ * '/src/index.js': 'export const foo = 42;',
167
+ * '/package.json': '{"name": "my-app"}'
168
+ * });
169
+ *
170
+ * // Read files from the virtual filesystem
171
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
80
172
  * ```
173
+ *
174
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
81
175
  */
82
- declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
83
-
84
- //#endregion
85
- //#region src/builtin-plugin/transform-plugin.d.ts
86
- type TransformPattern = string | RegExp | readonly (RegExp | string)[];
87
- type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude"> & {
88
- include?: TransformPattern
89
- exclude?: TransformPattern
90
- jsxRefreshInclude?: TransformPattern
91
- jsxRefreshExclude?: TransformPattern
92
- };
93
- declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
94
-
176
+ declare const memfs: {
177
+ fs: any;
178
+ volume: any;
179
+ } | undefined;
95
180
  //#endregion
96
- export { IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions as ResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
181
+ export { type BindingClientHmrUpdate, BindingRebuildStrategy, DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type MinifyOptions, type MinifyResult, type ParseResult, type ParserOptions, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, createTokioRuntime, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, parse, parseSync, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWasmHelperPlugin, viteWebWorkerPostPlugin };
@@ -1,22 +1,188 @@
1
- import { __toESM } from "./shared/chunk--iN_1bjD.mjs";
2
- import { BuiltinPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, init_compose_js_plugins, init_constructors, init_create_bundler, init_normalize_string_or_regex, init_transform_to_rollup_output, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./shared/src-sZov5fTK.mjs";
3
- import { require_binding } from "./shared/parse-ast-index-0m6JgGc9.mjs";
4
- import "./shared/misc-DGAe2XOW.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-C-UNREnT.mjs";
2
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-Dq50a7l9.mjs";
3
+ import { c as transformToRollupOutput, o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-Cb-01HR1.mjs";
4
+ import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build-KB1YaNe-.mjs";
5
+ import { i as parseSync, r as parse } from "./shared/parse-ast-index-B6LAhWD8.mjs";
6
+ import { a as viteImportGlobPlugin, c as viteModulePreloadPolyfillPlugin, d as viteResolvePlugin, f as viteWasmFallbackPlugin, i as viteDynamicImportVarsPlugin, l as viteReactRefreshWrapperPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteJsonPlugin, p as viteWasmHelperPlugin, r as viteBuildImportAnalysisPlugin, s as viteLoadFallbackPlugin, u as viteReporterPlugin } from "./shared/constructors-aZ82R2dj.mjs";
5
7
  import { pathToFileURL } from "node:url";
6
8
 
9
+ //#region src/api/dev/dev-engine.ts
10
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
11
+ var DevEngine = class DevEngine {
12
+ #inner;
13
+ #cachedBuildFinishPromise = null;
14
+ static async create(inputOptions, outputOptions = {}, devOptions = {}) {
15
+ inputOptions = await PluginDriver.callOptionsHook(inputOptions);
16
+ const options = await createBundlerOptions(inputOptions, outputOptions, false);
17
+ const userOnHmrUpdates = devOptions.onHmrUpdates;
18
+ const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {
19
+ const result = normalizeBindingResult(rawResult);
20
+ if (result instanceof Error) {
21
+ userOnHmrUpdates(result);
22
+ return;
23
+ }
24
+ const [updates, changedFiles] = result;
25
+ userOnHmrUpdates({
26
+ updates,
27
+ changedFiles
28
+ });
29
+ } : void 0;
30
+ const userOnOutput = devOptions.onOutput;
31
+ const bindingDevOptions = {
32
+ onHmrUpdates: bindingOnHmrUpdates,
33
+ onOutput: userOnOutput ? function(rawResult) {
34
+ const result = normalizeBindingResult(rawResult);
35
+ if (result instanceof Error) {
36
+ userOnOutput(result);
37
+ return;
38
+ }
39
+ userOnOutput(transformToRollupOutput(result));
40
+ } : void 0,
41
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding.BindingRebuildStrategy.Auto : import_binding.BindingRebuildStrategy.Never : void 0,
42
+ watch: devOptions.watch && {
43
+ skipWrite: devOptions.watch.skipWrite,
44
+ usePolling: devOptions.watch.usePolling,
45
+ pollInterval: devOptions.watch.pollInterval,
46
+ useDebounce: devOptions.watch.useDebounce,
47
+ debounceDuration: devOptions.watch.debounceDuration,
48
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
49
+ debounceTickRate: devOptions.watch.debounceTickRate
50
+ }
51
+ };
52
+ return new DevEngine(new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
53
+ }
54
+ constructor(inner) {
55
+ this.#inner = inner;
56
+ }
57
+ async run() {
58
+ await this.#inner.run();
59
+ }
60
+ async ensureCurrentBuildFinish() {
61
+ if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
62
+ const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
63
+ this.#cachedBuildFinishPromise = null;
64
+ });
65
+ this.#cachedBuildFinishPromise = promise;
66
+ return promise;
67
+ }
68
+ async getBundleState() {
69
+ return this.#inner.getBundleState();
70
+ }
71
+ async ensureLatestBuildOutput() {
72
+ await this.#inner.ensureLatestBuildOutput();
73
+ }
74
+ async invalidate(file, firstInvalidatedBy) {
75
+ return this.#inner.invalidate(file, firstInvalidatedBy);
76
+ }
77
+ async registerModules(clientId, modules) {
78
+ await this.#inner.registerModules(clientId, modules);
79
+ }
80
+ async removeClient(clientId) {
81
+ await this.#inner.removeClient(clientId);
82
+ }
83
+ async close() {
84
+ await this.#inner.close();
85
+ }
86
+ /**
87
+ * Compile a lazy entry module and return HMR-style patch code.
88
+ *
89
+ * This is called when a dynamically imported module is first requested at runtime.
90
+ * The module was previously stubbed with a proxy, and now we need to compile the
91
+ * actual module and its dependencies.
92
+ *
93
+ * @param moduleId - The absolute file path of the module to compile
94
+ * @param clientId - The client ID requesting this compilation
95
+ * @returns The compiled JavaScript code as a string (HMR patch format)
96
+ */
97
+ async compileEntry(moduleId, clientId) {
98
+ return this.#inner.compileEntry(moduleId, clientId);
99
+ }
100
+ };
101
+
102
+ //#endregion
103
+ //#region src/api/dev/index.ts
104
+ const dev = (...args) => DevEngine.create(...args);
105
+
106
+ //#endregion
107
+ //#region src/types/external-memory-handle.ts
108
+ const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
109
+ /**
110
+ * Frees the external memory held by the given handle.
111
+ *
112
+ * This is useful when you want to manually release memory held by Rust objects
113
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
114
+ *
115
+ * @param handle - The object with external memory to free
116
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
117
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
118
+ * when accessing properties after the memory is freed.
119
+ * @returns Status object with `freed` boolean and optional `reason` string.
120
+ * - `{ freed: true }` if memory was successfully freed
121
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { freeExternalMemory } from 'rolldown/experimental';
126
+ *
127
+ * const output = await bundle.generate();
128
+ * const chunk = output.output[0];
129
+ *
130
+ * // Use the chunk...
131
+ *
132
+ * // Manually free the memory (fast, but accessing properties after will throw)
133
+ * const status = freeExternalMemory(chunk); // { freed: true }
134
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
135
+ *
136
+ * // Keep data alive before freeing (slower, but data remains accessible)
137
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
138
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
139
+ *
140
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
141
+ * ```
142
+ */
143
+ function freeExternalMemory(handle, keepDataAlive = false) {
144
+ return handle[symbolForExternalMemoryHandle](keepDataAlive);
145
+ }
146
+
147
+ //#endregion
7
148
  //#region src/api/experimental.ts
8
- init_create_bundler();
9
- init_transform_to_rollup_output();
10
149
  /**
11
- * This is an experimental API. It's behavior may change in the future.
150
+ * This is an experimental API. Its behavior may change in the future.
151
+ *
152
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
153
+ * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
154
+ *
155
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
156
+ * ```ts
157
+ * import { scan } from 'rolldown/api/experimental';
12
158
  *
13
- * Calling this API will only execute the scan stage of rolldown.
159
+ * const cleanupPromise = await scan(...);
160
+ * await cleanupPromise;
161
+ * // Now all resources have been cleaned up.
162
+ * ```
14
163
  */
15
- const experimental_scan = async (input) => {
16
- const { bundler, stopWorkers } = await createBundler(input, {});
17
- const output = await bundler.scan();
18
- handleOutputErrors(output);
19
- await stopWorkers?.();
164
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
165
+ validateOption("input", rawInputOptions);
166
+ validateOption("output", rawOutputOptions);
167
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
168
+ const bundler = new import_binding.BindingBundler();
169
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();
170
+ async function cleanup() {
171
+ await bundler.close();
172
+ await ret.stopWorkers?.();
173
+ (0, import_binding.shutdownAsyncRuntime)();
174
+ RolldownBuild.asyncRuntimeShutdown = true;
175
+ }
176
+ let cleanupPromise = Promise.resolve();
177
+ try {
178
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
179
+ } catch (err) {
180
+ await cleanup();
181
+ throw err;
182
+ } finally {
183
+ cleanupPromise = cleanup();
184
+ }
185
+ return cleanupPromise;
20
186
  };
21
187
 
22
188
  //#endregion
@@ -32,69 +198,69 @@ function defineParallelPlugin(pluginPath) {
32
198
 
33
199
  //#endregion
34
200
  //#region src/builtin-plugin/alias-plugin.ts
35
- init_constructors();
36
- function aliasPlugin(config) {
37
- return new BuiltinPlugin("builtin:alias", config);
38
- }
39
-
40
- //#endregion
41
- //#region src/builtin-plugin/replace-plugin.ts
42
- init_constructors();
43
- /**
44
- * Replaces targeted strings in files while bundling.
45
- *
46
- * @example
47
- * // Basic usage
48
- * ```js
49
- * replacePlugin({
50
- * 'process.env.NODE_ENV': JSON.stringify('production'),
51
- * __buildDate__: () => JSON.stringify(new Date()),
52
- * __buildVersion: 15
53
- * })
54
- * ```
55
- * @example
56
- * // With options
57
- * ```js
58
- * replacePlugin({
59
- * 'process.env.NODE_ENV': JSON.stringify('production'),
60
- * __buildDate__: () => JSON.stringify(new Date()),
61
- * __buildVersion: 15
62
- * }, {
63
- * preventAssignment: false,
64
- * })
65
- * ```
66
- */
67
- function replacePlugin(values = {}, options = {}) {
68
- return new BuiltinPlugin("builtin:replace", {
69
- ...options,
70
- values
71
- });
201
+ function viteAliasPlugin(config) {
202
+ return new BuiltinPlugin("builtin:vite-alias", config);
72
203
  }
73
204
 
74
205
  //#endregion
75
206
  //#region src/builtin-plugin/transform-plugin.ts
76
- init_constructors();
77
- init_normalize_string_or_regex();
78
- function transformPlugin(config) {
79
- if (config) config = {
207
+ function viteTransformPlugin(config) {
208
+ return new BuiltinPlugin("builtin:vite-transform", {
80
209
  ...config,
81
210
  include: normalizedStringOrRegex(config.include),
82
211
  exclude: normalizedStringOrRegex(config.exclude),
83
212
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
84
- jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
85
- };
86
- return new BuiltinPlugin("builtin:transform", config);
213
+ jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),
214
+ yarnPnp: typeof process === "object" && !!process.versions?.pnp
215
+ });
216
+ }
217
+
218
+ //#endregion
219
+ //#region src/builtin-plugin/vite-manifest-plugin.ts
220
+ function viteManifestPlugin(config) {
221
+ return new BuiltinPlugin("builtin:vite-manifest", config);
87
222
  }
88
223
 
89
224
  //#endregion
90
225
  //#region src/experimental-index.ts
91
- var import_binding = __toESM(require_binding());
92
- init_compose_js_plugins();
93
- init_constructors();
226
+ /**
227
+ * In-memory file system for browser builds.
228
+ *
229
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
230
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
231
+ *
232
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
233
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
234
+ *
235
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * import { memfs } from 'rolldown/experimental';
240
+ *
241
+ * // Write files to virtual filesystem before bundling
242
+ * memfs?.volume.fromJSON({
243
+ * '/src/index.js': 'export const foo = 42;',
244
+ * '/package.json': '{"name": "my-app"}'
245
+ * });
246
+ *
247
+ * // Read files from the virtual filesystem
248
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
249
+ * ```
250
+ *
251
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
252
+ */
253
+ const memfs = void 0;
94
254
 
95
255
  //#endregion
256
+ var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;
96
257
  var ResolverFactory = import_binding.ResolverFactory;
258
+ var createTokioRuntime = import_binding.createTokioRuntime;
97
259
  var isolatedDeclaration = import_binding.isolatedDeclaration;
260
+ var isolatedDeclarationSync = import_binding.isolatedDeclarationSync;
261
+ var minify = import_binding.minify;
262
+ var minifySync = import_binding.minifySync;
98
263
  var moduleRunnerTransform = import_binding.moduleRunnerTransform;
99
264
  var transform = import_binding.transform;
100
- export { ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
265
+ var transformSync = import_binding.transformSync;
266
+ export { BindingRebuildStrategy, DevEngine, ResolverFactory, createTokioRuntime, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, parse, parseSync, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWasmHelperPlugin, viteWebWorkerPostPlugin };