diff --git a/packages/runtime-core/src/featureFlags.ts b/packages/runtime-core/src/featureFlags.ts index ee2f1368..e04c352c 100644 --- a/packages/runtime-core/src/featureFlags.ts +++ b/packages/runtime-core/src/featureFlags.ts @@ -8,24 +8,28 @@ import { getGlobalThis } from '@vue/shared' * istanbul-ignore-next */ export function initFeatureFlags() { - let needWarn = false + const needWarn = [] if (typeof __FEATURE_OPTIONS_API__ !== 'boolean') { - needWarn = true + __DEV__ && needWarn.push(`__VUE_OPTIONS_API__`) getGlobalThis().__VUE_OPTIONS_API__ = true } if (typeof __FEATURE_PROD_DEVTOOLS__ !== 'boolean') { - needWarn = true + __DEV__ && needWarn.push(`__VUE_PROD_DEVTOOLS__`) getGlobalThis().__VUE_PROD_DEVTOOLS__ = false } - if (__DEV__ && needWarn) { + if (__DEV__ && needWarn.length) { + const multi = needWarn.length > 1 console.warn( - `You are running the esm-bundler build of Vue. It is recommended to ` + - `configure your bundler to explicitly replace feature flag globals ` + - `with boolean literals to get proper tree-shaking in the final bundle. ` + - `See http://link.vuejs.org/feature-flags for more details.` + `Feature flag${multi ? `s` : ``} ${needWarn.join(', ')} ${ + multi ? `are` : `is` + } not explicitly defined. You are running the esm-bundler build of Vue, ` + + `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.` ) } }