rolldown 1.0.0-beta.55 → 1.0.0-beta.57

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 (32) hide show
  1. package/README.md +11 -0
  2. package/dist/cli-setup.mjs +1 -1
  3. package/dist/cli.mjs +8 -8
  4. package/dist/config.d.mts +2 -2
  5. package/dist/config.mjs +7 -7
  6. package/dist/experimental-index.d.mts +30 -3
  7. package/dist/experimental-index.mjs +50 -22
  8. package/dist/experimental-runtime-types.d.ts +1 -1
  9. package/dist/filter-index.d.mts +4 -4
  10. package/dist/filter-index.mjs +327 -2
  11. package/dist/index.d.mts +2 -2
  12. package/dist/index.mjs +7 -7
  13. package/dist/parallel-plugin-worker.mjs +4 -4
  14. package/dist/parallel-plugin.d.mts +2 -2
  15. package/dist/parse-ast-index.d.mts +1 -1
  16. package/dist/parse-ast-index.mjs +2 -2
  17. package/dist/plugins-index.d.mts +3 -3
  18. package/dist/plugins-index.mjs +3 -3
  19. package/dist/shared/{binding-r9j8jqRV.d.mts → binding-CDyF6W3D.d.mts} +13 -10
  20. package/dist/shared/{binding-DMnPPQ90.mjs → binding-Cuiiq-jL.mjs} +26 -26
  21. package/dist/shared/{bindingify-input-options-A-rLIOKA.mjs → bindingify-input-options-B8B4dvr-.mjs} +34 -6
  22. package/dist/shared/{constructors-DO8UjlE5.d.mts → constructors-BnPlw43Q.d.mts} +2 -2
  23. package/dist/shared/{constructors-BGI2r6Tk.mjs → constructors-CxTKGwaB.mjs} +1 -1
  24. package/dist/shared/{define-config-MdVaFcie.d.mts → define-config-kYHtCO-M.d.mts} +10 -4
  25. package/dist/shared/{load-config-DnirbDRj.mjs → load-config-BvbZUaFt.mjs} +1 -1
  26. package/dist/shared/{logs-sGci9sux.mjs → logs-Up1RAnkl.mjs} +4 -2
  27. package/dist/shared/{normalize-string-or-regex-B4d0IHth.mjs → normalize-string-or-regex-0t36Z7KW.mjs} +3 -3
  28. package/dist/shared/{parse-ast-index-CoZSRGeP.mjs → parse-ast-index-Bcjhsr8U.mjs} +11 -8
  29. package/dist/shared/{rolldown-BTFK71hw.mjs → rolldown-CF29fS6Z.mjs} +1 -1
  30. package/dist/shared/{rolldown-build-CNW2eye_.mjs → rolldown-build--qygLwCL.mjs} +8 -7
  31. package/dist/shared/{watch-CKam-d6K.mjs → watch-CyvuFK7g.mjs} +5 -5
  32. package/package.json +18 -18
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Rolldown
2
+
3
+ > Fast Rust-based bundler for JavaScript with Rollup-compatible API
4
+
5
+ - ⚡️ Lightning Fast Performance
6
+ - 🔌 Rollup-Compatible APIs
7
+ - ⏩ esbuild Feature Parity
8
+
9
+ Rolldown is primarily designed to serve as the underlying bundler in [Vite](https://vite.dev/), with the goal to replace esbuild and Rollup with one unified build tool. Although designed for Vite, Rolldown is also fully capable of being used as a standalone, general-purpose bundler. It can serve as a drop-in replacement for Rollup in most cases, and can also be used as an esbuild alternative when better chunking control is needed.
10
+
11
+ [Read the Docs to Learn More](https://rolldown.rs).
@@ -1,4 +1,4 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DMnPPQ90.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-Cuiiq-jL.mjs";
2
2
 
3
3
  //#region src/cli/setup-index.ts
4
4
  var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
package/dist/cli.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import "./shared/binding-DMnPPQ90.mjs";
2
- import { n as onExit, t as watch } from "./shared/watch-CKam-d6K.mjs";
1
+ import "./shared/binding-Cuiiq-jL.mjs";
2
+ import { n as onExit, t as watch } from "./shared/watch-CyvuFK7g.mjs";
3
3
  import { t as arraify } from "./shared/misc-DpjTMcQQ.mjs";
4
- import { b as description, x as version } from "./shared/normalize-string-or-regex-B4d0IHth.mjs";
5
- import { a as getOutputCliKeys, c as styleText$1, i as getInputCliKeys, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/rolldown-build-CNW2eye_.mjs";
6
- import "./shared/bindingify-input-options-A-rLIOKA.mjs";
7
- import "./shared/parse-ast-index-CoZSRGeP.mjs";
8
- import { t as rolldown } from "./shared/rolldown-BTFK71hw.mjs";
9
- import { t as loadConfig } from "./shared/load-config-DnirbDRj.mjs";
4
+ import { b as description, x as version } from "./shared/normalize-string-or-regex-0t36Z7KW.mjs";
5
+ import { a as getOutputCliKeys, c as styleText$1, i as getInputCliKeys, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/rolldown-build--qygLwCL.mjs";
6
+ import "./shared/bindingify-input-options-B8B4dvr-.mjs";
7
+ import "./shared/parse-ast-index-Bcjhsr8U.mjs";
8
+ import { t as rolldown } from "./shared/rolldown-CF29fS6Z.mjs";
9
+ import { t as loadConfig } from "./shared/load-config-BvbZUaFt.mjs";
10
10
  import path, { sep } from "node:path";
11
11
  import { formatWithOptions, parseArgs } from "node:util";
12
12
  import process$1 from "node:process";
package/dist/config.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import "./shared/binding-r9j8jqRV.mjs";
2
- import { n as ConfigExport, t as defineConfig } from "./shared/define-config-MdVaFcie.mjs";
1
+ import "./shared/binding-CDyF6W3D.mjs";
2
+ import { n as ConfigExport, t as defineConfig } from "./shared/define-config-kYHtCO-M.mjs";
3
3
 
4
4
  //#region src/utils/load-config.d.ts
5
5
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
package/dist/config.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import "./shared/binding-DMnPPQ90.mjs";
2
- import { x as version } from "./shared/normalize-string-or-regex-B4d0IHth.mjs";
3
- import "./shared/rolldown-build-CNW2eye_.mjs";
4
- import "./shared/bindingify-input-options-A-rLIOKA.mjs";
5
- import "./shared/parse-ast-index-CoZSRGeP.mjs";
6
- import "./shared/rolldown-BTFK71hw.mjs";
1
+ import "./shared/binding-Cuiiq-jL.mjs";
2
+ import { x as version } from "./shared/normalize-string-or-regex-0t36Z7KW.mjs";
3
+ import "./shared/rolldown-build--qygLwCL.mjs";
4
+ import "./shared/bindingify-input-options-B8B4dvr-.mjs";
5
+ import "./shared/parse-ast-index-Bcjhsr8U.mjs";
6
+ import "./shared/rolldown-CF29fS6Z.mjs";
7
7
  import { t as defineConfig } from "./shared/define-config-BF4P-Pum.mjs";
8
- import { t as loadConfig } from "./shared/load-config-DnirbDRj.mjs";
8
+ import { t as loadConfig } from "./shared/load-config-BvbZUaFt.mjs";
9
9
 
10
10
  //#region src/config.ts
11
11
  const VERSION = version;
@@ -1,6 +1,6 @@
1
- import { $ as transformSync, B as ParserOptions, C as BindingViteManifestPluginConfig, G as TransformResult, H as ResolveResult, I as MinifyOptions, J as isolatedDeclarationSync, K as createTokioRuntime, L as MinifyResult, N as IsolatedDeclarationsOptions, O as BindingViteTransformPluginConfig, P as IsolatedDeclarationsResult, Q as transform, R as NapiResolveOptions, U as ResolverFactory, W as TransformOptions, X as minifySync, Y as minify, Z as moduleRunnerTransform, _ as BindingViteCssPostPluginConfig, b as BindingViteHtmlPluginConfig, c as BindingRebuildStrategy, f as BindingUrlResolver, g as BindingViteCssPluginConfig, m as BindingViteAssetPluginConfig, n as BindingBundleState, q as isolatedDeclaration, r as BindingClientHmrUpdate, z as ParseResult } from "./shared/binding-r9j8jqRV.mjs";
2
- import { A as BuiltinPlugin, At as RolldownOutput, Dt as OutputChunk, F as OutputBundle, G as MinimalPluginContext, Mt as freeExternalMemory, N as SourceMapInput, W as defineParallelPlugin, o as InputOptions, tt as NormalizedOutputOptions, xt as OutputOptions } from "./shared/define-config-MdVaFcie.mjs";
3
- import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-DO8UjlE5.mjs";
1
+ import { $ as transformSync, B as ParserOptions, C as BindingViteManifestPluginConfig, G as TransformResult, H as ResolveResult, I as MinifyOptions, J as isolatedDeclarationSync, K as createTokioRuntime, L as MinifyResult, N as IsolatedDeclarationsOptions, O as BindingViteTransformPluginConfig, P as IsolatedDeclarationsResult, Q as transform, R as NapiResolveOptions, U as ResolverFactory, W as TransformOptions, X as minifySync, Y as minify, Z as moduleRunnerTransform, _ as BindingViteCssPostPluginConfig, b as BindingViteHtmlPluginConfig, c as BindingRebuildStrategy, f as BindingUrlResolver, g as BindingViteCssPluginConfig, m as BindingViteAssetPluginConfig, n as BindingBundleState, q as isolatedDeclaration, r as BindingClientHmrUpdate, z as ParseResult } from "./shared/binding-CDyF6W3D.mjs";
2
+ import { A as BuiltinPlugin, At as RolldownOutput, Dt as OutputChunk, F as OutputBundle, G as MinimalPluginContext, Mt as freeExternalMemory, N as SourceMapInput, W as defineParallelPlugin, o as InputOptions, tt as NormalizedOutputOptions, xt as OutputOptions } from "./shared/define-config-kYHtCO-M.mjs";
3
+ import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-BnPlw43Q.mjs";
4
4
 
5
5
  //#region src/api/dev/dev-options.d.ts
6
6
  type DevOnHmrUpdates = (result: Error | {
@@ -192,6 +192,33 @@ type ViteManifestPluginConfig = Omit<BindingViteManifestPluginConfig, "isLegacy"
192
192
  declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPlugin;
193
193
  //#endregion
194
194
  //#region src/experimental-index.d.ts
195
+ /**
196
+ * In-memory file system for browser builds.
197
+ *
198
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
199
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
200
+ *
201
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
202
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
203
+ *
204
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * import { memfs } from 'rolldown/experimental';
209
+ *
210
+ * // Write files to virtual filesystem before bundling
211
+ * memfs?.volume.fromJSON({
212
+ * '/src/index.js': 'export const foo = 42;',
213
+ * '/package.json': '{"name": "my-app"}'
214
+ * });
215
+ *
216
+ * // Read files from the virtual filesystem
217
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
218
+ * ```
219
+ *
220
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
221
+ */
195
222
  declare const memfs: {
196
223
  fs: any;
197
224
  volume: any;
@@ -1,13 +1,13 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DMnPPQ90.mjs";
2
- import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./shared/normalize-string-or-regex-B4d0IHth.mjs";
3
- import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build-CNW2eye_.mjs";
4
- import { o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-A-rLIOKA.mjs";
5
- import { i as parseSync, r as parse } from "./shared/parse-ast-index-CoZSRGeP.mjs";
6
- import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-BGI2r6Tk.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-Cuiiq-jL.mjs";
2
+ import { d as bindingifySourcemap, n as BuiltinPlugin, t as normalizedStringOrRegex, u as transformToRollupOutput } from "./shared/normalize-string-or-regex-0t36Z7KW.mjs";
3
+ import { l as PluginDriver, n as createBundlerOptions, s as validateOption, t as RolldownBuild } from "./shared/rolldown-build--qygLwCL.mjs";
4
+ import { o as normalizeBindingResult, s as unwrapBindingResult } from "./shared/bindingify-input-options-B8B4dvr-.mjs";
5
+ import { i as parseSync, r as parse } from "./shared/parse-ast-index-Bcjhsr8U.mjs";
6
+ import { a as viteDynamicImportVarsPlugin, c as viteJsonPlugin, d as viteReactRefreshWrapperPlugin, f as viteReporterPlugin, g as viteWebWorkerPostPlugin, h as viteWasmHelperPlugin, i as viteBuildImportAnalysisPlugin, l as viteLoadFallbackPlugin, m as viteWasmFallbackPlugin, n as isolatedDeclarationPlugin, o as viteHtmlInlineProxyPlugin, p as viteResolvePlugin, r as viteAssetImportMetaUrlPlugin, s as viteImportGlobPlugin, u as viteModulePreloadPolyfillPlugin } from "./shared/constructors-CxTKGwaB.mjs";
7
7
  import { pathToFileURL } from "node:url";
8
8
 
9
9
  //#region src/api/dev/dev-engine.ts
10
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
10
+ var import_binding$1 = /* @__PURE__ */ __toESM(require_binding(), 1);
11
11
  var DevEngine = class DevEngine {
12
12
  #inner;
13
13
  #cachedBuildFinishPromise = null;
@@ -38,7 +38,7 @@ var DevEngine = class DevEngine {
38
38
  }
39
39
  userOnOutput(transformToRollupOutput(result));
40
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,
41
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding$1.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding$1.BindingRebuildStrategy.Auto : import_binding$1.BindingRebuildStrategy.Never : void 0,
42
42
  watch: devOptions.watch && {
43
43
  skipWrite: devOptions.watch.skipWrite,
44
44
  usePolling: devOptions.watch.usePolling,
@@ -49,7 +49,7 @@ var DevEngine = class DevEngine {
49
49
  debounceTickRate: devOptions.watch.debounceTickRate
50
50
  }
51
51
  };
52
- return new DevEngine(new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
52
+ return new DevEngine(new import_binding$1.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
53
53
  }
54
54
  constructor(inner) {
55
55
  this.#inner = inner;
@@ -151,12 +151,12 @@ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
151
151
  validateOption("input", rawInputOptions);
152
152
  validateOption("output", rawOutputOptions);
153
153
  const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
154
- const bundler = new import_binding.BindingBundler();
155
- if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();
154
+ const bundler = new import_binding$1.BindingBundler();
155
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding$1.startAsyncRuntime)();
156
156
  async function cleanup() {
157
157
  await bundler.close();
158
158
  await ret.stopWorkers?.();
159
- (0, import_binding.shutdownAsyncRuntime)();
159
+ (0, import_binding$1.shutdownAsyncRuntime)();
160
160
  RolldownBuild.asyncRuntimeShutdown = true;
161
161
  }
162
162
  let cleanupPromise = Promise.resolve();
@@ -242,17 +242,45 @@ function viteManifestPlugin(config) {
242
242
 
243
243
  //#endregion
244
244
  //#region src/experimental-index.ts
245
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
246
+ /**
247
+ * In-memory file system for browser builds.
248
+ *
249
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
250
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
251
+ *
252
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
253
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
254
+ *
255
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * import { memfs } from 'rolldown/experimental';
260
+ *
261
+ * // Write files to virtual filesystem before bundling
262
+ * memfs?.volume.fromJSON({
263
+ * '/src/index.js': 'export const foo = 42;',
264
+ * '/package.json': '{"name": "my-app"}'
265
+ * });
266
+ *
267
+ * // Read files from the virtual filesystem
268
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
269
+ * ```
270
+ *
271
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
272
+ */
245
273
  const memfs = void 0;
246
274
 
247
275
  //#endregion
248
- var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;
249
- var ResolverFactory = import_binding.ResolverFactory;
250
- var createTokioRuntime = import_binding.createTokioRuntime;
251
- var isolatedDeclaration = import_binding.isolatedDeclaration;
252
- var isolatedDeclarationSync = import_binding.isolatedDeclarationSync;
253
- var minify = import_binding.minify;
254
- var minifySync = import_binding.minifySync;
255
- var moduleRunnerTransform = import_binding.moduleRunnerTransform;
256
- var transform = import_binding.transform;
257
- var transformSync = import_binding.transformSync;
276
+ var BindingRebuildStrategy = import_binding$1.BindingRebuildStrategy;
277
+ var ResolverFactory = import_binding$1.ResolverFactory;
278
+ var createTokioRuntime = import_binding$1.createTokioRuntime;
279
+ var isolatedDeclaration = import_binding$1.isolatedDeclaration;
280
+ var isolatedDeclarationSync = import_binding$1.isolatedDeclarationSync;
281
+ var minify = import_binding$1.minify;
282
+ var minifySync = import_binding$1.minifySync;
283
+ var moduleRunnerTransform = import_binding$1.moduleRunnerTransform;
284
+ var transform = import_binding$1.transform;
285
+ var transformSync = import_binding$1.transformSync;
258
286
  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, viteAssetImportMetaUrlPlugin, viteAssetPlugin, viteBuildImportAnalysisPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlInlineProxyPlugin, viteHtmlPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWasmHelperPlugin, viteWebWorkerPostPlugin };
@@ -54,7 +54,7 @@ export class DevRuntime {
54
54
  /** @internal */
55
55
  __toCommonJS: any;
56
56
  /** @internal */
57
- __export: any;
57
+ __exportAll: any;
58
58
  /** @internal */
59
59
  __toDynamicImportESM: any;
60
60
  /** @internal */
@@ -1,4 +1,4 @@
1
- import "./shared/binding-r9j8jqRV.mjs";
2
- import { k as withFilter } from "./shared/define-config-MdVaFcie.mjs";
3
- import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
4
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
1
+ import "./shared/binding-CDyF6W3D.mjs";
2
+ import { k as withFilter } from "./shared/define-config-kYHtCO-M.mjs";
3
+ export * from "@rolldown/pluginutils/filter";
4
+ export { withFilter };
@@ -1,6 +1,331 @@
1
1
  import { n as isPromiseLike, t as arraify } from "./shared/misc-DpjTMcQQ.mjs";
2
- import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
3
2
 
3
+ //#region ../pluginutils/dist/utils.js
4
+ const postfixRE = /[?#].*$/;
5
+ function cleanUrl(url) {
6
+ return url.replace(postfixRE, "");
7
+ }
8
+ function extractQueryWithoutFragment(url) {
9
+ const questionMarkIndex = url.indexOf("?");
10
+ if (questionMarkIndex === -1) return "";
11
+ const fragmentIndex = url.indexOf("#", questionMarkIndex);
12
+ if (fragmentIndex === -1) return url.substring(questionMarkIndex);
13
+ else return url.substring(questionMarkIndex, fragmentIndex);
14
+ }
15
+
16
+ //#endregion
17
+ //#region ../pluginutils/dist/filter/composable-filters.js
18
+ var And = class {
19
+ kind;
20
+ args;
21
+ constructor(...args) {
22
+ if (args.length === 0) throw new Error("`And` expects at least one operand");
23
+ this.args = args;
24
+ this.kind = "and";
25
+ }
26
+ };
27
+ var Or = class {
28
+ kind;
29
+ args;
30
+ constructor(...args) {
31
+ if (args.length === 0) throw new Error("`Or` expects at least one operand");
32
+ this.args = args;
33
+ this.kind = "or";
34
+ }
35
+ };
36
+ var Not = class {
37
+ kind;
38
+ expr;
39
+ constructor(expr) {
40
+ this.expr = expr;
41
+ this.kind = "not";
42
+ }
43
+ };
44
+ var Id = class {
45
+ kind;
46
+ pattern;
47
+ params;
48
+ constructor(pattern, params) {
49
+ this.pattern = pattern;
50
+ this.kind = "id";
51
+ this.params = params ?? { cleanUrl: false };
52
+ }
53
+ };
54
+ var ImporterId = class {
55
+ kind;
56
+ pattern;
57
+ params;
58
+ constructor(pattern, params) {
59
+ this.pattern = pattern;
60
+ this.kind = "importerId";
61
+ this.params = params ?? { cleanUrl: false };
62
+ }
63
+ };
64
+ var ModuleType = class {
65
+ kind;
66
+ pattern;
67
+ constructor(pattern) {
68
+ this.pattern = pattern;
69
+ this.kind = "moduleType";
70
+ }
71
+ };
72
+ var Code = class {
73
+ kind;
74
+ pattern;
75
+ constructor(expr) {
76
+ this.pattern = expr;
77
+ this.kind = "code";
78
+ }
79
+ };
80
+ var Query = class {
81
+ kind;
82
+ key;
83
+ pattern;
84
+ constructor(key, pattern) {
85
+ this.pattern = pattern;
86
+ this.key = key;
87
+ this.kind = "query";
88
+ }
89
+ };
90
+ var Include = class {
91
+ kind;
92
+ expr;
93
+ constructor(expr) {
94
+ this.expr = expr;
95
+ this.kind = "include";
96
+ }
97
+ };
98
+ var Exclude = class {
99
+ kind;
100
+ expr;
101
+ constructor(expr) {
102
+ this.expr = expr;
103
+ this.kind = "exclude";
104
+ }
105
+ };
106
+ function and(...args) {
107
+ return new And(...args);
108
+ }
109
+ function or(...args) {
110
+ return new Or(...args);
111
+ }
112
+ function not(expr) {
113
+ return new Not(expr);
114
+ }
115
+ function id(pattern, params) {
116
+ return new Id(pattern, params);
117
+ }
118
+ function importerId(pattern, params) {
119
+ return new ImporterId(pattern, params);
120
+ }
121
+ function moduleType(pattern) {
122
+ return new ModuleType(pattern);
123
+ }
124
+ function code(pattern) {
125
+ return new Code(pattern);
126
+ }
127
+ function query(key, pattern) {
128
+ return new Query(key, pattern);
129
+ }
130
+ function include(expr) {
131
+ return new Include(expr);
132
+ }
133
+ function exclude(expr) {
134
+ return new Exclude(expr);
135
+ }
136
+ /**
137
+ * convert a queryObject to FilterExpression like
138
+ * ```js
139
+ * and(query(k1, v1), query(k2, v2))
140
+ * ```
141
+ * @param queryFilterObject The query filter object needs to be matched.
142
+ * @returns a `And` FilterExpression
143
+ */
144
+ function queries(queryFilter) {
145
+ return and(...Object.entries(queryFilter).map(([key, value]) => {
146
+ return new Query(key, value);
147
+ }));
148
+ }
149
+ function interpreter(exprs, code$1, id$1, moduleType$1, importerId$1) {
150
+ let arr = [];
151
+ if (Array.isArray(exprs)) arr = exprs;
152
+ else arr = [exprs];
153
+ return interpreterImpl(arr, code$1, id$1, moduleType$1, importerId$1);
154
+ }
155
+ function interpreterImpl(expr, code$1, id$1, moduleType$1, importerId$1, ctx = {}) {
156
+ let hasInclude = false;
157
+ for (const e of expr) switch (e.kind) {
158
+ case "include":
159
+ hasInclude = true;
160
+ if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, importerId$1, ctx)) return true;
161
+ break;
162
+ case "exclude":
163
+ if (exprInterpreter(e.expr, code$1, id$1, moduleType$1, importerId$1, ctx)) return false;
164
+ break;
165
+ }
166
+ return !hasInclude;
167
+ }
168
+ function exprInterpreter(expr, code$1, id$1, moduleType$1, importerId$1, ctx = {}) {
169
+ switch (expr.kind) {
170
+ case "and": return expr.args.every((e) => exprInterpreter(e, code$1, id$1, moduleType$1, importerId$1, ctx));
171
+ case "or": return expr.args.some((e) => exprInterpreter(e, code$1, id$1, moduleType$1, importerId$1, ctx));
172
+ case "not": return !exprInterpreter(expr.expr, code$1, id$1, moduleType$1, importerId$1, ctx);
173
+ case "id": {
174
+ if (id$1 === void 0) throw new Error("`id` is required for `id` expression");
175
+ let idToMatch = id$1;
176
+ if (expr.params.cleanUrl) idToMatch = cleanUrl(idToMatch);
177
+ return typeof expr.pattern === "string" ? idToMatch === expr.pattern : expr.pattern.test(idToMatch);
178
+ }
179
+ case "importerId": {
180
+ if (importerId$1 === void 0) return false;
181
+ let importerIdToMatch = importerId$1;
182
+ if (expr.params.cleanUrl) importerIdToMatch = cleanUrl(importerIdToMatch);
183
+ return typeof expr.pattern === "string" ? importerIdToMatch === expr.pattern : expr.pattern.test(importerIdToMatch);
184
+ }
185
+ case "moduleType":
186
+ if (moduleType$1 === void 0) throw new Error("`moduleType` is required for `moduleType` expression");
187
+ return moduleType$1 === expr.pattern;
188
+ case "code":
189
+ if (code$1 === void 0) throw new Error("`code` is required for `code` expression");
190
+ return typeof expr.pattern === "string" ? code$1.includes(expr.pattern) : expr.pattern.test(code$1);
191
+ case "query": {
192
+ if (id$1 === void 0) throw new Error("`id` is required for `Query` expression");
193
+ if (!ctx.urlSearchParamsCache) {
194
+ let queryString = extractQueryWithoutFragment(id$1);
195
+ ctx.urlSearchParamsCache = new URLSearchParams(queryString);
196
+ }
197
+ let urlParams = ctx.urlSearchParamsCache;
198
+ if (typeof expr.pattern === "boolean") if (expr.pattern) return urlParams.has(expr.key);
199
+ else return !urlParams.has(expr.key);
200
+ else if (typeof expr.pattern === "string") return urlParams.get(expr.key) === expr.pattern;
201
+ else return expr.pattern.test(urlParams.get(expr.key) ?? "");
202
+ }
203
+ default: throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
204
+ }
205
+ }
206
+
207
+ //#endregion
208
+ //#region ../pluginutils/dist/filter/filter-vite-plugins.js
209
+ /**
210
+ * Filters out Vite plugins that have `apply: 'serve'` set.
211
+ *
212
+ * Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
213
+ * are intended only for Vite's dev server and should be excluded from the build process.
214
+ *
215
+ * @param plugins - Array of plugins (can include nested arrays)
216
+ * @returns Filtered array with serve-only plugins removed
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { defineConfig } from 'rolldown';
221
+ * import { filterVitePlugins } from '@rolldown/pluginutils';
222
+ * import viteReact from '@vitejs/plugin-react';
223
+ *
224
+ * export default defineConfig({
225
+ * plugins: filterVitePlugins([
226
+ * viteReact(),
227
+ * {
228
+ * name: 'dev-only',
229
+ * apply: 'serve', // This will be filtered out
230
+ * // ...
231
+ * }
232
+ * ])
233
+ * });
234
+ * ```
235
+ */
236
+ function filterVitePlugins(plugins) {
237
+ if (!plugins) return [];
238
+ const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
239
+ const result = [];
240
+ for (const plugin of pluginArray) {
241
+ if (!plugin) continue;
242
+ if (Array.isArray(plugin)) {
243
+ result.push(...filterVitePlugins(plugin));
244
+ continue;
245
+ }
246
+ const pluginWithApply = plugin;
247
+ if ("apply" in pluginWithApply) {
248
+ const applyValue = pluginWithApply.apply;
249
+ if (typeof applyValue === "function") try {
250
+ if (applyValue({}, {
251
+ command: "build",
252
+ mode: "production"
253
+ })) result.push(plugin);
254
+ } catch {
255
+ result.push(plugin);
256
+ }
257
+ else if (applyValue === "serve") continue;
258
+ else result.push(plugin);
259
+ } else result.push(plugin);
260
+ }
261
+ return result;
262
+ }
263
+
264
+ //#endregion
265
+ //#region ../pluginutils/dist/filter/simple-filters.js
266
+ /**
267
+ * Constructs a RegExp that matches the exact string specified.
268
+ *
269
+ * This is useful for plugin hook filters.
270
+ *
271
+ * @param str the string to match.
272
+ * @param flags flags for the RegExp.
273
+ *
274
+ * @example
275
+ * ```ts
276
+ * import { exactRegex } from '@rolldown/pluginutils';
277
+ * const plugin = {
278
+ * name: 'plugin',
279
+ * resolveId: {
280
+ * filter: { id: exactRegex('foo') },
281
+ * handler(id) {} // will only be called for `foo`
282
+ * }
283
+ * }
284
+ * ```
285
+ */
286
+ function exactRegex(str, flags) {
287
+ return new RegExp(`^${escapeRegex(str)}$`, flags);
288
+ }
289
+ /**
290
+ * Constructs a RegExp that matches a value that has the specified prefix.
291
+ *
292
+ * This is useful for plugin hook filters.
293
+ *
294
+ * @param str the string to match.
295
+ * @param flags flags for the RegExp.
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * import { prefixRegex } from '@rolldown/pluginutils';
300
+ * const plugin = {
301
+ * name: 'plugin',
302
+ * resolveId: {
303
+ * filter: { id: prefixRegex('foo') },
304
+ * handler(id) {} // will only be called for IDs starting with `foo`
305
+ * }
306
+ * }
307
+ * ```
308
+ */
309
+ function prefixRegex(str, flags) {
310
+ return new RegExp(`^${escapeRegex(str)}`, flags);
311
+ }
312
+ const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
313
+ function escapeRegex(str) {
314
+ return str.replace(escapeRegexRE, "\\$&");
315
+ }
316
+ function makeIdFiltersToMatchWithQuery(input) {
317
+ if (!Array.isArray(input)) return makeIdFilterToMatchWithQuery(input);
318
+ return input.map((i) => makeIdFilterToMatchWithQuery(i));
319
+ }
320
+ function makeIdFilterToMatchWithQuery(input) {
321
+ if (typeof input === "string") return `${input}{?*,}`;
322
+ return makeRegexIdFilterToMatchWithQuery(input);
323
+ }
324
+ function makeRegexIdFilterToMatchWithQuery(input) {
325
+ return new RegExp(input.source.replace(/(?<!\\)\$/g, "(?:\\?.*)?$"), input.flags);
326
+ }
327
+
328
+ //#endregion
4
329
  //#region src/plugin/with-filter.ts
5
330
  function withFilterImpl(pluginOption, filterObjectList) {
6
331
  if (isPromiseLike(pluginOption)) return pluginOption.then((p) => withFilter(p, filterObjectList));
@@ -41,4 +366,4 @@ function findMatchedFilterObject(pluginName, overrideFilterObjectList) {
41
366
  }
42
367
 
43
368
  //#endregion
44
- export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
369
+ export { and, code, exactRegex, exclude, exprInterpreter, filterVitePlugins, id, importerId, include, interpreter, interpreterImpl, makeIdFiltersToMatchWithQuery, moduleType, not, or, prefixRegex, queries, query, withFilter };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./shared/logging-BpAvp7KV.mjs";
2
- import { V as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-r9j8jqRV.mjs";
3
- import { $ as RolldownFsModule, At as RolldownOutput, B as EmittedPrebuiltChunk, C as ResolveIdResult, D as SourceDescription, Dt as OutputChunk, E as RolldownPluginOption, Et as OutputAsset, F as OutputBundle, G as MinimalPluginContext, H as PluginContext, I as TreeshakingOptions, J as HookFilter, K as PluginContextMeta, L as TransformPluginContext, M as ExistingRawSourceMap, N as SourceMapInput, Nt as ModuleInfo, O as TransformResult, Ot as RenderedChunk, P as RolldownOptionsFunction, Pt as SourcemapIgnoreListOption, Q as RolldownFileStats, R as EmittedAsset, S as ResolveIdExtraOptions, St as PreRenderedAsset, T as RolldownPlugin, U as DefineParallelPluginResult, V as GetModuleInfo, X as BufferEncoding, Y as ModuleTypeFilter, Z as RolldownDirectoryEntry, _ as ModuleType, _t as GeneratedCodePreset, a as InputOption, at as watch, b as PartialResolvedId, bt as ModuleFormat, c as OptimizationOptions, ct as WatchOptions, d as CustomPluginOptions, dt as BuildOptions, et as InternalModuleFormat, f as FunctionPluginHooks, ft as build, g as ModuleOptions, gt as GeneratedCodeOptions, h as LoadResult, ht as ChunkingContext, i as ExternalOption, it as WarningHandlerWithDefault, j as VERSION, jt as SourceMap, kt as RenderedModule, l as WatcherOptions, lt as rolldown, m as ImportKind, mt as ChunkFileNamesFunction, n as ConfigExport, nt as NormalizedInputOptions, o as InputOptions, ot as RolldownWatcher, p as HookFilterExtension, pt as AddonFunction, q as GeneralHookFilter, r as RolldownOptions, rt as LoggingFunction, s as ModuleTypes, st as RolldownWatcherEvent, t as defineConfig, tt as NormalizedOutputOptions, u as AsyncPluginHooks, ut as RolldownBuild, v as ObjectHook, vt as GlobalsFunction, w as ResolvedId, wt as PartialNull, x as Plugin, xt as OutputOptions, y as ParallelPluginHooks, yt as MinifyOptions, z as EmittedFile } from "./shared/define-config-MdVaFcie.mjs";
2
+ import { V as PreRenderedChunk, s as BindingMagicString } from "./shared/binding-CDyF6W3D.mjs";
3
+ import { $ as RolldownFsModule, At as RolldownOutput, B as EmittedPrebuiltChunk, C as ResolveIdResult, D as SourceDescription, Dt as OutputChunk, E as RolldownPluginOption, Et as OutputAsset, F as OutputBundle, G as MinimalPluginContext, H as PluginContext, I as TreeshakingOptions, J as HookFilter, K as PluginContextMeta, L as TransformPluginContext, M as ExistingRawSourceMap, N as SourceMapInput, Nt as ModuleInfo, O as TransformResult, Ot as RenderedChunk, P as RolldownOptionsFunction, Pt as SourcemapIgnoreListOption, Q as RolldownFileStats, R as EmittedAsset, S as ResolveIdExtraOptions, St as PreRenderedAsset, T as RolldownPlugin, U as DefineParallelPluginResult, V as GetModuleInfo, X as BufferEncoding, Y as ModuleTypeFilter, Z as RolldownDirectoryEntry, _ as ModuleType, _t as GeneratedCodePreset, a as InputOption, at as watch, b as PartialResolvedId, bt as ModuleFormat, c as OptimizationOptions, ct as WatchOptions, d as CustomPluginOptions, dt as BuildOptions, et as InternalModuleFormat, f as FunctionPluginHooks, ft as build, g as ModuleOptions, gt as GeneratedCodeOptions, h as LoadResult, ht as ChunkingContext, i as ExternalOption, it as WarningHandlerWithDefault, j as VERSION, jt as SourceMap, kt as RenderedModule, l as WatcherOptions, lt as rolldown, m as ImportKind, mt as ChunkFileNamesFunction, n as ConfigExport, nt as NormalizedInputOptions, o as InputOptions, ot as RolldownWatcher, p as HookFilterExtension, pt as AddonFunction, q as GeneralHookFilter, r as RolldownOptions, rt as LoggingFunction, s as ModuleTypes, st as RolldownWatcherEvent, t as defineConfig, tt as NormalizedOutputOptions, u as AsyncPluginHooks, ut as RolldownBuild, v as ObjectHook, vt as GlobalsFunction, w as ResolvedId, wt as PartialNull, x as Plugin, xt as OutputOptions, y as ParallelPluginHooks, yt as MinifyOptions, z as EmittedFile } from "./shared/define-config-kYHtCO-M.mjs";
4
4
  export { AddonFunction, AsyncPluginHooks, BindingMagicString, BufferEncoding, BuildOptions, ChunkFileNamesFunction, ChunkingContext, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, EmittedPrebuiltChunk, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GeneratedCodeOptions, GeneratedCodePreset, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DMnPPQ90.mjs";
2
- import { n as onExit, t as watch } from "./shared/watch-CKam-d6K.mjs";
3
- import { y as VERSION } from "./shared/normalize-string-or-regex-B4d0IHth.mjs";
4
- import "./shared/rolldown-build-CNW2eye_.mjs";
5
- import "./shared/bindingify-input-options-A-rLIOKA.mjs";
6
- import "./shared/parse-ast-index-CoZSRGeP.mjs";
7
- import { t as rolldown } from "./shared/rolldown-BTFK71hw.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-Cuiiq-jL.mjs";
2
+ import { n as onExit, t as watch } from "./shared/watch-CyvuFK7g.mjs";
3
+ import { y as VERSION } from "./shared/normalize-string-or-regex-0t36Z7KW.mjs";
4
+ import "./shared/rolldown-build--qygLwCL.mjs";
5
+ import "./shared/bindingify-input-options-B8B4dvr-.mjs";
6
+ import "./shared/parse-ast-index-Bcjhsr8U.mjs";
7
+ import { t as rolldown } from "./shared/rolldown-CF29fS6Z.mjs";
8
8
  import { t as defineConfig } from "./shared/define-config-BF4P-Pum.mjs";
9
9
  import { isMainThread } from "node:worker_threads";
10
10
 
@@ -1,7 +1,7 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DMnPPQ90.mjs";
2
- import "./shared/normalize-string-or-regex-B4d0IHth.mjs";
3
- import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-A-rLIOKA.mjs";
4
- import "./shared/parse-ast-index-CoZSRGeP.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-Cuiiq-jL.mjs";
2
+ import "./shared/normalize-string-or-regex-0t36Z7KW.mjs";
3
+ import { n as PluginContextData, r as bindingifyPlugin } from "./shared/bindingify-input-options-B8B4dvr-.mjs";
4
+ import "./shared/parse-ast-index-Bcjhsr8U.mjs";
5
5
  import { parentPort, workerData } from "node:worker_threads";
6
6
 
7
7
  //#region src/parallel-plugin-worker.ts
@@ -1,5 +1,5 @@
1
- import "./shared/binding-r9j8jqRV.mjs";
2
- import { Ct as MaybePromise, x as Plugin } from "./shared/define-config-MdVaFcie.mjs";
1
+ import "./shared/binding-CDyF6W3D.mjs";
2
+ import { Ct as MaybePromise, x as Plugin } from "./shared/define-config-kYHtCO-M.mjs";
3
3
 
4
4
  //#region src/plugin/parallel-plugin-implementation.d.ts
5
5
  type ParallelPluginImplementation = Plugin;
@@ -1,4 +1,4 @@
1
- import { B as ParserOptions, z as ParseResult } from "./shared/binding-r9j8jqRV.mjs";
1
+ import { B as ParserOptions, z as ParseResult } from "./shared/binding-CDyF6W3D.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
 
4
4
  //#region src/parse-ast-index.d.ts