Skip to content

Commit 0479e69

Browse files
committedOct 30, 2024
fix: rework path aliases
1 parent 9d99d54 commit 0479e69

File tree

13 files changed

+37
-14
lines changed

13 files changed

+37
-14
lines changed
 

‎src/module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export default defineNuxtModule<ModuleOptions>({
199199
logger.warn('Nuxt OG Image is enabled but SSR is disabled.\n\nYou should enable SSR (`ssr: true`) or disable the module (`ogImage: { enabled: false }`).')
200200
return
201201
}
202-
nuxt.options.alias['#nuxt-og-image-utils'] = resolve('./runtime/shared')
202+
nuxt.options.alias['#nuxt-og-image'] = resolve('./runtime')
203203
nuxt.options.alias['#nuxt-og-image-cache'] = resolve('./runtime/nitro/og-image/cache/lru')
204204

205205
const preset = resolveNitroPreset(nuxt.options.nitro)
@@ -491,7 +491,7 @@ export default defineNuxtModule<ModuleOptions>({
491491
options: { mode: 'server' },
492492
})
493493
nuxt.options.nitro.virtual = nuxt.options.nitro.virtual || {}
494-
nuxt.options.nitro.virtual['#nuxt-og-image/component-names.mjs'] = () => {
494+
nuxt.options.nitro.virtual['#nuxt-og-image-virtual/component-names.mjs'] = () => {
495495
return `export const componentNames = ${JSON.stringify(ogImageComponentCtx.components)}`
496496
}
497497

@@ -505,7 +505,7 @@ export default defineNuxtModule<ModuleOptions>({
505505
nuxt.hook('unocss:config', (_unoCssConfig) => {
506506
unoCssConfig = { ..._unoCssConfig.theme }
507507
})
508-
nuxt.options.nitro.virtual['#nuxt-og-image/unocss-config.mjs'] = () => {
508+
nuxt.options.nitro.virtual['#nuxt-og-image-virtual/unocss-config.mjs'] = () => {
509509
return `export const theme = ${JSON.stringify(unoCssConfig)}`
510510
}
511511

‎src/runtime/nitro/og-image/context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type {
66
} from '../../types'
77
import type ChromiumRenderer from './chromium/renderer'
88
import type SatoriRenderer from './satori/renderer'
9+
import { useNitroApp } from '#imports'
910
import { htmlPayloadCache, prerenderOptionsCache } from '#nuxt-og-image-cache'
1011
import { defu } from 'defu'
1112
import { parse } from 'devalue'
1213
import { createError, getQuery } from 'h3'
13-
import { useNitroApp } from 'nitropack/runtime/app'
1414
import { hash } from 'ohash'
1515
import { parseURL, withoutLeadingSlash, withoutTrailingSlash, withQuery } from 'ufo'
1616
import { normalizeKey } from 'unstorage'

‎src/runtime/nitro/og-image/satori/plugins/unocss.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { VNode } from '../../../../types'
2-
import { theme } from '#nuxt-og-image/unocss-config.mjs'
2+
import { theme } from '#nuxt-og-image/virtual/unocss-config.mjs'
33
import { createGenerator } from '@unocss/core'
44
import presetWind from '@unocss/preset-wind'
55
import { defineSatoriTransformer } from '../utils'

‎src/runtime/nitro/og-image/satori/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { SatoriOptions } from 'satori'
22
import type { OgImageRenderEventContext, Renderer, ResolvedFontConfig } from '../../../types'
3-
import { theme } from '#nuxt-og-image/unocss-config.mjs'
3+
import { theme } from '#nuxt-og-image/virtual/unocss-config.mjs'
44
import { fontCache } from '#nuxt-og-image-cache'
55
import { defu } from 'defu'
66
import { normaliseFontInput, useOgImageRuntimeConfig } from '../../../shared'

‎src/runtime/nitro/og-image/templates/html.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FontConfig, OgImageRenderEventContext } from '../../../types'
2-
import { theme } from '#nuxt-og-image/unocss-config.mjs'
2+
import { theme } from '#nuxt-og-image/virtual/unocss-config.mjs'
33
import { renderSSRHead } from '@unhead/ssr'
44
import { createHeadCore } from '@unhead/vue'
55
import { createError } from 'h3'

‎src/runtime/nitro/plugins/__zero-runtime/nuxt-content.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineNitroPlugin } from 'nitropack/dist/runtime/plugin'
1+
import { defineNitroPlugin } from '#imports'
22
import { nuxtContentPlugin } from '../../util/plugins'
33

44
export default defineNitroPlugin((nitroApp) => {

‎src/runtime/nitro/plugins/nuxt-content.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineNitroPlugin } from 'nitropack/dist/runtime/plugin'
1+
import { defineNitroPlugin } from '#imports'
22
import { nuxtContentPlugin } from '../util/plugins'
33

44
export default defineNitroPlugin((nitroApp) => {

‎src/runtime/nitro/plugins/prerender.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { defineNitroPlugin } from '#imports'
12
import { prerenderOptionsCache } from '#nuxt-og-image-cache'
2-
import { defineNitroPlugin } from 'nitropack/dist/runtime/plugin'
33
import { parseURL } from 'ufo'
44
import { isInternalRoute } from '../../pure'
55
import { extractAndNormaliseOgImageOptions, resolvePathCacheKey } from '../og-image/context'

‎src/runtime/nitro/routes/debug.json.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-expect-error virtual module
22
import compatibility from '#nuxt-og-image/compatibility'
33
// @ts-expect-error untyped
4-
import { componentNames } from '#nuxt-og-image/component-names.mjs'
4+
import { componentNames } from '#nuxt-og-image-virtual/component-names.mjs'
55

66
import { defineEventHandler, setHeader } from 'h3'
77

‎src/runtime/nitro/util/options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DefineOgImageInput, OgImageOptions, OgImagePrebuilt } from '../../types'
22
// @ts-expect-error untyped
3-
import { componentNames } from '#nuxt-og-image/component-names.mjs'
3+
import { componentNames } from '#nuxt-og-image-virtual/component-names.mjs'
44

55
export function normaliseOptions(_options: DefineOgImageInput): OgImageOptions | OgImagePrebuilt {
66
const options = { ..._options } as OgImageOptions

‎src/runtime/nuxt/components/Templates/Community/NuxtSeo.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
66
import { useSiteConfig } from '#imports'
7-
import { useOgImageRuntimeConfig } from '#nuxt-og-image-utils'
7+
import { useOgImageRuntimeConfig } from '#nuxt-og-image/shared'
88
import { computed, defineComponent, h, resolveComponent } from 'vue'
99
1010
// convert to typescript props

‎test/fixtures/zero-runtime/components/OgImage/0.NuxtSeo.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
66
import { useSiteConfig } from '#imports'
7-
import { useOgImageRuntimeConfig } from '#nuxt-og-image-utils'
7+
import { useOgImageRuntimeConfig } from '#nuxt-og-image/shared'
88
import { computed, defineComponent, h, resolveComponent } from 'vue'
99
1010
// convert to typescript props

‎virtual.d.ts

+23
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,26 @@ declare module '#nuxt-og-image/bindings/sharp' {
4747
const sharp: _sharp
4848
export default sharp
4949
}
50+
51+
declare module '#nuxt-og-image-virtual/component-names.mjs' {
52+
const componentNames: string[]
53+
export default componentNames
54+
}
55+
56+
declare module '#nuxt-og-image-virtual/unocss-config.mjs' {
57+
const theme: Record<string, any>
58+
export default theme
59+
}
60+
61+
declare module '#nuxt-og-image-cache' {
62+
import type { OgImageOptions } from '#nuxt-og-image/types'
63+
import type { Storage } from 'unstorage'
64+
65+
export const htmlPayloadCache: Storage<{ expiresAt: number, value: OgImageOptions }>
66+
67+
export const prerenderOptionsCache: Storage<OgImageOptions> | undefined
68+
69+
export const fontCache: Storage<BufferSource> | undefined
70+
71+
export const emojiCache: Storage<string>
72+
}

0 commit comments

Comments
 (0)
Please sign in to comment.