mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
fb94222bb4
* build: refactor build * refactor: reorganize files * refactor: refactor build * build: improve perf * fix: scripts * build: add rollup-plugin-filesize * chore: scripts ignore no-console * build: disable tree-shaking * build: improve code * build: add sourcemap * build: add banner * refactor: remove annotation
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import findWorkspacePackages from '@pnpm/find-workspace-packages'
|
|
import { buildConfig } from '../build-info'
|
|
import { EP_PREFIX } from './constants'
|
|
import { projRoot } from './paths'
|
|
import type { Module } from '../build-info'
|
|
import type { ProjectManifest } from '@pnpm/types'
|
|
|
|
export const getWorkspacePackages = () => findWorkspacePackages(projRoot)
|
|
export const getWorkspaceNames = async (dir = projRoot) => {
|
|
const pkgs = await findWorkspacePackages(projRoot)
|
|
return pkgs
|
|
.filter((pkg) => pkg.dir.startsWith(dir))
|
|
.map((pkg) => pkg.manifest.name)
|
|
.filter((name): name is string => !!name)
|
|
}
|
|
|
|
export const getPackageManifest = (pkgPath: string) => {
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
return require(pkgPath) as ProjectManifest
|
|
}
|
|
|
|
export const getPackageDependencies = (pkgPath: string): string[] => {
|
|
const manifest = getPackageManifest(pkgPath)
|
|
const { dependencies } = manifest
|
|
return Object.keys(dependencies ?? {})
|
|
}
|
|
|
|
export const pathRewriter = (module: Module) => {
|
|
const config = buildConfig[module]
|
|
|
|
return (id: string) => {
|
|
id = id.replaceAll(`${EP_PREFIX}/theme-chalk`, 'element-plus/theme-chalk')
|
|
id = id.replaceAll(`${EP_PREFIX}/`, `${config.bundle.path}/`)
|
|
return id
|
|
}
|
|
}
|
|
|
|
export const excludeFiles = (files: string[]) => {
|
|
const excludes = ['node_modules', 'test', 'mock', 'gulpfile', 'dist']
|
|
return files.filter(
|
|
(path) => !excludes.some((exclude) => path.includes(exclude))
|
|
)
|
|
}
|