mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-11-30 18:27:40 +08:00
perf(build): optimizition build time (#5507)
This commit is contained in:
parent
47fdd4f542
commit
621d8c7a8e
@ -19,10 +19,16 @@ export const getPackageManifest = (pkgPath: string) => {
|
||||
return require(pkgPath) as ProjectManifest
|
||||
}
|
||||
|
||||
export const getPackageDependencies = (pkgPath: string): string[] => {
|
||||
export const getPackageDependencies = (
|
||||
pkgPath: string
|
||||
): Record<'dependencies' | 'peerDependencies', string[]> => {
|
||||
const manifest = getPackageManifest(pkgPath)
|
||||
const { dependencies } = manifest
|
||||
return Object.keys(dependencies ?? {})
|
||||
const { dependencies = {}, peerDependencies = {} } = manifest
|
||||
|
||||
return {
|
||||
dependencies: Object.keys(dependencies),
|
||||
peerDependencies: Object.keys(peerDependencies),
|
||||
}
|
||||
}
|
||||
|
||||
/** used for type generator */
|
||||
|
@ -4,12 +4,16 @@ 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[] = ['vue']
|
||||
const packages: string[] = peerDependencies
|
||||
if (!options.full) {
|
||||
packages.push('element-plus/theme-chalk')
|
||||
// dependencies
|
||||
packages.push('@vue', ...getPackageDependencies(epPackage))
|
||||
packages.push('@vue', ...dependencies)
|
||||
}
|
||||
|
||||
return [...new Set(packages)].some(
|
||||
|
@ -28,7 +28,7 @@ if (process.env.DOC_ENV !== 'production') {
|
||||
}
|
||||
|
||||
export default async () => {
|
||||
const deps = getPackageDependencies(epPackage)
|
||||
const { dependencies } = getPackageDependencies(epPackage)
|
||||
const optimizeDeps = [
|
||||
'vue',
|
||||
'@vue/shared',
|
||||
@ -36,7 +36,7 @@ export default async () => {
|
||||
'clipboard-copy',
|
||||
'axios',
|
||||
'nprogress',
|
||||
...deps,
|
||||
...dependencies,
|
||||
]
|
||||
optimizeDeps.push(
|
||||
...(
|
||||
|
Loading…
Reference in New Issue
Block a user