build: drop unnecessary codegen branch for global build
This commit is contained in:
parent
0f67aa7da5
commit
c44d9fbe3d
@ -187,7 +187,7 @@ export function generate(
|
|||||||
const genScopeId = !__BROWSER__ && scopeId != null && mode === 'module'
|
const genScopeId = !__BROWSER__ && scopeId != null && mode === 'module'
|
||||||
|
|
||||||
// preambles
|
// preambles
|
||||||
if (mode === 'module') {
|
if (!__BROWSER__ && mode === 'module') {
|
||||||
genModulePreamble(ast, context, genScopeId)
|
genModulePreamble(ast, context, genScopeId)
|
||||||
} else {
|
} else {
|
||||||
genFunctionPreamble(ast, context)
|
genFunctionPreamble(ast, context)
|
||||||
@ -222,7 +222,7 @@ export function generate(
|
|||||||
}
|
}
|
||||||
newline()
|
newline()
|
||||||
}
|
}
|
||||||
} else if (!ssr) {
|
} else if (!__BROWSER__ && !ssr) {
|
||||||
push(`const _ctx = this`)
|
push(`const _ctx = this`)
|
||||||
if (ast.cached > 0) {
|
if (ast.cached > 0) {
|
||||||
newline()
|
newline()
|
||||||
@ -289,7 +289,8 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
|
|||||||
runtimeModuleName,
|
runtimeModuleName,
|
||||||
runtimeGlobalName
|
runtimeGlobalName
|
||||||
} = context
|
} = context
|
||||||
const VueBinding = ssr
|
const VueBinding =
|
||||||
|
!__BROWSER__ && ssr
|
||||||
? `require(${JSON.stringify(runtimeModuleName)})`
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
||||||
: runtimeGlobalName
|
: runtimeGlobalName
|
||||||
// Generate const declaration for helpers
|
// Generate const declaration for helpers
|
||||||
@ -297,7 +298,7 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
|
|||||||
// only once; But if we not prefixing, we place the declaration inside the
|
// only once; But if we not prefixing, we place the declaration inside the
|
||||||
// with block so it doesn't incur the `in` check cost for every helper access.
|
// with block so it doesn't incur the `in` check cost for every helper access.
|
||||||
if (ast.helpers.length > 0) {
|
if (ast.helpers.length > 0) {
|
||||||
if (prefixIdentifiers) {
|
if (!__BROWSER__ && prefixIdentifiers) {
|
||||||
push(`const { ${ast.helpers.map(helper).join(', ')} } = ${VueBinding}\n`)
|
push(`const { ${ast.helpers.map(helper).join(', ')} } = ${VueBinding}\n`)
|
||||||
} else {
|
} else {
|
||||||
// "with" mode.
|
// "with" mode.
|
||||||
@ -336,7 +337,7 @@ function genModulePreamble(
|
|||||||
) {
|
) {
|
||||||
const { push, helper, newline, scopeId, runtimeModuleName } = context
|
const { push, helper, newline, scopeId, runtimeModuleName } = context
|
||||||
|
|
||||||
if (!__BROWSER__ && genScopeId) {
|
if (genScopeId) {
|
||||||
ast.helpers.push(WITH_SCOPE_ID)
|
ast.helpers.push(WITH_SCOPE_ID)
|
||||||
if (ast.hoists.length) {
|
if (ast.hoists.length) {
|
||||||
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID)
|
ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID)
|
||||||
@ -352,7 +353,6 @@ function genModulePreamble(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!__BROWSER__) {
|
|
||||||
if (ast.ssrHelpers && ast.ssrHelpers.length) {
|
if (ast.ssrHelpers && ast.ssrHelpers.length) {
|
||||||
push(
|
push(
|
||||||
`import { ${ast.ssrHelpers
|
`import { ${ast.ssrHelpers
|
||||||
@ -360,15 +360,16 @@ function genModulePreamble(
|
|||||||
.join(', ')} } from "@vue/server-renderer"\n`
|
.join(', ')} } from "@vue/server-renderer"\n`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast.imports.length) {
|
if (ast.imports.length) {
|
||||||
genImports(ast.imports, context)
|
genImports(ast.imports, context)
|
||||||
newline()
|
newline()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (genScopeId) {
|
if (genScopeId) {
|
||||||
push(`const withId = ${helper(WITH_SCOPE_ID)}("${scopeId}")`)
|
push(`const withId = ${helper(WITH_SCOPE_ID)}("${scopeId}")`)
|
||||||
newline()
|
newline()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
genHoists(ast.hoists, context)
|
genHoists(ast.hoists, context)
|
||||||
newline()
|
newline()
|
||||||
|
Loading…
Reference in New Issue
Block a user