Skip to content

Commit c1cf26d

Browse files
committed
chore: improve feature flag warning
1 parent 1e5a0db commit c1cf26d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

packages/runtime-core/src/featureFlags.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,28 @@ import { getGlobalThis } from '@vue/shared'
88
* istanbul-ignore-next
99
*/
1010
export function initFeatureFlags() {
11-
let needWarn = false
11+
const needWarn = []
1212

1313
if (typeof __FEATURE_OPTIONS_API__ !== 'boolean') {
14-
needWarn = true
14+
__DEV__ && needWarn.push(`__VUE_OPTIONS_API__`)
1515
getGlobalThis().__VUE_OPTIONS_API__ = true
1616
}
1717

1818
if (typeof __FEATURE_PROD_DEVTOOLS__ !== 'boolean') {
19-
needWarn = true
19+
__DEV__ && needWarn.push(`__VUE_PROD_DEVTOOLS__`)
2020
getGlobalThis().__VUE_PROD_DEVTOOLS__ = false
2121
}
2222

23-
if (__DEV__ && needWarn) {
23+
if (__DEV__ && needWarn.length) {
24+
const multi = needWarn.length > 1
2425
console.warn(
25-
`You are running the esm-bundler build of Vue. It is recommended to ` +
26-
`configure your bundler to explicitly replace feature flag globals ` +
27-
`with boolean literals to get proper tree-shaking in the final bundle. ` +
28-
`See http://link.vuejs.org/feature-flags for more details.`
26+
`Feature flag${multi ? `s` : ``} ${needWarn.join(', ')} ${
27+
multi ? `are` : `is`
28+
} not explicitly defined. You are running the esm-bundler build of Vue, ` +
29+
`which expects these compile-time feature flags to be globally injected ` +
30+
`via the bundler config in order to get better tree-shaking in the ` +
31+
`production bundle.\n\n` +
32+
`For more details, see http://link.vuejs.org/feature-flags.`
2933
)
3034
}
3135
}

0 commit comments

Comments
 (0)