import type { AppConfig } from './AppConfig.js'; /** * A function that takes a config object and options object and returns a new config object. * This is used to implement a bundler capability. * * - `TConfig` is the type of the bundler's config object. (ie: `WebpackConfiguration`, `OriBuildOptions`, etc) * - `TOptions` is the type of the options object that's passed to the capability. (ie: `{ banner: string }` * or any other type that the capability needs when enabled) or a boolean to indicate if the capability is enabled. */ export type BundlerCapabilityFunction = (config: TConfig, options: TOptions) => TConfig; /** * A bundler capability is a feature that can be enabled for a package to modify the bundling process. * * `TOptions` is the type of the options object that's passed to the capability. (ie: `{ banner: string }` * or any other type that the capability needs when enabled) */ export type BaseBundlerCapability> = { name: string; description: string; implementations: { [key in Bundlers]?: BundlerCapabilityFunction; }; }; /** * This is the list of the bundler capabilities that cloudpack provides. * - key: The name of the capability which will be used in the cloudpack config to enable the capability * - value: Options object which will be passed to the capability function */ export type InternalBundlerCapabilities = { /** * Inlines assets into the bundle. * * Extensions can be specified as: * - Array: `['avif']` - use only these extensions (replaces defaults) * - Object: `{ 'svg': false, 'avif': true }` - modify defaults (remove svg, add avif) * * Do not include the leading dot. */ 'asset-inline': { extensions: readonly string[] | Record; }; /** * Replace identifiers at build time. * Values must be valid JS literals as strings (e.g. JSON.stringify('value')). */ define: { [key: string]: string; }; /** * Bundler capability to support Density externals. * This is not a real capability, it's just an indicator that a package needs to use density post-bundle task. * Since there is no actual way to execute post-bundle tasks, I'm using this as a workaround. * This will be removed once we have a proper way to execute post-bundle tasks with the plugins. * Options: List of entries that should be treated as density externals. */ density: boolean | { entries: string[]; }; /** * Adds aliases to externalized packages. */ alias: { [key: string]: string; }; /** * Enables React Native type resolution of .web.ts extensions. * Options: object is empty because it's just an indicator. No options are needed. */ 'resolve-web-extensions': boolean; /** * Enables Relay support for the package. */ relay: NonNullable; }; /** * This is the type that's being used `PackageSettings` to enable/disable bundler capabilities. * - Key: internal capability name * - Value: options object to configure the capability, or false to disable it */ export type InternalBundlerCapabilitiesOptions = { [key in keyof InternalBundlerCapabilities]?: InternalBundlerCapabilities[key] | boolean; }; type ExternalBundlerCapabilitiesOptions = Record; /** * Options used in `PackageSettings` to configure or disable bundler capabilities. * - Key: capability name, either internal (Cloudpack-provided) or external (as specified in * `AppConfig.bundlerCapabilitiesRegistry`) * - Value: options object to configure the capability, or false to disable it. */ export type BundlerCapabilitiesOptions = InternalBundlerCapabilitiesOptions & ExternalBundlerCapabilitiesOptions; /** * Metadata for the bundler capabilities that cloudpack provides. * - Key: capability name * - Value: metadata object with description */ export type InternalBundlerCapabilitiesMetaData = { [key in keyof InternalBundlerCapabilities]: Pick, 'description'>; }; /** * This is a bundler specific implementation of the internal bundler capabilities. * It's a mapping from the capability name to the capability function. * * `TConfig` is the type of the bundler's config object. (ie: `WebpackConfiguration`, `OriBuildOptions`, etc) */ export type InternalBundlerCapabilityImplementations = { [key in keyof InternalBundlerCapabilities]: BundlerCapabilityFunction; }; /** * This is the type of the external bundler capability module that's being imported. * * `TOptions` is the type of the capability's options. */ export type ExternalBundlerCapabilityModule> = { default: BaseBundlerCapability; }; export {}; //# sourceMappingURL=BundlerCapability.d.ts.map