import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform" ; import castArray from "lodash/castArray" ; import type { BundleConfig , BundleDefinition , BundleRequiredParameters , } from "./bundleConfig" ; export type BundleDefinitionWithRequiredParameters = BundleDefinition & BundleRequiredParameters ; param config param id returns export function getBundleDefinition ( config , id ? ) { const defaultDefinition = { entryPath : "lib/index.js" , distPath : "dist" , assetsPath : "dist" , bundlePrefix : "index" , detectCyclicDependencies : true , detectDuplicateDependencies : true , typescriptValidation : true , experimental_treeShake : false } ; if ( typeof config === "boolean" ) { return defaultDefinition ; } const bundles = castArray ( config ) ; if ( id ) { const bundle = bundles . find ( ( b ) => b . id === id ) || { } ; return { ... defaultDefinition , ... bundle } ; } return { ... defaultDefinition , ... bundles [ 0 ] } ; } param bundle param platform returns export function getBundlePlatformDefinition ( bundle , platform ) { const platformValues = bundle . platforms && bundle . platforms [ platform ] ; return platformValues ? { ... bundle , ... platformValues } : bundle ; }