@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 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 (73) hide show
  1. package/dist/cli-setup.mjs +16 -0
  2. package/dist/cli.mjs +1084 -1281
  3. package/dist/config.d.mts +1 -3
  4. package/dist/config.mjs +7 -5
  5. package/dist/constructors-B8gqcrFr.js +61 -0
  6. package/dist/experimental-index.browser.mjs +225 -50
  7. package/dist/experimental-index.d.mts +164 -76
  8. package/dist/experimental-index.mjs +220 -60
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +104 -2
  11. package/dist/filter-index.mjs +123 -3
  12. package/dist/get-log-filter.d.mts +7 -0
  13. package/dist/get-log-filter.mjs +48 -0
  14. package/dist/index.browser.mjs +242 -2
  15. package/dist/index.d.mts +4 -3
  16. package/dist/index.mjs +54 -5
  17. package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-CL-PJZI7.js} +70 -137
  18. package/dist/parallel-plugin-worker.mjs +26 -33
  19. package/dist/parallel-plugin.d.mts +7 -7
  20. package/dist/parse-ast-index.d.mts +5 -6
  21. package/dist/parse-ast-index.mjs +1 -2
  22. package/dist/plugins-index.browser.mjs +39 -0
  23. package/dist/plugins-index.d.mts +30 -0
  24. package/dist/plugins-index.mjs +39 -0
  25. package/dist/rolldown-binding.wasi-browser.js +41 -24
  26. package/dist/rolldown-binding.wasi.cjs +62 -24
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/rolldown-build-C4tDS_XC.js +5055 -0
  29. package/dist/shared/bindingify-input-options-Bp2kpiI8.mjs +2231 -0
  30. package/dist/shared/composable-filters-CIxSuZSM.mjs +227 -0
  31. package/dist/shared/constructors-5bt5oBhE.d.mts +28 -0
  32. package/dist/shared/constructors-BTW-c3jX.mjs +61 -0
  33. package/dist/shared/define-config-CDlEOpr1.d.mts +3531 -0
  34. package/dist/shared/define-config-Dlptvz3X.mjs +7 -0
  35. package/dist/shared/{load-config-D7UduHRZ.mjs → load-config-BBZgIUGN.mjs} +23 -33
  36. package/dist/shared/logging-Nvu645a7.d.mts +50 -0
  37. package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-B2CASPcx.mjs} +21 -116
  38. package/dist/shared/normalize-string-or-regex-DIwprzLy.mjs +60 -0
  39. package/dist/shared/parse-ast-index-2ahkCVK6.mjs +98 -0
  40. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-B6NrDD1-.mjs} +301 -308
  41. package/dist/shared/rolldown-C0_W0QdY.mjs +42 -0
  42. package/dist/shared/rolldown-build-DLuUhuNw.mjs +2368 -0
  43. package/dist/shared/types-CIYK49jr.d.mts +1300 -0
  44. package/dist/shared/utils-CqMTwlsR.d.mts +22 -0
  45. package/dist/shared/watch-eIop0yN6.mjs +378 -0
  46. package/package.json +33 -38
  47. package/dist/cli.cjs +0 -1748
  48. package/dist/config.cjs +0 -12
  49. package/dist/config.d.cts +0 -11
  50. package/dist/experimental-index.cjs +0 -129
  51. package/dist/experimental-index.d.cts +0 -96
  52. package/dist/filter-index.cjs +0 -53
  53. package/dist/filter-index.d.cts +0 -3
  54. package/dist/index.cjs +0 -9
  55. package/dist/index.d.cts +0 -3
  56. package/dist/parallel-plugin-worker.cjs +0 -33
  57. package/dist/parallel-plugin-worker.d.cts +0 -1
  58. package/dist/parallel-plugin.cjs +0 -8
  59. package/dist/parallel-plugin.d.cts +0 -14
  60. package/dist/parse-ast-index.cjs +0 -4
  61. package/dist/parse-ast-index.d.cts +0 -9
  62. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  63. package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
  64. package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
  65. package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
  66. package/dist/shared/dist-BMVjvV-v.cjs +0 -249
  67. package/dist/shared/dist-CAn6dxW6.mjs +0 -153
  68. package/dist/shared/load-config-CtKjQ8Mn.cjs +0 -125
  69. package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
  70. package/dist/shared/src-D0nc44MQ.mjs +0 -4691
  71. package/dist/shared/src-s89s870G.cjs +0 -4647
  72. package/dist/src-CeWghjQt.js +0 -4329
  73. /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
@@ -1,22 +1,187 @@
1
- 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-D0nc44MQ.mjs";
2
- import "./shared/dist-CAn6dxW6.mjs";
3
- import "./shared/parse-ast-index-vu376yZ1.mjs";
4
- import { ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi.cjs";
1
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-DIwprzLy.mjs";
2
+ import { c as transformToRollupOutput, o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-Bp2kpiI8.mjs";
3
+ import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build-DLuUhuNw.mjs";
4
+ import { i as parseSync, r as parse } from "./shared/parse-ast-index-2ahkCVK6.mjs";
5
+ 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-BTW-c3jX.mjs";
6
+ import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, createTokioRuntime, isolatedDeclaration, isolatedDeclarationSync, minify, minifySync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime, transform, transformSync } from "./rolldown-binding.wasi.cjs";
5
7
  import { pathToFileURL } from "node:url";
6
8
 
9
+ //#region src/api/dev/dev-engine.ts
10
+ var DevEngine = class DevEngine {
11
+ #inner;
12
+ #cachedBuildFinishPromise = null;
13
+ static async create(inputOptions, outputOptions = {}, devOptions = {}) {
14
+ inputOptions = await PluginDriver.callOptionsHook(inputOptions);
15
+ const options = await createBundlerOptions(inputOptions, outputOptions, false);
16
+ const userOnHmrUpdates = devOptions.onHmrUpdates;
17
+ const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {
18
+ const result = normalizeBindingResult(rawResult);
19
+ if (result instanceof Error) {
20
+ userOnHmrUpdates(result);
21
+ return;
22
+ }
23
+ const [updates, changedFiles] = result;
24
+ userOnHmrUpdates({
25
+ updates,
26
+ changedFiles
27
+ });
28
+ } : void 0;
29
+ const userOnOutput = devOptions.onOutput;
30
+ const bindingDevOptions = {
31
+ onHmrUpdates: bindingOnHmrUpdates,
32
+ onOutput: userOnOutput ? function(rawResult) {
33
+ const result = normalizeBindingResult(rawResult);
34
+ if (result instanceof Error) {
35
+ userOnOutput(result);
36
+ return;
37
+ }
38
+ userOnOutput(transformToRollupOutput(result));
39
+ } : void 0,
40
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? BindingRebuildStrategy$1.Always : devOptions.rebuildStrategy === "auto" ? BindingRebuildStrategy$1.Auto : BindingRebuildStrategy$1.Never : void 0,
41
+ watch: devOptions.watch && {
42
+ skipWrite: devOptions.watch.skipWrite,
43
+ usePolling: devOptions.watch.usePolling,
44
+ pollInterval: devOptions.watch.pollInterval,
45
+ useDebounce: devOptions.watch.useDebounce,
46
+ debounceDuration: devOptions.watch.debounceDuration,
47
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
48
+ debounceTickRate: devOptions.watch.debounceTickRate
49
+ }
50
+ };
51
+ return new DevEngine(new BindingDevEngine(options.bundlerOptions, bindingDevOptions));
52
+ }
53
+ constructor(inner) {
54
+ this.#inner = inner;
55
+ }
56
+ async run() {
57
+ await this.#inner.run();
58
+ }
59
+ async ensureCurrentBuildFinish() {
60
+ if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
61
+ const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
62
+ this.#cachedBuildFinishPromise = null;
63
+ });
64
+ this.#cachedBuildFinishPromise = promise;
65
+ return promise;
66
+ }
67
+ async getBundleState() {
68
+ return this.#inner.getBundleState();
69
+ }
70
+ async ensureLatestBuildOutput() {
71
+ await this.#inner.ensureLatestBuildOutput();
72
+ }
73
+ async invalidate(file, firstInvalidatedBy) {
74
+ return this.#inner.invalidate(file, firstInvalidatedBy);
75
+ }
76
+ async registerModules(clientId, modules) {
77
+ await this.#inner.registerModules(clientId, modules);
78
+ }
79
+ async removeClient(clientId) {
80
+ await this.#inner.removeClient(clientId);
81
+ }
82
+ async close() {
83
+ await this.#inner.close();
84
+ }
85
+ /**
86
+ * Compile a lazy entry module and return HMR-style patch code.
87
+ *
88
+ * This is called when a dynamically imported module is first requested at runtime.
89
+ * The module was previously stubbed with a proxy, and now we need to compile the
90
+ * actual module and its dependencies.
91
+ *
92
+ * @param moduleId - The absolute file path of the module to compile
93
+ * @param clientId - The client ID requesting this compilation
94
+ * @returns The compiled JavaScript code as a string (HMR patch format)
95
+ */
96
+ async compileEntry(moduleId, clientId) {
97
+ return this.#inner.compileEntry(moduleId, clientId);
98
+ }
99
+ };
100
+
101
+ //#endregion
102
+ //#region src/api/dev/index.ts
103
+ const dev = (...args) => DevEngine.create(...args);
104
+
105
+ //#endregion
106
+ //#region src/types/external-memory-handle.ts
107
+ const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
108
+ /**
109
+ * Frees the external memory held by the given handle.
110
+ *
111
+ * This is useful when you want to manually release memory held by Rust objects
112
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
113
+ *
114
+ * @param handle - The object with external memory to free
115
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
116
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
117
+ * when accessing properties after the memory is freed.
118
+ * @returns Status object with `freed` boolean and optional `reason` string.
119
+ * - `{ freed: true }` if memory was successfully freed
120
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { freeExternalMemory } from 'rolldown/experimental';
125
+ *
126
+ * const output = await bundle.generate();
127
+ * const chunk = output.output[0];
128
+ *
129
+ * // Use the chunk...
130
+ *
131
+ * // Manually free the memory (fast, but accessing properties after will throw)
132
+ * const status = freeExternalMemory(chunk); // { freed: true }
133
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
134
+ *
135
+ * // Keep data alive before freeing (slower, but data remains accessible)
136
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
137
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
138
+ *
139
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
140
+ * ```
141
+ */
142
+ function freeExternalMemory(handle, keepDataAlive = false) {
143
+ return handle[symbolForExternalMemoryHandle](keepDataAlive);
144
+ }
145
+
146
+ //#endregion
7
147
  //#region src/api/experimental.ts
8
- init_create_bundler();
9
- init_transform_to_rollup_output();
10
148
  /**
11
- * This is an experimental API. It's behavior may change in the future.
149
+ * This is an experimental API. Its behavior may change in the future.
150
+ *
151
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
152
+ * - `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.
153
+ *
154
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
155
+ * ```ts
156
+ * import { scan } from 'rolldown/api/experimental';
12
157
  *
13
- * Calling this API will only execute the scan stage of rolldown.
158
+ * const cleanupPromise = await scan(...);
159
+ * await cleanupPromise;
160
+ * // Now all resources have been cleaned up.
161
+ * ```
14
162
  */
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?.();
163
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
164
+ validateOption("input", rawInputOptions);
165
+ validateOption("output", rawOutputOptions);
166
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
167
+ const bundler = new BindingBundler();
168
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
169
+ async function cleanup() {
170
+ await bundler.close();
171
+ await ret.stopWorkers?.();
172
+ shutdownAsyncRuntime();
173
+ RolldownBuild.asyncRuntimeShutdown = true;
174
+ }
175
+ let cleanupPromise = Promise.resolve();
176
+ try {
177
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
178
+ } catch (err) {
179
+ await cleanup();
180
+ throw err;
181
+ } finally {
182
+ cleanupPromise = cleanup();
183
+ }
184
+ return cleanupPromise;
20
185
  };
21
186
 
22
187
  //#endregion
@@ -32,64 +197,59 @@ function defineParallelPlugin(pluginPath) {
32
197
 
33
198
  //#endregion
34
199
  //#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
- });
200
+ function viteAliasPlugin(config) {
201
+ return new BuiltinPlugin("builtin:vite-alias", config);
72
202
  }
73
203
 
74
204
  //#endregion
75
205
  //#region src/builtin-plugin/transform-plugin.ts
76
- init_constructors();
77
- init_normalize_string_or_regex();
78
- function transformPlugin(config) {
79
- if (config) config = {
206
+ function viteTransformPlugin(config) {
207
+ return new BuiltinPlugin("builtin:vite-transform", {
80
208
  ...config,
81
209
  include: normalizedStringOrRegex(config.include),
82
210
  exclude: normalizedStringOrRegex(config.exclude),
83
211
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
84
- jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
85
- };
86
- return new BuiltinPlugin("builtin:transform", config);
212
+ jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),
213
+ yarnPnp: typeof process === "object" && !!process.versions?.pnp
214
+ });
215
+ }
216
+
217
+ //#endregion
218
+ //#region src/builtin-plugin/vite-manifest-plugin.ts
219
+ function viteManifestPlugin(config) {
220
+ return new BuiltinPlugin("builtin:vite-manifest", config);
87
221
  }
88
222
 
89
223
  //#endregion
90
224
  //#region src/experimental-index.ts
91
- init_compose_js_plugins();
92
- init_constructors();
225
+ /**
226
+ * In-memory file system for browser builds.
227
+ *
228
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
229
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
230
+ *
231
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
232
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
233
+ *
234
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * import { memfs } from 'rolldown/experimental';
239
+ *
240
+ * // Write files to virtual filesystem before bundling
241
+ * memfs?.volume.fromJSON({
242
+ * '/src/index.js': 'export const foo = 42;',
243
+ * '/package.json': '{"name": "my-app"}'
244
+ * });
245
+ *
246
+ * // Read files from the virtual filesystem
247
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
248
+ * ```
249
+ *
250
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
251
+ */
252
+ const memfs = void 0;
93
253
 
94
254
  //#endregion
95
- 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 };
255
+ 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 };
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @typedef {{ type: 'hmr:module-registered', modules: string[] }} DevRuntimeMessage
3
+ * @typedef {{ send(message: DevRuntimeMessage): void }} Messenger
4
+ */
5
+ export class DevRuntime {
6
+ /**
7
+ * @param {Messenger} messenger
8
+ * @param {string} clientId
9
+ */
10
+ constructor(messenger: Messenger, clientId: string);
11
+ /**
12
+ * Client ID generated at runtime initialization, used for lazy compilation requests.
13
+ * @type {string}
14
+ */
15
+ clientId: string;
16
+ messenger: Messenger;
17
+ /**
18
+ * @type {Record<string, Module>}
19
+ */
20
+ modules: Record<string, Module>;
21
+ /**
22
+ * @param {string} _moduleId
23
+ */
24
+ createModuleHotContext(_moduleId: string): void;
25
+ /**
26
+ * @param {[string, string][]} _boundaries
27
+ */
28
+ applyUpdates(_boundaries: [string, string][]): void;
29
+ /**
30
+ * @param {string} id
31
+ * @param {{ exports: any }} exportsHolder
32
+ */
33
+ registerModule(id: string, exportsHolder: {
34
+ exports: any;
35
+ }): void;
36
+ /**
37
+ * @param {string} id
38
+ */
39
+ loadExports(id: string): any;
40
+ /**
41
+ * __esmMin
42
+ *
43
+ * @type {<T>(fn: any, res: T) => () => T}
44
+ * @internal
45
+ */
46
+ createEsmInitializer: <T>(fn: any, res: T) => () => T;
47
+ /**
48
+ * __commonJSMin
49
+ *
50
+ * @type {<T extends { exports: any }>(cb: any, mod: { exports: any }) => () => T}
51
+ * @internal
52
+ */
53
+ createCjsInitializer: <T extends {
54
+ exports: any;
55
+ }>(cb: any, mod: {
56
+ exports: any;
57
+ }) => () => T;
58
+ /** @internal */
59
+ __toESM: any;
60
+ /** @internal */
61
+ __toCommonJS: any;
62
+ /** @internal */
63
+ __exportAll: any;
64
+ /**
65
+ * @param {boolean} [isNodeMode]
66
+ * @returns {(mod: any) => any}
67
+ * @internal
68
+ */
69
+ __toDynamicImportESM: (isNodeMode?: boolean) => (mod: any) => any;
70
+ /** @internal */
71
+ __reExport: any;
72
+ sendModuleRegisteredMessage: (module: string) => void;
73
+ }
74
+ export type DevRuntimeMessage = {
75
+ type: "hmr:module-registered";
76
+ modules: string[];
77
+ };
78
+ export type Messenger = {
79
+ send(message: DevRuntimeMessage): void;
80
+ };
81
+ declare class Module {
82
+ /**
83
+ * @param {string} id
84
+ */
85
+ constructor(id: string);
86
+ /**
87
+ * @type {{ exports: any }}
88
+ */
89
+ exportsHolder: {
90
+ exports: any;
91
+ };
92
+ /**
93
+ * @type {string}
94
+ */
95
+ id: string;
96
+ get exports(): any;
97
+ }
98
+ export {};
@@ -1,3 +1,105 @@
1
- import { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter } from "./shared/define-config.d-Dm9iNdt9.mjs";
1
+ import { B as id, F as TopLevelFilterExpression, G as moduleType, H as include, I as and, J as queries, K as not, L as code, M as FilterExpression, N as FilterExpressionKind, P as QueryFilterObject, R as exclude, U as interpreter, V as importerId, W as interpreterImpl, Y as query, j as withFilter, q as or, z as exprInterpreter } from "./shared/define-config-CDlEOpr1.mjs";
2
2
 
3
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
3
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.d.ts
4
+ /**
5
+ * Filters out Vite plugins that have `apply: 'serve'` set.
6
+ *
7
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
8
+ * are intended only for Vite's dev server and should be excluded from the build process.
9
+ *
10
+ * @param plugins - Array of plugins (can include nested arrays)
11
+ * @returns Filtered array with serve-only plugins removed
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { defineConfig } from 'rolldown';
16
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
17
+ * import viteReact from '@vitejs/plugin-react';
18
+ *
19
+ * export default defineConfig({
20
+ * plugins: filterVitePlugins([
21
+ * viteReact(),
22
+ * {
23
+ * name: 'dev-only',
24
+ * apply: 'serve', // This will be filtered out
25
+ * // ...
26
+ * }
27
+ * ])
28
+ * });
29
+ * ```
30
+ */
31
+ declare function filterVitePlugins<T = any>(plugins: T | T[] | null | undefined | false): T[];
32
+ //#endregion
33
+ //#region ../pluginutils/dist/filter/simple-filters.d.ts
34
+ /**
35
+ * Constructs a RegExp that matches the exact string specified.
36
+ *
37
+ * This is useful for plugin hook filters.
38
+ *
39
+ * @param str the string to match.
40
+ * @param flags flags for the RegExp.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { exactRegex } from '@rolldown/pluginutils';
45
+ * const plugin = {
46
+ * name: 'plugin',
47
+ * resolveId: {
48
+ * filter: { id: exactRegex('foo') },
49
+ * handler(id) {} // will only be called for `foo`
50
+ * }
51
+ * }
52
+ * ```
53
+ */
54
+ declare function exactRegex(str: string, flags?: string): RegExp;
55
+ /**
56
+ * Constructs a RegExp that matches a value that has the specified prefix.
57
+ *
58
+ * This is useful for plugin hook filters.
59
+ *
60
+ * @param str the string to match.
61
+ * @param flags flags for the RegExp.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { prefixRegex } from '@rolldown/pluginutils';
66
+ * const plugin = {
67
+ * name: 'plugin',
68
+ * resolveId: {
69
+ * filter: { id: prefixRegex('foo') },
70
+ * handler(id) {} // will only be called for IDs starting with `foo`
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ declare function prefixRegex(str: string, flags?: string): RegExp;
76
+ type WidenString<T> = T extends string ? string : T;
77
+ /**
78
+ * Converts a id filter to match with an id with a query.
79
+ *
80
+ * @param input the id filters to convert.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { makeIdFiltersToMatchWithQuery } from '@rolldown/pluginutils';
85
+ * const plugin = {
86
+ * name: 'plugin',
87
+ * transform: {
88
+ * filter: { id: makeIdFiltersToMatchWithQuery(['**' + '/*.js', /\.ts$/]) },
89
+ * // The handler will be called for IDs like:
90
+ * // - foo.js
91
+ * // - foo.js?foo
92
+ * // - foo.txt?foo.js
93
+ * // - foo.ts
94
+ * // - foo.ts?foo
95
+ * // - foo.txt?foo.ts
96
+ * handler(code, id) {}
97
+ * }
98
+ * }
99
+ * ```
100
+ */
101
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: T): WidenString<T>;
102
+ declare function makeIdFiltersToMatchWithQuery<T extends string | RegExp>(input: readonly T[]): WidenString<T>[];
103
+ declare function makeIdFiltersToMatchWithQuery(input: string | RegExp | readonly (string | RegExp)[]): string | RegExp | (string | RegExp)[];
104
+ //#endregion
105
+ export { FilterExpression, FilterExpressionKind, QueryFilterObject, TopLevelFilterExpression, and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
@@ -1,7 +1,127 @@
1
- import { and$1 as and, arraify, code$1 as code, exclude$1 as exclude, id$1 as id, include$1 as include, init_misc, isPromiseLike, moduleType$1 as moduleType, not$1 as not, or$1 as or, queries$1 as queries, query$1 as query } from "./shared/dist-CAn6dxW6.mjs";
1
+ import { a as id, c as interpreter, d as not, f as or, g as isPromiseLike, h as arraify, i as exprInterpreter, l as interpreterImpl, m as query, n as code, o as importerId, p as queries, r as exclude, s as include, t as and, u as moduleType } from "./shared/composable-filters-CIxSuZSM.mjs";
2
2
 
3
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.js
4
+ /**
5
+ * Filters out Vite plugins that have `apply: 'serve'` set.
6
+ *
7
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
8
+ * are intended only for Vite's dev server and should be excluded from the build process.
9
+ *
10
+ * @param plugins - Array of plugins (can include nested arrays)
11
+ * @returns Filtered array with serve-only plugins removed
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { defineConfig } from 'rolldown';
16
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
17
+ * import viteReact from '@vitejs/plugin-react';
18
+ *
19
+ * export default defineConfig({
20
+ * plugins: filterVitePlugins([
21
+ * viteReact(),
22
+ * {
23
+ * name: 'dev-only',
24
+ * apply: 'serve', // This will be filtered out
25
+ * // ...
26
+ * }
27
+ * ])
28
+ * });
29
+ * ```
30
+ */
31
+ function filterVitePlugins(plugins) {
32
+ if (!plugins) return [];
33
+ const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
34
+ const result = [];
35
+ for (const plugin of pluginArray) {
36
+ if (!plugin) continue;
37
+ if (Array.isArray(plugin)) {
38
+ result.push(...filterVitePlugins(plugin));
39
+ continue;
40
+ }
41
+ const pluginWithApply = plugin;
42
+ if ("apply" in pluginWithApply) {
43
+ const applyValue = pluginWithApply.apply;
44
+ if (typeof applyValue === "function") try {
45
+ if (applyValue({}, {
46
+ command: "build",
47
+ mode: "production"
48
+ })) result.push(plugin);
49
+ } catch {
50
+ result.push(plugin);
51
+ }
52
+ else if (applyValue === "serve") continue;
53
+ else result.push(plugin);
54
+ } else result.push(plugin);
55
+ }
56
+ return result;
57
+ }
58
+
59
+ //#endregion
60
+ //#region ../pluginutils/dist/filter/simple-filters.js
61
+ /**
62
+ * Constructs a RegExp that matches the exact string specified.
63
+ *
64
+ * This is useful for plugin hook filters.
65
+ *
66
+ * @param str the string to match.
67
+ * @param flags flags for the RegExp.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { exactRegex } from '@rolldown/pluginutils';
72
+ * const plugin = {
73
+ * name: 'plugin',
74
+ * resolveId: {
75
+ * filter: { id: exactRegex('foo') },
76
+ * handler(id) {} // will only be called for `foo`
77
+ * }
78
+ * }
79
+ * ```
80
+ */
81
+ function exactRegex(str, flags) {
82
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
83
+ }
84
+ /**
85
+ * Constructs a RegExp that matches a value that has the specified prefix.
86
+ *
87
+ * This is useful for plugin hook filters.
88
+ *
89
+ * @param str the string to match.
90
+ * @param flags flags for the RegExp.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { prefixRegex } from '@rolldown/pluginutils';
95
+ * const plugin = {
96
+ * name: 'plugin',
97
+ * resolveId: {
98
+ * filter: { id: prefixRegex('foo') },
99
+ * handler(id) {} // will only be called for IDs starting with `foo`
100
+ * }
101
+ * }
102
+ * ```
103
+ */
104
+ function prefixRegex(str, flags) {
105
+ return new RegExp(`^${escapeRegex(str)}`, flags);
106
+ }
107
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
108
+ function escapeRegex(str) {
109
+ return str.replace(escapeRegexRE, "\\$&");
110
+ }
111
+ function makeIdFiltersToMatchWithQuery(input) {
112
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
113
+ return input.map((i) => makeIdFilterToMatchWithQuery(i));
114
+ }
115
+ function makeIdFilterToMatchWithQuery(input) {
116
+ if (typeof input === "string") return `${input}{?*,}`;
117
+ return makeRegexIdFilterToMatchWithQuery(input);
118
+ }
119
+ function makeRegexIdFilterToMatchWithQuery(input) {
120
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
121
+ }
122
+
123
+ //#endregion
3
124
  //#region src/plugin/with-filter.ts
4
- init_misc();
5
125
  function withFilterImpl(pluginOption, filterObjectList) {
6
126
  if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
7
127
  if (pluginOption == false || pluginOption == null) return pluginOption;
@@ -41,4 +161,4 @@ function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
41
161
  }
42
162
 
43
163
  //#endregion
44
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
164
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
@@ -0,0 +1,7 @@
1
+ import { a as RolldownLog } from "./shared/logging-Nvu645a7.mjs";
2
+
3
+ //#region src/get-log-filter.d.ts
4
+ type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
5
+ declare const getLogFilter: GetLogFilter;
6
+ //#endregion
7
+ export { GetLogFilter, type RolldownLog, type RolldownLog as RollupLog, getLogFilter as default };