featureFlags.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { getGlobalThis } from '@vue/shared'
  2. /**
  3. * This is only called in esm-bundler builds.
  4. * It is called when a renderer is created, in `baseCreateRenderer` so that
  5. * importing runtime-core is side-effects free.
  6. *
  7. * istanbul-ignore-next
  8. */
  9. export function initFeatureFlags() {
  10. const needWarn = []
  11. if (typeof __FEATURE_OPTIONS_API__ !== 'boolean') {
  12. __DEV__ && needWarn.push(`__VUE_OPTIONS_API__`)
  13. getGlobalThis().__VUE_OPTIONS_API__ = true
  14. }
  15. if (typeof __FEATURE_PROD_DEVTOOLS__ !== 'boolean') {
  16. __DEV__ && needWarn.push(`__VUE_PROD_DEVTOOLS__`)
  17. getGlobalThis().__VUE_PROD_DEVTOOLS__ = false
  18. }
  19. if (__DEV__ && needWarn.length) {
  20. const multi = needWarn.length > 1
  21. console.warn(
  22. `Feature flag${multi ? `s` : ``} ${needWarn.join(', ')} ${
  23. multi ? `are` : `is`
  24. } not explicitly defined. You are running the esm-bundler build of Vue, ` +
  25. `which expects these compile-time feature flags to be globally injected ` +
  26. `via the bundler config in order to get better tree-shaking in the ` +
  27. `production bundle.\n\n` +
  28. `For more details, see https://link.vuejs.org/feature-flags.`
  29. )
  30. }
  31. }