Skip to content

Commit

Permalink
fix: refactor nuxt module plugin ts types
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ksem committed May 1, 2023
1 parent 9c5c9af commit 2ab22ec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
15 changes: 15 additions & 0 deletions packages/nuxt/nuxt.shim.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@ declare module '#app' {
export * from 'nuxt/app'
}

declare module '#app/components/nuxt-link' {
export * from 'nuxt/dist/app/components/nuxt-link.ts'
export { default as default } from 'nuxt/dist/app/components/nuxt-link.ts'
}

// Path to vuestic-ui main, so it is not required to build vuestic before working with packages/nuxt
declare module 'vuestci-ui' {
export * from 'vuestic-ui/src/main'
}

declare module '#imports' {
export * from 'nuxt/dist/head/runtime/composables.ts'
}

declare module '#vuestic-config' {
import { GlobalConfig } from 'vuestic-ui'
var gc: GlobalConfig | undefined
export default gc
}
11 changes: 4 additions & 7 deletions packages/nuxt/src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ import {
} from 'vuestic-ui'
import { markRaw, computed } from 'vue'

import type { VuesticOptions } from '../types'
// @ts-ignore: nuxt import alias
import { defineNuxtPlugin } from '#app'
// @ts-ignore: direct nuxt-link import
import { useHead } from '#imports'
import NuxtLink from '#app/components/nuxt-link'
// @ts-ignore: use-config-file import alias
import configFromFile from '#vuestic-config'
// @ts-ignore: use-head import alias
import { useHead } from '#imports'

import type { VuesticOptions } from '../types'

function getGlobalProperty (app, key) {
return app.config.globalProperties[key]
Expand All @@ -32,7 +29,7 @@ export default defineNuxtPlugin((nuxtApp) => {
/** Use tree-shaking by default and do not register any component. Components will be registered by nuxt in use-components. */
app.use(createVuesticEssential({
config: { ...userConfig, routerComponent: markRaw(NuxtLink) },
// TODO: Would be nice to tree-shake plugins, but they're small so we don't cant for now.
// TODO: Would be nice to tree-shake plugins, but they're small so we can let it be for now.
// Should be synced with create-vuestic.ts
plugins: {
BreakpointConfigPlugin,
Expand Down

0 comments on commit 2ab22ec

Please sign in to comment.