build: adjust build formats
- Rename `esm` to `esm-browser` - Add runtime-only build for `esm-browser` - Add default CDN alias for jsdelivr
This commit is contained in:
@@ -23,6 +23,10 @@ const outputConfigs = {
|
||||
file: resolve(`dist/${name}.esm-bundler.js`),
|
||||
format: `es`
|
||||
},
|
||||
'esm-browser': {
|
||||
file: resolve(`dist/${name}.esm-browser.js`),
|
||||
format: `es`
|
||||
},
|
||||
cjs: {
|
||||
file: resolve(`dist/${name}.cjs.js`),
|
||||
format: `cjs`
|
||||
@@ -31,15 +35,16 @@ const outputConfigs = {
|
||||
file: resolve(`dist/${name}.global.js`),
|
||||
format: `iife`
|
||||
},
|
||||
esm: {
|
||||
file: resolve(`dist/${name}.esm.js`),
|
||||
format: `es`
|
||||
},
|
||||
// main "vue" package only
|
||||
|
||||
// runtime-only builds, for main "vue" package only
|
||||
'esm-bundler-runtime': {
|
||||
file: resolve(`dist/${name}.runtime.esm-bundler.js`),
|
||||
format: `es`
|
||||
},
|
||||
'esm-browser-runtime': {
|
||||
file: resolve(`dist/${name}.runtime.esm-browser.js`),
|
||||
format: 'es'
|
||||
},
|
||||
'global-runtime': {
|
||||
file: resolve(`dist/${name}.runtime.global.js`),
|
||||
format: 'iife'
|
||||
@@ -58,7 +63,7 @@ if (process.env.NODE_ENV === 'production') {
|
||||
if (format === 'cjs' && packageOptions.prod !== false) {
|
||||
packageConfigs.push(createProductionConfig(format))
|
||||
}
|
||||
if (/global/.test(format) || format === 'esm') {
|
||||
if (/^(global|esm-browser)(-runtime)?/.test(format)) {
|
||||
packageConfigs.push(createMinifiedConfig(format))
|
||||
}
|
||||
})
|
||||
@@ -77,10 +82,10 @@ function createConfig(format, output, plugins = []) {
|
||||
|
||||
const isProductionBuild =
|
||||
process.env.__DEV__ === 'false' || /\.prod\.js$/.test(output.file)
|
||||
const isGlobalBuild = /global/.test(format)
|
||||
const isRawESMBuild = format === 'esm'
|
||||
const isNodeBuild = format === 'cjs'
|
||||
const isBundlerESMBuild = /esm-bundler/.test(format)
|
||||
const isBrowserESMBuild = /esm-browser/.test(format)
|
||||
const isNodeBuild = format === 'cjs'
|
||||
const isGlobalBuild = /global/.test(format)
|
||||
|
||||
if (isGlobalBuild) {
|
||||
output.name = packageOptions.name
|
||||
@@ -109,7 +114,7 @@ function createConfig(format, output, plugins = []) {
|
||||
const entryFile = /runtime$/.test(format) ? `src/runtime.ts` : `src/index.ts`
|
||||
|
||||
const external =
|
||||
isGlobalBuild || isRawESMBuild
|
||||
isGlobalBuild || isBrowserESMBuild
|
||||
? []
|
||||
: [
|
||||
...Object.keys(pkg.dependencies || {}),
|
||||
@@ -137,7 +142,7 @@ function createConfig(format, output, plugins = []) {
|
||||
isProductionBuild,
|
||||
isBundlerESMBuild,
|
||||
// isBrowserBuild?
|
||||
(isGlobalBuild || isRawESMBuild || isBundlerESMBuild) &&
|
||||
(isGlobalBuild || isBrowserESMBuild || isBundlerESMBuild) &&
|
||||
!packageOptions.enableNonBrowserBranches,
|
||||
isGlobalBuild,
|
||||
isNodeBuild
|
||||
|
||||
Reference in New Issue
Block a user