mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* Revert "build!: simplify build & support native esm import (#3900)"
This reverts commit fb94222bb4.
* remove module
* Fix linter
* Add @element-plus/icons as dependency
* update pnpm lock file
* temporary lock element-plus at 1.1.0-beta.20
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import findWorkspacePackages from '@pnpm/find-workspace-packages'
|
|
import { buildConfig } from '../info'
|
|
import { EP_PREFIX } from '../constants'
|
|
import { projRoot } from './paths'
|
|
import type { Module } from '../info'
|
|
import type { ProjectManifest } from '@pnpm/types'
|
|
|
|
export const getWorkspacePackages = () => findWorkspacePackages(projRoot)
|
|
export const getWorkspaceNames = async () => {
|
|
const pkgs = await findWorkspacePackages(projRoot)
|
|
return pkgs
|
|
.map((pkg) => pkg.manifest.name)
|
|
.filter((name): name is string => !!name)
|
|
}
|
|
export const getWorkspacePackageManifest = async (
|
|
name: string
|
|
): Promise<ProjectManifest> => {
|
|
const packages = await getWorkspacePackages()
|
|
const { manifest } = packages.find((pkg) => pkg.manifest.name === name)!
|
|
return manifest
|
|
}
|
|
|
|
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, replaceAll: boolean) => {
|
|
const replaceName = replaceAll ? 'replaceAll' : 'replace'
|
|
const config = buildConfig[module]
|
|
|
|
return (id: string) => {
|
|
id = id[replaceName](`${EP_PREFIX}/theme-chalk`, 'element-plus/theme-chalk')
|
|
id = id[replaceName](`${EP_PREFIX}/`, `${config.bundle.path}/`)
|
|
return id
|
|
}
|
|
}
|