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:
Evan You
2020-07-20 21:51:30 -04:00
parent dabdc5e115
commit 54727f9874
15 changed files with 123 additions and 45 deletions

View File

@@ -1,14 +1,14 @@
import { version, setDevtoolsHook } from '@vue/runtime-dom'
import { setDevtoolsHook } from '@vue/runtime-dom'
import { getGlobalThis } from '@vue/shared'
export function initDev() {
const target: any = __BROWSER__ ? window : global
const target = getGlobalThis()
target.__VUE__ = version
target.__VUE__ = true
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__)
if (__BROWSER__) {
// @ts-ignore `console.info` cannot be null error
console[console.info ? 'info' : 'log'](
console.info(
`You are running a development build of Vue.\n` +
`Make sure to use the production build (*.prod.js) when deploying for production.`
)