build: further shave off runtime compile only code

This commit is contained in:
Evan You
2019-10-14 01:08:00 -04:00
parent 57a94b530d
commit 82b5978e9c
7 changed files with 36 additions and 17 deletions

View File

@@ -76,6 +76,7 @@ function createConfig(output, plugins = []) {
const isGlobalBuild = /\.global(\.prod)?\.js$/.test(output.file)
const isBundlerESMBuild = /\.esm\.js$/.test(output.file)
const isBrowserESMBuild = /esm-browser(\.prod)?\.js$/.test(output.file)
const isRuntimeCompileBuild = /^dist\/vue\./.test(output.file)
if (isGlobalBuild) {
output.name = packageOptions.name
@@ -120,7 +121,8 @@ function createConfig(output, plugins = []) {
isProductionBuild,
isBundlerESMBuild,
(isGlobalBuild || isBrowserESMBuild) &&
!packageOptions.enableNonBrowserBranches
!packageOptions.enableNonBrowserBranches,
isRuntimeCompileBuild
),
...plugins
],
@@ -133,7 +135,12 @@ function createConfig(output, plugins = []) {
}
}
function createReplacePlugin(isProduction, isBundlerESMBuild, isBrowserBuild) {
function createReplacePlugin(
isProduction,
isBundlerESMBuild,
isBrowserBuild,
isRuntimeCompileBuild
) {
return replace({
__COMMIT__: `"${process.env.COMMIT}"`,
__DEV__: isBundlerESMBuild
@@ -143,9 +150,11 @@ function createReplacePlugin(isProduction, isBundlerESMBuild, isBrowserBuild) {
!isProduction,
// If the build is expected to run directly in the browser (global / esm-browser builds)
__BROWSER__: isBrowserBuild,
// support compile in browser?
__RUNTIME_COMPILE__: isRuntimeCompileBuild,
// support options?
// the lean build drops options related code with buildOptions.lean: true
__FEATURE_OPTIONS__: !packageOptions.lean,
__FEATURE_OPTIONS__: !packageOptions.lean && !process.env.LEAN,
__FEATURE_SUSPENSE__: true,
// this is only used during tests
__JSDOM__: false