mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-06 05:09:00 +08:00
4e99d0b5ba
* build!: simplify build & support native esm import * 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 * build!: improve esm exports (#3871) * build: improve esm import * refactor: change mjs for esm version * chore: improve exports map * fix: add sideEffects * refactor: improve alias * build: upgrade dependencies
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import path from 'path'
|
|
import { epOutput } from './utils/paths'
|
|
import { EP_PKG } from './utils/constants'
|
|
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'
|
|
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',
|
|
output: {
|
|
name: 'es',
|
|
path: path.resolve(epOutput, 'es'),
|
|
},
|
|
bundle: {
|
|
path: `${EP_PKG}/es`,
|
|
},
|
|
},
|
|
cjs: {
|
|
module: 'CommonJS',
|
|
format: 'cjs',
|
|
ext: 'js',
|
|
output: {
|
|
name: 'lib',
|
|
path: path.resolve(epOutput, 'lib'),
|
|
},
|
|
bundle: {
|
|
path: `${EP_PKG}/lib`,
|
|
},
|
|
},
|
|
}
|
|
export const buildConfigEntries = Object.entries(
|
|
buildConfig
|
|
) as BuildConfigEntries
|
|
|
|
export type BuildConfig = typeof buildConfig
|
|
export type BuildConfigEntries = [Module, BuildInfo][]
|