build: improve treeshakeability (#5682)
This commit is contained in:
parent
053c65bc5e
commit
c6eb3cccce
@ -35,6 +35,7 @@ import { warn } from './warning'
|
|||||||
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`)
|
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`)
|
||||||
|
|
||||||
const builtInSymbols = new Set(
|
const builtInSymbols = new Set(
|
||||||
|
/*#__PURE__*/
|
||||||
Object.getOwnPropertyNames(Symbol)
|
Object.getOwnPropertyNames(Symbol)
|
||||||
.map(key => (Symbol as any)[key])
|
.map(key => (Symbol as any)[key])
|
||||||
.filter(isSymbol)
|
.filter(isSymbol)
|
||||||
|
@ -4,7 +4,7 @@ import { ComputedGetter, ComputedRef } from './computed'
|
|||||||
import { ReactiveFlags, toRaw } from './reactive'
|
import { ReactiveFlags, toRaw } from './reactive'
|
||||||
import { trackRefValue, triggerRefValue } from './ref'
|
import { trackRefValue, triggerRefValue } from './ref'
|
||||||
|
|
||||||
const tick = Promise.resolve()
|
const tick = /*#__PURE__*/ Promise.resolve()
|
||||||
const queue: any[] = []
|
const queue: any[] = []
|
||||||
let queued = false
|
let queued = false
|
||||||
|
|
||||||
|
@ -223,9 +223,10 @@ const getPublicInstance = (
|
|||||||
return getPublicInstance(i.parent)
|
return getPublicInstance(i.parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const publicPropertiesMap: PublicPropertiesMap = /*#__PURE__*/ extend(
|
export const publicPropertiesMap: PublicPropertiesMap =
|
||||||
Object.create(null),
|
// Move PURE marker to new line to workaround compiler discarding it
|
||||||
{
|
// due to type annotation
|
||||||
|
/*#__PURE__*/ extend(Object.create(null), {
|
||||||
$: i => i,
|
$: i => i,
|
||||||
$el: i => i.vnode.el,
|
$el: i => i.vnode.el,
|
||||||
$data: i => i.data,
|
$data: i => i.data,
|
||||||
@ -240,8 +241,7 @@ export const publicPropertiesMap: PublicPropertiesMap = /*#__PURE__*/ extend(
|
|||||||
$forceUpdate: i => () => queueJob(i.update),
|
$forceUpdate: i => () => queueJob(i.update),
|
||||||
$nextTick: i => nextTick.bind(i.proxy!),
|
$nextTick: i => nextTick.bind(i.proxy!),
|
||||||
$watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP)
|
$watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP)
|
||||||
} as PublicPropertiesMap
|
} as PublicPropertiesMap)
|
||||||
)
|
|
||||||
|
|
||||||
if (__COMPAT__) {
|
if (__COMPAT__) {
|
||||||
installCompatInstanceProperties(publicPropertiesMap)
|
installCompatInstanceProperties(publicPropertiesMap)
|
||||||
@ -456,8 +456,8 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
|
|||||||
) {
|
) {
|
||||||
if (descriptor.get != null) {
|
if (descriptor.get != null) {
|
||||||
// invalidate key cache of a getter based property #5417
|
// invalidate key cache of a getter based property #5417
|
||||||
target.$.accessCache[key] = 0;
|
target.$.accessCache[key] = 0
|
||||||
} else if (hasOwn(descriptor,'value')) {
|
} else if (hasOwn(descriptor, 'value')) {
|
||||||
this.set!(target, key, descriptor.value, null)
|
this.set!(target, key, descriptor.value, null)
|
||||||
}
|
}
|
||||||
return Reflect.defineProperty(target, key, descriptor)
|
return Reflect.defineProperty(target, key, descriptor)
|
||||||
|
@ -47,7 +47,7 @@ const pendingPostFlushCbs: SchedulerJob[] = []
|
|||||||
let activePostFlushCbs: SchedulerJob[] | null = null
|
let activePostFlushCbs: SchedulerJob[] | null = null
|
||||||
let postFlushIndex = 0
|
let postFlushIndex = 0
|
||||||
|
|
||||||
const resolvedPromise: Promise<any> = Promise.resolve()
|
const resolvedPromise = /*#__PURE__*/ Promise.resolve() as Promise<any>
|
||||||
let currentFlushPromise: Promise<void> | null = null
|
let currentFlushPromise: Promise<void> | null = null
|
||||||
|
|
||||||
let currentPreFlushParentJob: SchedulerJob | null = null
|
let currentPreFlushParentJob: SchedulerJob | null = null
|
||||||
|
@ -31,7 +31,7 @@ declare module '@vue/reactivity' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rendererOptions = extend({ patchProp }, nodeOps)
|
const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps)
|
||||||
|
|
||||||
// lazy create the renderer - this makes core renderer logic tree-shakable
|
// lazy create the renderer - this makes core renderer logic tree-shakable
|
||||||
// in case the user only imports reactivity utilities from Vue.
|
// in case the user only imports reactivity utilities from Vue.
|
||||||
|
@ -13,31 +13,32 @@ interface Invoker extends EventListener {
|
|||||||
type EventValue = Function | Function[]
|
type EventValue = Function | Function[]
|
||||||
|
|
||||||
// Async edge case fix requires storing an event listener's attach timestamp.
|
// Async edge case fix requires storing an event listener's attach timestamp.
|
||||||
let _getNow: () => number = Date.now
|
const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
|
||||||
|
let _getNow = Date.now
|
||||||
let skipTimestampCheck = false
|
let skipTimestampCheck = false
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
if (typeof window !== 'undefined') {
|
// Determine what event timestamp the browser is using. Annoyingly, the
|
||||||
// Determine what event timestamp the browser is using. Annoyingly, the
|
// timestamp can either be hi-res (relative to page load) or low-res
|
||||||
// timestamp can either be hi-res (relative to page load) or low-res
|
// (relative to UNIX epoch), so in order to compare time we have to use the
|
||||||
// (relative to UNIX epoch), so in order to compare time we have to use the
|
// same timestamp type when saving the flush timestamp.
|
||||||
// same timestamp type when saving the flush timestamp.
|
if (Date.now() > document.createEvent('Event').timeStamp) {
|
||||||
if (_getNow() > document.createEvent('Event').timeStamp) {
|
// if the low-res timestamp which is bigger than the event timestamp
|
||||||
// if the low-res timestamp which is bigger than the event timestamp
|
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
|
||||||
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
|
// and we need to use the hi-res version for event listeners as well.
|
||||||
// and we need to use the hi-res version for event listeners as well.
|
_getNow = () => performance.now()
|
||||||
_getNow = () => performance.now()
|
}
|
||||||
|
// #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
|
||||||
|
// and does not fire microtasks in between event propagation, so safe to exclude.
|
||||||
|
const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i)
|
||||||
|
skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53)
|
||||||
}
|
}
|
||||||
// #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
|
return [_getNow, skipTimestampCheck]
|
||||||
// and does not fire microtasks in between event propagation, so safe to exclude.
|
})()
|
||||||
const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i)
|
|
||||||
skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53)
|
|
||||||
}
|
|
||||||
|
|
||||||
// To avoid the overhead of repeatedly calling performance.now(), we cache
|
// To avoid the overhead of repeatedly calling performance.now(), we cache
|
||||||
// and use the same timestamp for all event listeners attached in the same tick.
|
// and use the same timestamp for all event listeners attached in the same tick.
|
||||||
let cachedNow: number = 0
|
let cachedNow: number = 0
|
||||||
const p = Promise.resolve()
|
const p = /*#__PURE__*/ Promise.resolve()
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
cachedNow = 0
|
cachedNow = 0
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ export const svgNS = 'http://www.w3.org/2000/svg'
|
|||||||
|
|
||||||
const doc = (typeof document !== 'undefined' ? document : null) as Document
|
const doc = (typeof document !== 'undefined' ? document : null) as Document
|
||||||
|
|
||||||
const templateContainer = doc && doc.createElement('template')
|
const templateContainer = doc && /*#__PURE__*/ doc.createElement('template')
|
||||||
|
|
||||||
export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
|
export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
|
||||||
insert: (child, parent, anchor) => {
|
insert: (child, parent, anchor) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user