Skip to content

Commit

Permalink
fix: add implicit imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 3, 2022
1 parent 6f2a430 commit db0934c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default defineNuxtConfig({
buildModules: [
'../src/module'
],
imports: {
autoImport: false
},
image: {
domains: [
'https://nuxtjs.org',
Expand Down
2 changes: 2 additions & 0 deletions playground/pages/bg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
</template>

<script lang="ts" setup>
import { useImage, computed } from '#imports'
const $img = useImage()
const bg = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/components/nuxt-img.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h, defineComponent } from 'vue'
import { h, defineComponent, ref, computed, onMounted } from 'vue'
import { useImage } from '../composables'
import { parseSize } from '../utils'
import { baseImageProps, useBaseImage } from './_base'
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/components/nuxt-picture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { h, defineComponent } from 'vue'
import { h, defineComponent, computed } from 'vue'
import { useBaseImage, baseImageProps } from './_base'
import { useHead } from '#imports'
import { useImage, useHead } from '#imports'
import { getFileExtension } from '#image'

export const pictureProps = {
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/composables.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useNuxtApp } from '#imports'

export const useImage = () => {
return useNuxtApp().$img
}

0 comments on commit db0934c

Please sign in to comment.