( libOptions: LibraryOptions, format: ModuleFormat, entryName: string, root: string, extension?: JsExt, packageCache?: PackageCache, )
| 994 | } |
| 995 | |
| 996 | export function resolveLibFilename( |
| 997 | libOptions: LibraryOptions, |
| 998 | format: ModuleFormat, |
| 999 | entryName: string, |
| 1000 | root: string, |
| 1001 | extension?: JsExt, |
| 1002 | packageCache?: PackageCache, |
| 1003 | ): string { |
| 1004 | if (typeof libOptions.fileName === 'function') { |
| 1005 | return libOptions.fileName(format, entryName) |
| 1006 | } |
| 1007 | |
| 1008 | const packageJson = findNearestMainPackageData(root, packageCache)?.data |
| 1009 | const name = |
| 1010 | libOptions.fileName || |
| 1011 | (packageJson && typeof libOptions.entry === 'string' |
| 1012 | ? getPkgName(packageJson.name) |
| 1013 | : entryName) |
| 1014 | |
| 1015 | if (!name) |
| 1016 | throw new Error( |
| 1017 | 'Name in package.json is required if option "build.lib.fileName" is not provided.', |
| 1018 | ) |
| 1019 | |
| 1020 | extension ??= resolveOutputJsExtension(format, packageJson?.type) |
| 1021 | |
| 1022 | if (format === 'cjs' || format === 'es') { |
| 1023 | return `${name}.${extension}` |
| 1024 | } |
| 1025 | |
| 1026 | return `${name}.${format}.${extension}` |
| 1027 | } |
| 1028 | |
| 1029 | export function resolveBuildOutputs( |
| 1030 | outputs: OutputOptions | OutputOptions[] | undefined, |
no test coverage detected