Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85166cc

Browse files
committed
feat(schema): allow configuring type hoists with typescript.hoist
1 parent 9d08cdf commit 85166cc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/nuxt/src/core/nuxt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function initNuxt (nuxt: Nuxt) {
6363
nuxtCtx.set(nuxt)
6464
nuxt.hook('close', () => nuxtCtx.unset())
6565

66-
const coreTypePackages = ['nitropack', 'defu', 'h3', '@unhead/vue', 'vue', 'vue-router', '@nuxt/schema']
66+
const coreTypePackages = nuxt.options.typescript.hoist || []
6767
const paths = Object.fromEntries(await Promise.all(coreTypePackages.map(async (pkg) => {
6868
const path = await _resolvePath(pkg, { url: nuxt.options.modulesDir }).then(r => resolvePackageJSON(r)).catch(() => null)
6969
if (!path) { return }

packages/schema/src/config/typescript.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ export default defineUntypedSchema({
2626
$resolve: val => val ?? null
2727
},
2828

29+
/**
30+
* Modules to generate deep aliases for within `compilerOptions.paths`. This does not yet support subpaths.
31+
* It may be necessary when using Nuxt within a pnpm monorepo with `shamefully-hoist=false`.
32+
*/
33+
hoist: {
34+
$resolve: (val) => {
35+
const defaults = ['nitropack', 'defu', 'h3', '@unhead/vue', 'vue', 'vue-router', '@nuxt/schema']
36+
return val === false ? [] : (Array.isArray(val) ? val.concat(defaults) : defaults)
37+
}
38+
},
39+
2940
/**
3041
* Include parent workspace in the Nuxt project. Mostly useful for themes and module authors.
3142
*/

0 commit comments

Comments
 (0)