build: add browser builds for @vue/compiler-sfc
This commit is contained in:
@@ -60,7 +60,10 @@ const packageConfigs = process.env.PROD_ONLY
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
packageFormats.forEach(format => {
|
||||
if (format === 'cjs' && packageOptions.prod !== false) {
|
||||
if (packageOptions.prod === false) {
|
||||
return
|
||||
}
|
||||
if (format === 'cjs') {
|
||||
packageConfigs.push(createProductionConfig(format))
|
||||
}
|
||||
if (/^(global|esm-browser)(-runtime)?/.test(format)) {
|
||||
@@ -115,18 +118,39 @@ function createConfig(format, output, plugins = []) {
|
||||
|
||||
const external =
|
||||
isGlobalBuild || isBrowserESMBuild
|
||||
? []
|
||||
: [
|
||||
? packageOptions.enableNonBrowserBranches
|
||||
? // externalize postcss for @vue/compiler-sfc
|
||||
// because @rollup/plugin-commonjs cannot bundle it properly
|
||||
['postcss']
|
||||
: // normal browser builds - non-browser only imports are tree-shaken,
|
||||
// they are only listed here to suppress warnings.
|
||||
['source-map', '@babel/parser', 'estree-walker']
|
||||
: // Node / esm-bundler builds. Externalize everything.
|
||||
[
|
||||
...Object.keys(pkg.dependencies || {}),
|
||||
...Object.keys(pkg.peerDependencies || {})
|
||||
...Object.keys(pkg.peerDependencies || {}),
|
||||
'url' // for @vue/compiler-sfc
|
||||
]
|
||||
|
||||
const nodePlugins = packageOptions.enableNonBrowserBranches
|
||||
? [
|
||||
require('@rollup/plugin-node-resolve')(),
|
||||
require('@rollup/plugin-commonjs')()
|
||||
]
|
||||
: []
|
||||
// the browser builds of @vue/compiler-sfc requires postcss to be available
|
||||
// as a global (e.g. http://wzrd.in/standalone/postcss)
|
||||
output.globals = {
|
||||
postcss: 'postcss'
|
||||
}
|
||||
|
||||
const nodePlugins =
|
||||
packageOptions.enableNonBrowserBranches && format !== 'cjs'
|
||||
? [
|
||||
require('@rollup/plugin-node-resolve')({
|
||||
preferBuiltins: true
|
||||
}),
|
||||
require('@rollup/plugin-commonjs')({
|
||||
sourceMap: false
|
||||
}),
|
||||
require('rollup-plugin-node-builtins')(),
|
||||
require('rollup-plugin-node-globals')()
|
||||
]
|
||||
: []
|
||||
|
||||
return {
|
||||
input: resolve(entryFile),
|
||||
@@ -156,6 +180,9 @@ function createConfig(format, output, plugins = []) {
|
||||
if (!/Circular/.test(msg)) {
|
||||
warn(msg)
|
||||
}
|
||||
},
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user