mirror of
https://github.com/element-plus/element-plus.git
synced 2024-11-27 02:01:15 +08:00
36 lines
928 B
TypeScript
36 lines
928 B
TypeScript
import { epPackage } from './paths'
|
|
import { getPackageDependencies } from './pkg'
|
|
|
|
import type { OutputOptions, RollupBuild } from 'rollup'
|
|
|
|
export const generateExternal = async (options: { full: boolean }) => {
|
|
const { dependencies, peerDependencies } = await getPackageDependencies(
|
|
epPackage
|
|
)
|
|
|
|
return (id: string) => {
|
|
const packages: string[] = peerDependencies
|
|
if (!options.full) {
|
|
packages.push('element-plus/theme-chalk')
|
|
// dependencies
|
|
packages.push('@vue', ...dependencies)
|
|
}
|
|
|
|
return [...new Set(packages)].some(
|
|
(pkg) => id === pkg || id.startsWith(`${pkg}/`)
|
|
)
|
|
}
|
|
}
|
|
|
|
export function writeBundles(bundle: RollupBuild, options: OutputOptions[]) {
|
|
return Promise.all(options.map((option) => bundle.write(option)))
|
|
}
|
|
|
|
export function formatBundleFilename(
|
|
name: string,
|
|
minify: boolean,
|
|
ext: string
|
|
) {
|
|
return `${name}${minify ? '.min' : ''}.${ext}`
|
|
}
|