mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): fully resolve unctx
where possible (#22811)
This commit is contained in:
parent
a352d59a58
commit
9bee320c7a
@ -16,6 +16,7 @@ import importsModule from '../imports/module'
|
||||
import { distDir, pkgDir } from '../dirs'
|
||||
import { version } from '../../package.json'
|
||||
import { ImportProtectionPlugin, vueAppPatterns } from './plugins/import-protection'
|
||||
import type { UnctxTransformPluginOptions } from './plugins/unctx'
|
||||
import { UnctxTransformPlugin } from './plugins/unctx'
|
||||
import type { TreeShakeComposablesPluginOptions } from './plugins/tree-shake'
|
||||
import { TreeShakeComposablesPlugin } from './plugins/tree-shake'
|
||||
@ -110,12 +111,15 @@ async function initNuxt (nuxt: Nuxt) {
|
||||
}))
|
||||
}
|
||||
|
||||
nuxt.hook('modules:done', () => {
|
||||
nuxt.hook('modules:done', async () => {
|
||||
// Add unctx transform
|
||||
const options = {
|
||||
sourcemap: !!nuxt.options.sourcemap.server || !!nuxt.options.sourcemap.client,
|
||||
transformerOptions: nuxt.options.optimization.asyncTransforms
|
||||
}
|
||||
transformerOptions: {
|
||||
...nuxt.options.optimization.asyncTransforms,
|
||||
helperModule: await tryResolveModule('unctx', nuxt.options.modulesDir) ?? 'unctx'
|
||||
}
|
||||
} satisfies UnctxTransformPluginOptions
|
||||
addVitePlugin(() => UnctxTransformPlugin.vite(options))
|
||||
addWebpackPlugin(() => UnctxTransformPlugin.webpack(options))
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { isJS, isVue } from '../utils'
|
||||
|
||||
const TRANSFORM_MARKER = '/* _processed_nuxt_unctx_transform */\n'
|
||||
|
||||
interface UnctxTransformPluginOptions {
|
||||
export interface UnctxTransformPluginOptions {
|
||||
sourcemap?: boolean
|
||||
transformerOptions: TransformerOptions
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user