chore: improve feature flag warning
This commit is contained in:
parent
1e5a0db4d4
commit
c1cf26d207
@ -8,24 +8,28 @@ import { getGlobalThis } from '@vue/shared'
|
|||||||
* istanbul-ignore-next
|
* istanbul-ignore-next
|
||||||
*/
|
*/
|
||||||
export function initFeatureFlags() {
|
export function initFeatureFlags() {
|
||||||
let needWarn = false
|
const needWarn = []
|
||||||
|
|
||||||
if (typeof __FEATURE_OPTIONS_API__ !== 'boolean') {
|
if (typeof __FEATURE_OPTIONS_API__ !== 'boolean') {
|
||||||
needWarn = true
|
__DEV__ && needWarn.push(`__VUE_OPTIONS_API__`)
|
||||||
getGlobalThis().__VUE_OPTIONS_API__ = true
|
getGlobalThis().__VUE_OPTIONS_API__ = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof __FEATURE_PROD_DEVTOOLS__ !== 'boolean') {
|
if (typeof __FEATURE_PROD_DEVTOOLS__ !== 'boolean') {
|
||||||
needWarn = true
|
__DEV__ && needWarn.push(`__VUE_PROD_DEVTOOLS__`)
|
||||||
getGlobalThis().__VUE_PROD_DEVTOOLS__ = false
|
getGlobalThis().__VUE_PROD_DEVTOOLS__ = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__DEV__ && needWarn) {
|
if (__DEV__ && needWarn.length) {
|
||||||
|
const multi = needWarn.length > 1
|
||||||
console.warn(
|
console.warn(
|
||||||
`You are running the esm-bundler build of Vue. It is recommended to ` +
|
`Feature flag${multi ? `s` : ``} ${needWarn.join(', ')} ${
|
||||||
`configure your bundler to explicitly replace feature flag globals ` +
|
multi ? `are` : `is`
|
||||||
`with boolean literals to get proper tree-shaking in the final bundle. ` +
|
} not explicitly defined. You are running the esm-bundler build of Vue, ` +
|
||||||
`See http://link.vuejs.org/feature-flags for more details.`
|
`which expects these compile-time feature flags to be globally injected ` +
|
||||||
|
`via the bundler config in order to get better tree-shaking in the ` +
|
||||||
|
`production bundle.\n\n` +
|
||||||
|
`For more details, see http://link.vuejs.org/feature-flags.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user