element-plus/build/build-info.ts

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-09-26 01:29:07 +08:00
import path from 'path'
import { epOutput } from './utils/paths'
import { EP_PKG } from './utils/constants'
2021-09-26 01:29:07 +08:00
import type { ModuleFormat } from 'rollup'
export const modules = ['esm', 'cjs'] as const
export type Module = typeof modules[number]
export interface BuildInfo {
module: 'ESNext' | 'CommonJS'
format: ModuleFormat
ext: 'mjs' | 'cjs' | 'js'
2021-09-26 01:29:07 +08:00
output: {
/** e.g: `es` */
name: string
/** e.g: `dist/element-plus/es` */
path: string
}
bundle: {
/** e.g: `element-plus/es` */
path: string
}
}
export const buildConfig: Record<Module, BuildInfo> = {
esm: {
module: 'ESNext',
format: 'esm',
ext: 'mjs',
2021-09-26 01:29:07 +08:00
output: {
name: 'es',
path: path.resolve(epOutput, 'es'),
},
bundle: {
path: `${EP_PKG}/es`,
2021-09-26 01:29:07 +08:00
},
},
cjs: {
module: 'CommonJS',
format: 'cjs',
ext: 'js',
2021-09-26 01:29:07 +08:00
output: {
name: 'lib',
path: path.resolve(epOutput, 'lib'),
},
bundle: {
path: `${EP_PKG}/lib`,
2021-09-26 01:29:07 +08:00
},
},
}
export const buildConfigEntries = Object.entries(
buildConfig
) as BuildConfigEntries
2021-09-26 01:29:07 +08:00
export type BuildConfig = typeof buildConfig
export type BuildConfigEntries = [Module, BuildInfo][]