types-bundle-config
TypeScript type definitions for Metro bundling configuration, bundler plugins, server configuration, and React Native platform targets. This package exists to break circular dependencies between rnx-kit packages that share these types.
Installation
Section titled “Installation”yarn add @rnx-kit/types-bundle-config --devor if you’re using npm
npm add --save-dev @rnx-kit/types-bundle-configimport type { BundleConfig, BundleParameters, ServerConfig, AllPlatforms, Plugin,} from "@rnx-kit/types-bundle-config";Bundle Configuration
Section titled “Bundle Configuration”BundleParameters
Section titled “BundleParameters”Parameters controlling how a bundle is constructed. Extends BundlerPlugins and
BundleOutputOptions.
| Name | Type | Description |
|---|---|---|
| entryFile | string | undefined |
Path to the entry-point .js file. Either absolute or relative to package. |
| assetsDest | string | undefined |
Path where bundle assets are written. |
| projectRoot | string | undefined |
Path to the root of the react-native project. |
| assetPlugins | string[] | undefined |
Additional asset plugins for the Metro Babel transformer. |
| sourceExts | string[] | undefined |
Additional source-file extensions to include when generating bundles. |
| treeShake | boolean | SerializerEsbuildOptions |
Enable tree shaking via esbuild. |
| hermes | boolean | HermesOptions |
Whether to run the Hermes compiler on the output bundle. |
| plugins | Plugin[] |
List of plugins to add to the bundling process. |
BundleConfig
Section titled “BundleConfig”Defines how a package is bundled. Extends BundleParameters with
platform-specific overrides.
| Name | Type | Description |
|---|---|---|
| id | string | undefined |
Unique identifier for this bundle configuration. |
| targets | AllPlatforms[] | undefined |
The platform(s) for which this package may be bundled. |
| platforms | Partial<Record<AllPlatforms, BundleParameters>> |
Platform-specific overrides for bundling parameters. |
BundleOutputOptions
Section titled “BundleOutputOptions”Output path and encoding options for a bundle, derived from Metro’s
OutputOptions.
| Name | Type | Description |
|---|---|---|
| bundleOutput | string | undefined |
Path to the output bundle file. |
| bundleEncoding | string | undefined |
Encoding scheme (UTF-8, UTF-16 LE, or 7-bit ASCII). |
| sourcemapOutput | string | undefined |
Path for the bundle source map file. |
| sourcemapSourcesRoot | string | undefined |
Path to package source files for portable source-map paths. |
| sourcemapUseAbsolutePath | boolean | undefined |
Whether SourceMapURL is reported as a full path or just a file name. |
HermesOptions
Section titled “HermesOptions”Options for the Hermes bytecode compiler.
| Name | Type | Description |
|---|---|---|
| command | string | undefined |
Path to hermesc binary. |
| flags | string[] | undefined |
Arguments passed to hermesc. |
Server Configuration
Section titled “Server Configuration”ServerConfig
Section titled “ServerConfig”An alias for BundleParameters.
Bundler Plugin Types
Section titled “Bundler Plugin Types”Plugin
Section titled “Plugin”A plugin is either a module name string or a tuple of [name, options].
Platform Types
Section titled “Platform Types”AllPlatforms
Section titled “AllPlatforms”Union type of supported React Native platforms:
type AllPlatforms = | "android" | "ios" | "macos" | "visionos" | "web" | "win32" | "windows";ALL_PLATFORM_VALUES
Section titled “ALL_PLATFORM_VALUES”Constant array containing all platform values (useful for iteration):
const ALL_PLATFORM_VALUES = [ "android", "ios", "macos", "visionos", "web", "win32", "windows",] as const;