| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import { isRuntimeOnly } from '../component'
- export const enum DeprecationTypes {
- CONFIG_SILENT,
- CONFIG_DEVTOOLS,
- CONFIG_KEY_CODES,
- CONFIG_PRODUCTION_TIP,
- CONFIG_IGNORED_ELEMENTS,
- GLOBAL_PROTOTYPE,
- GLOBAL_SET,
- GLOBAL_DELETE,
- GLOBAL_OBSERVABLE,
- GLOBAL_DOM_TEMPLATE_MOUNT,
- INSTANCE_SET,
- INSTANCE_DELETE,
- INSTANCE_MOUNT,
- INSTANCE_DESTROY
- }
- type DeprecationData = {
- message: string | (() => string)
- link?: string
- }
- const deprecations: Record<DeprecationTypes, DeprecationData> = {
- [DeprecationTypes.CONFIG_SILENT]: {
- message:
- `config.silent has been removed because it is not good practice to ` +
- `intentionally suppress warnings. You can use your browser console's ` +
- `filter features to focus on relevant messages.`
- },
- [DeprecationTypes.CONFIG_DEVTOOLS]: {
- message:
- `config.devtools has been removed. To enable devtools for ` +
- `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
- link: `https://github.com/vuejs/vue-next/tree/master/packages/vue#bundler-build-feature-flags`
- },
- [DeprecationTypes.CONFIG_KEY_CODES]: {
- message:
- `config.keyCodes has been removed. ` +
- `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
- link: `https://v3.vuejs.org/guide/migration/keycode-modifiers.html`
- },
- [DeprecationTypes.CONFIG_PRODUCTION_TIP]: {
- message: `config.productionTip has been removed.`,
- link: `https://v3.vuejs.org/guide/migration/global-api.html#config-productiontip-removed`
- },
- [DeprecationTypes.CONFIG_IGNORED_ELEMENTS]: {
- message: () => {
- let msg = `config.ignoredElements has been removed.`
- if (isRuntimeOnly()) {
- msg += ` Pass the "isCustomElement" option to @vue/compiler-dom instead.`
- } else {
- msg += ` Use config.isCustomElement instead.`
- }
- return msg
- },
- link: `https://v3.vuejs.org/guide/migration/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
- },
- [DeprecationTypes.GLOBAL_PROTOTYPE]: {
- message:
- `Vue.prototype is no longer available in Vue 3. ` +
- `Use config.globalProperties instead.`,
- link: `https://v3.vuejs.org/guide/migration/global-api.html#vue-prototype-replaced-by-config-globalproperties`
- },
- [DeprecationTypes.GLOBAL_SET]: {
- message:
- `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
- `Simply use native JavaScript mutations.`
- },
- [DeprecationTypes.GLOBAL_DELETE]: {
- message:
- `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
- `Simply use native JavaScript mutations.`
- },
- [DeprecationTypes.GLOBAL_OBSERVABLE]: {
- message:
- `Vue.observable() has been removed. ` +
- `Use \`import { reactive } from "vue"\` from Composition API instead.`,
- link: `https://v3.vuejs.org/api/basic-reactivity.html`
- },
- [DeprecationTypes.GLOBAL_DOM_TEMPLATE_MOUNT]: {
- message:
- `Vue detected directives on the mount container. ` +
- `In Vue 3, the container is no longer considered part of the template ` +
- `and will not be processed/replaced.`,
- link: `https://v3.vuejs.org/guide/migration/mount-changes.html`
- },
- [DeprecationTypes.INSTANCE_SET]: {
- message:
- `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
- `Simply use native JavaScript mutations.`
- },
- [DeprecationTypes.INSTANCE_DELETE]: {
- message:
- `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
- `Simply use native JavaScript mutations.`
- },
- [DeprecationTypes.INSTANCE_MOUNT]: {
- message:
- `The global app boostrapping API has changed: vm.$mount() and the "el" ` +
- `option have been removed. Use createApp(RootComponent).mount() instead.`,
- link: `https://v3.vuejs.org/guide/migration/global-api.html#mounting-app-instance`
- },
- [DeprecationTypes.INSTANCE_DESTROY]: {
- message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
- link: `https://v3.vuejs.org/api/application-api.html#unmount`
- }
- }
- export function warnDeprecation(key: DeprecationTypes) {
- if (!__COMPAT__ || !__DEV__) {
- return
- }
- const { message, link } = deprecations[key]
- console.warn(
- `[Vue Deprecation]: ${typeof message === 'function' ? message() : message}${
- link ? `\nFor more details, see ${link}` : ``
- }`
- )
- }
|