import type { RsbuildPlugin } from '@rsbuild/core'; import type { Rspack } from '@rsbuild/core'; /** * The name of the bundle files. * * @public */ export declare type BundleFilename = string | ((context: BundleFilenameContext) => string); /** * The context passed to the {@link LynxFilename.bundle} function. * * @public */ export declare interface BundleFilenameContext { /** * Whether the filename is being resolved for a lazy bundle (async chunk) * instead of the main bundle of an entry. */ lazyBundle: boolean; /** * The name of the entry. * * @remarks * * It is `undefined` for lazy bundles, since a lazy bundle name is resolved * per async chunk instead of per entry. */ entryName?: string | undefined; /** * The name of the Rsbuild environment. */ platform: string; } /** * Whether the Lynx build engine is already registered. * * @remarks * * The engine is a global one. `isPluginExists` without an environment only * reports the global plugins, so it misses an engine a caller — `rslib`, for * one — registered on an environment instead. * * @param host - The Rsbuild instance or plugin API to look it up on. * @param environments - The names of the configured environments. * * @public */ export declare function isPluginLynxRegistered(host: { isPluginExists(name: string, options?: { environment?: string; }): boolean; }, environments: string[]): boolean; /** * The Lynx config that `pluginLynx` exposes to other plugins. * * @remarks * * The data mirrors {@link LynxPluginOptions}, so a plugin reads * `config.output.filename` the same way it reads `output.filename` from * `api.getRsbuildConfig()`. Values that depend on the entry being built are * derived by the methods, which travel with the data so that the plugin that * built the config is always the one that resolves it. * * @beta * * @example * * ```js * const lynx = getLynxConfig(api) * const filename = lynx.resolveBundleFilename({ * entryName: 'main', * platform: environment.name, * }) * ``` */ export declare interface LynxConfig { /** * The build outputs. */ readonly output: LynxOutput; /** * The performance options. */ readonly performance: LynxPerformance; /** * Resolve the name of the bundle file of an entry. * * @param context - The entry to resolve the name for. */ resolveBundleFilename(context: { entryName: string; platform: string; }): string; /** * Resolve the directory of the intermediate files. * * @remarks * * A Lynx bundle is encoded from per-thread JS, CSS and HMR outputs. They are * emitted into this directory, per entry, instead of next to the bundle. * * @param context - The entry to resolve the directory for. Without an entry * name, the directory that holds every entry's is returned. */ resolveIntermediateDir(context?: { entryName?: string | undefined; }): string; /** * Resolve the name of the lazy bundle files. * * @param context - The environment to resolve the name for. * * @returns The resolved name, or `undefined` when {@link LynxFilename.bundle} * is not a function. A lazy bundle name can only be customized by a function, * since it is resolved per async chunk, so `undefined` means the caller * leaves the name to `LynxTemplatePlugin`. * * @remarks * * There is no entry name to resolve `[name]` with, so the placeholder is * kept for `LynxTemplatePlugin` to fill in per async chunk. */ resolveLazyBundleFilename(context: { platform: string; }): string | undefined; } /** * The names of the files emitted by the Lynx build engine. * * @public */ export declare interface LynxFilename { /** * The name of the bundle files. * * @defaultValue `'[name].[platform].bundle'` * * @remarks * * The following placeholders are supported: * * - `[name]`: the name of the entry. * - `[platform]`: the name of the Rsbuild environment. */ bundle?: BundleFilename | undefined; } /** * The minifier options of the Lynx threads. * * @public * * @remarks * * Lynx emits one bundle per thread, and each thread may need different * minifier settings. These are merged on top of the Rsbuild * `output.minify.jsOptions` and applied to that thread only. */ export declare interface LynxMinify { /** * The minifier options of the main thread. */ mainThreadOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined; /** * The minifier options of the background thread. */ backgroundOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined; } /** * The build outputs of the Lynx build engine. * * @public */ export declare interface LynxOutput { /** * The names of the emitted files. */ filename?: LynxFilename | undefined; /** * The per-thread minifier options. */ minify?: LynxMinify | undefined; } /** * The performance options of the Lynx build engine. * * @public */ export declare interface LynxPerformance { /** * Whether to capture timing information in Lynx runtime integrations such as * ReactLynx. * * @remarks * * A framework includes runtime information using `console.profile` when this * is enabled. */ profile?: boolean | undefined; } /** * The options of `pluginLynx`. * * @public */ export declare interface LynxPluginOptions { /** * The build outputs. */ output?: LynxOutput | undefined; /** * The performance options. */ performance?: LynxPerformance | undefined; } /** * The name of the plugin that marks `pluginLynx` as applied. Use it with * `api.isPluginExists` to tell whether the Lynx build engine is already there. * * @public */ export declare const PLUGIN_LYNX_NAME = "lynx:rsbuild"; /** * @public */ export declare function pluginLynx(options?: LynxPluginOptions): RsbuildPlugin[]; export { }