feat: provide ability to overwrite feature flags in esm-bundler builds
e.g. by replacing `__VUE_OPTIONS_API__` to `false` using webpack's `DefinePlugin`, the final bundle will drop all code supporting the options API. This does not break existing usage, but requires the user to explicitly configure the feature flags via bundlers to properly tree-shake the disabled branches. As a result, users will see a console warning if the flags have not been properly configured.
This commit is contained in:
@@ -64,7 +64,8 @@ import { createHydrationFunctions, RootHydrateFunction } from './hydration'
|
||||
import { invokeDirectiveHook } from './directives'
|
||||
import { startMeasure, endMeasure } from './profiling'
|
||||
import { ComponentPublicInstance } from './componentProxy'
|
||||
import { componentRemoved, componentUpdated } from './devtools'
|
||||
import { devtoolsComponentRemoved, devtoolsComponentUpdated } from './devtools'
|
||||
import { initFeatureFlags } from './featureFlags'
|
||||
|
||||
export interface Renderer<HostElement = RendererElement> {
|
||||
render: RootRenderFunction<HostElement>
|
||||
@@ -383,6 +384,11 @@ function baseCreateRenderer(
|
||||
options: RendererOptions,
|
||||
createHydrationFns?: typeof createHydrationFunctions
|
||||
): any {
|
||||
// compile-time feature flags check
|
||||
if (__ESM_BUNDLER__ && !__TEST__) {
|
||||
initFeatureFlags()
|
||||
}
|
||||
|
||||
const {
|
||||
insert: hostInsert,
|
||||
remove: hostRemove,
|
||||
@@ -1393,9 +1399,13 @@ function baseCreateRenderer(
|
||||
invokeVNodeHook(vnodeHook!, parent, next!, vnode)
|
||||
}, parentSuspense)
|
||||
}
|
||||
|
||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||
devtoolsComponentUpdated(instance)
|
||||
}
|
||||
|
||||
if (__DEV__) {
|
||||
popWarningContext()
|
||||
componentUpdated(instance)
|
||||
}
|
||||
}
|
||||
}, __DEV__ ? createDevEffectOptions(instance) : prodEffectOptions)
|
||||
@@ -2046,7 +2056,9 @@ function baseCreateRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
__DEV__ && componentRemoved(instance)
|
||||
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
|
||||
devtoolsComponentRemoved(instance)
|
||||
}
|
||||
}
|
||||
|
||||
const unmountChildren: UnmountChildrenFn = (
|
||||
|
||||
Reference in New Issue
Block a user