2021-10-02 16:59:32 +00:00
|
|
|
import { installModule, useNuxt } from '@nuxt/kit'
|
2021-10-11 08:07:27 +00:00
|
|
|
import autoImports from '../../nuxt3/src/auto-imports/module'
|
2021-10-02 16:59:32 +00:00
|
|
|
|
|
|
|
// TODO: implement these: https://github.com/nuxt/framework/issues/549
|
|
|
|
const disabled = [
|
|
|
|
'useAsyncData',
|
|
|
|
'asyncData'
|
|
|
|
]
|
|
|
|
|
|
|
|
const identifiers = {
|
|
|
|
'#app': [
|
|
|
|
'defineNuxtComponent',
|
|
|
|
'useNuxtApp',
|
|
|
|
'defineNuxtPlugin',
|
|
|
|
'useRoute',
|
2021-10-02 20:30:20 +00:00
|
|
|
'useRouter',
|
|
|
|
'useRuntimeConfig'
|
2021-10-02 16:59:32 +00:00
|
|
|
],
|
2021-10-06 12:37:45 +00:00
|
|
|
'#meta': [
|
|
|
|
'useMeta'
|
|
|
|
],
|
2021-10-02 16:59:32 +00:00
|
|
|
'@vue/composition-api': [
|
|
|
|
// lifecycle
|
|
|
|
'onActivated',
|
|
|
|
'onBeforeMount',
|
|
|
|
'onBeforeUnmount',
|
|
|
|
'onBeforeUpdate',
|
|
|
|
'onDeactivated',
|
|
|
|
'onErrorCaptured',
|
|
|
|
'onMounted',
|
|
|
|
'onServerPrefetch',
|
|
|
|
'onUnmounted',
|
|
|
|
'onUpdated',
|
|
|
|
|
|
|
|
// reactivity,
|
|
|
|
'computed',
|
|
|
|
'customRef',
|
|
|
|
'isReadonly',
|
|
|
|
'isRef',
|
|
|
|
'markRaw',
|
|
|
|
'reactive',
|
|
|
|
'readonly',
|
|
|
|
'ref',
|
|
|
|
'shallowReactive',
|
|
|
|
'shallowReadonly',
|
|
|
|
'shallowRef',
|
|
|
|
'toRaw',
|
|
|
|
'toRef',
|
|
|
|
'toRefs',
|
|
|
|
'triggerRef',
|
|
|
|
'unref',
|
|
|
|
'watch',
|
|
|
|
'watchEffect',
|
|
|
|
|
|
|
|
// component
|
|
|
|
'defineComponent',
|
|
|
|
'defineAsyncComponent',
|
|
|
|
'getCurrentInstance',
|
|
|
|
'h',
|
|
|
|
'inject',
|
|
|
|
'nextTick',
|
|
|
|
'provide',
|
|
|
|
'useCssModule'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultIdentifiers = {}
|
|
|
|
for (const pkg in identifiers) {
|
|
|
|
for (const id of identifiers[pkg]) {
|
|
|
|
defaultIdentifiers[id] = pkg
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 08:07:27 +00:00
|
|
|
export async function setupAutoImports () {
|
2021-10-02 16:59:32 +00:00
|
|
|
const nuxt = useNuxt()
|
2021-10-11 08:07:27 +00:00
|
|
|
nuxt.options.autoImports = nuxt.options.autoImports || {}
|
|
|
|
nuxt.options.autoImports.disabled = nuxt.options.autoImports.disabled || disabled
|
|
|
|
nuxt.options.autoImports.identifiers = Object.assign({}, defaultIdentifiers, nuxt.options.autoImports.identifiers)
|
|
|
|
await installModule(nuxt, autoImports)
|
2021-10-02 16:59:32 +00:00
|
|
|
}
|