mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
build!: improve esm exports (#3871)
* build: improve esm import * refactor: change mjs for esm version * chore: improve exports map
This commit is contained in:
@@ -8,6 +8,7 @@ export type Module = typeof modules[number]
|
||||
export interface BuildInfo {
|
||||
module: 'ESNext' | 'CommonJS'
|
||||
format: ModuleFormat
|
||||
ext: 'mjs' | 'cjs' | 'js'
|
||||
output: {
|
||||
/** e.g: `es` */
|
||||
name: string
|
||||
@@ -25,6 +26,7 @@ export const buildConfig: Record<Module, BuildInfo> = {
|
||||
esm: {
|
||||
module: 'ESNext',
|
||||
format: 'esm',
|
||||
ext: 'mjs',
|
||||
output: {
|
||||
name: 'es',
|
||||
path: path.resolve(epOutput, 'es'),
|
||||
@@ -36,6 +38,7 @@ export const buildConfig: Record<Module, BuildInfo> = {
|
||||
cjs: {
|
||||
module: 'CommonJS',
|
||||
format: 'cjs',
|
||||
ext: 'js',
|
||||
output: {
|
||||
name: 'lib',
|
||||
path: path.resolve(epOutput, 'lib'),
|
||||
|
||||
@@ -48,6 +48,7 @@ export const buildModules = async () => {
|
||||
preserveModules: true,
|
||||
preserveModulesRoot: epRoot,
|
||||
sourcemap: true,
|
||||
entryFileNames: `[name].${config.ext}`,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -12,8 +12,17 @@
|
||||
"vue"
|
||||
],
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./lib/index.js",
|
||||
"import": "./es/index.mjs"
|
||||
},
|
||||
"./es": "./es/index.mjs",
|
||||
"./lib": "./lib/index.js",
|
||||
"./*": "./*"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
"module": "es/index.mjs",
|
||||
"style": "dist/index.css",
|
||||
"unpkg": "dist/index.full.js",
|
||||
"jsdelivr": "dist/index.full.js",
|
||||
|
||||
Reference in New Issue
Block a user