build: generate more treeshaking friendly code
This commit is contained in:
parent
a6e5f82d8e
commit
a31303f835
@ -60,12 +60,13 @@ export function renderComponentRoot(
|
||||
} = instance
|
||||
|
||||
let result
|
||||
let fallthroughAttrs
|
||||
const prev = setCurrentRenderingInstance(instance)
|
||||
if (__DEV__) {
|
||||
accessedAttrs = false
|
||||
}
|
||||
|
||||
try {
|
||||
let fallthroughAttrs
|
||||
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
|
||||
// withProxy is a proxy with a different `has` trap only for
|
||||
// runtime-compiled render functions using `with` block.
|
||||
@ -110,6 +111,11 @@ export function renderComponentRoot(
|
||||
? attrs
|
||||
: getFunctionalFallthrough(attrs)
|
||||
}
|
||||
} catch (err) {
|
||||
blockStack.length = 0
|
||||
handleError(err, instance, ErrorCodes.RENDER_FUNCTION)
|
||||
result = createVNode(Comment)
|
||||
}
|
||||
|
||||
// attr merging
|
||||
// in dev mode, comments are preserved, and it's possible for a template
|
||||
@ -227,11 +233,6 @@ export function renderComponentRoot(
|
||||
} else {
|
||||
result = root
|
||||
}
|
||||
} catch (err) {
|
||||
blockStack.length = 0
|
||||
handleError(err, instance, ErrorCodes.RENDER_FUNCTION)
|
||||
result = createVNode(Comment)
|
||||
}
|
||||
|
||||
setCurrentRenderingInstance(prev)
|
||||
return result
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ErrorCodes, callWithErrorHandling } from './errorHandling'
|
||||
import { isArray } from '@vue/shared'
|
||||
import { isArray, NOOP } from '@vue/shared'
|
||||
import { ComponentInternalInstance, getComponentName } from './component'
|
||||
import { warn } from './warning'
|
||||
|
||||
@ -128,10 +128,7 @@ function queueCb(
|
||||
if (!isArray(cb)) {
|
||||
if (
|
||||
!activeQueue ||
|
||||
!activeQueue.includes(
|
||||
cb,
|
||||
cb.allowRecurse ? index + 1 : index
|
||||
)
|
||||
!activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)
|
||||
) {
|
||||
pendingQueue.push(cb)
|
||||
}
|
||||
@ -241,11 +238,20 @@ function flushJobs(seen?: CountMap) {
|
||||
// its update can be skipped.
|
||||
queue.sort((a, b) => getId(a) - getId(b))
|
||||
|
||||
// conditional usage of checkRecursiveUpdate must be determined out of
|
||||
// try ... catch block since Rollup by default de-optimizes treeshaking
|
||||
// inside try-catch. This can leave all warning code unshaked. Although
|
||||
// they would get eventually shaken by a minifier like terser, some minifiers
|
||||
// would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
|
||||
const check = __DEV__
|
||||
? (job: SchedulerJob) => checkRecursiveUpdates(seen!, job)
|
||||
: NOOP
|
||||
|
||||
try {
|
||||
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
||||
const job = queue[flushIndex]
|
||||
if (job && job.active !== false) {
|
||||
if (__DEV__ && checkRecursiveUpdates(seen!, job)) {
|
||||
if (__DEV__ && check(job)) {
|
||||
continue
|
||||
}
|
||||
// console.log(`running:`, job.id)
|
||||
|
Loading…
Reference in New Issue
Block a user