2022-04-17 22:43:58 +00:00
|
|
|
import router from '~/router'
|
|
|
|
import store from '~/store'
|
2022-05-02 15:06:44 +00:00
|
|
|
// @ts-expect-error typescript does not know about configureCompat
|
2022-04-19 19:40:25 +00:00
|
|
|
import { configureCompat, createApp, defineAsyncComponent, h } from 'vue'
|
2022-04-18 18:39:30 +00:00
|
|
|
import useLogger from '~/composables/useLogger'
|
2022-04-23 07:26:25 +00:00
|
|
|
import useTheme from '~/composables/useTheme'
|
2022-05-01 19:57:22 +00:00
|
|
|
|
|
|
|
// NOTE: Set the theme as fast as possible
|
2022-04-23 07:26:25 +00:00
|
|
|
useTheme()
|
2022-04-18 00:40:34 +00:00
|
|
|
|
2022-04-19 19:40:25 +00:00
|
|
|
configureCompat({
|
2022-05-02 08:31:09 +00:00
|
|
|
RENDER_FUNCTION: false,
|
|
|
|
COMPONENT_V_MODEL: false
|
2022-04-19 19:40:25 +00:00
|
|
|
})
|
|
|
|
|
2022-04-18 18:39:30 +00:00
|
|
|
const logger = useLogger()
|
|
|
|
logger.info('Loading environment:', import.meta.env.MODE)
|
|
|
|
logger.debug('Environment variables:', import.meta.env)
|
2022-04-17 22:43:58 +00:00
|
|
|
|
|
|
|
const app = createApp({
|
2022-04-19 19:40:25 +00:00
|
|
|
name: 'Root',
|
|
|
|
data: () => ({ ready: false }),
|
|
|
|
mounted () {
|
|
|
|
this.ready = true
|
2022-04-17 23:24:50 +00:00
|
|
|
},
|
2022-04-19 19:40:25 +00:00
|
|
|
render () {
|
|
|
|
if (this.ready) {
|
|
|
|
return h(defineAsyncComponent(() => import('~/App.vue')))
|
2022-04-17 23:24:50 +00:00
|
|
|
}
|
|
|
|
|
2022-04-19 19:40:25 +00:00
|
|
|
return null
|
2022-04-17 23:24:50 +00:00
|
|
|
}
|
2022-04-17 22:43:58 +00:00
|
|
|
})
|
|
|
|
|
2022-04-18 16:17:51 +00:00
|
|
|
app.use(router)
|
|
|
|
app.use(store)
|
2022-04-17 22:43:58 +00:00
|
|
|
|
2022-05-01 19:57:22 +00:00
|
|
|
const modules: Array<Promise<unknown>> = []
|
2022-04-23 12:10:36 +00:00
|
|
|
for (const module of Object.values(import.meta.globEager('./init/*.ts'))) {
|
2022-04-17 23:24:50 +00:00
|
|
|
modules.push(module.install?.({
|
2022-04-17 22:43:58 +00:00
|
|
|
app,
|
|
|
|
router,
|
|
|
|
store
|
2022-04-17 23:24:50 +00:00
|
|
|
}))
|
2022-04-17 22:43:58 +00:00
|
|
|
}
|
|
|
|
|
2022-04-18 18:39:30 +00:00
|
|
|
// Wait for all modules to load
|
|
|
|
Promise.all(modules).finally(() => {
|
2022-04-17 22:43:58 +00:00
|
|
|
app.mount('#app')
|
2022-04-18 18:39:30 +00:00
|
|
|
logger.info('Everything loaded!')
|
2022-04-17 22:43:58 +00:00
|
|
|
})
|
2022-05-01 15:06:01 +00:00
|
|
|
|
|
|
|
// TODO (wvffle): Check for mixin merging: https://v3-migration.vuejs.org/breaking-changes/data-option.html#mixin-merge-behavior-change=
|
|
|
|
// TODO (wvffle): Use emits options: https://v3-migration.vuejs.org/breaking-changes/emits-option.html
|
2022-05-02 08:25:37 +00:00
|
|
|
// TODO (wvffle): Find all array watchers and make them deep
|
2022-05-01 15:17:12 +00:00
|
|
|
// TODO (wvffle): Migrate to <script setup>
|
2022-05-01 16:46:27 +00:00
|
|
|
// TODO (wvffle): Replace `from '(../)+` with `from '~/`
|