Skip to content

Commit

Permalink
feat(schema): allow configuring type hoists with typescript.hoist
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 15, 2024
1 parent 9d08cdf commit 85166cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/nuxt/src/core/nuxt.ts
Expand Up @@ -63,7 +63,7 @@ async function initNuxt (nuxt: Nuxt) {
nuxtCtx.set(nuxt)
nuxt.hook('close', () => nuxtCtx.unset())

const coreTypePackages = ['nitropack', 'defu', 'h3', '@unhead/vue', 'vue', 'vue-router', '@nuxt/schema']
const coreTypePackages = nuxt.options.typescript.hoist || []
const paths = Object.fromEntries(await Promise.all(coreTypePackages.map(async (pkg) => {
const path = await _resolvePath(pkg, { url: nuxt.options.modulesDir }).then(r => resolvePackageJSON(r)).catch(() => null)
if (!path) { return }
Expand Down
11 changes: 11 additions & 0 deletions packages/schema/src/config/typescript.ts
Expand Up @@ -26,6 +26,17 @@ export default defineUntypedSchema({
$resolve: val => val ?? null
},

/**
* Modules to generate deep aliases for within `compilerOptions.paths`. This does not yet support subpaths.
* It may be necessary when using Nuxt within a pnpm monorepo with `shamefully-hoist=false`.
*/
hoist: {
$resolve: (val) => {
const defaults = ['nitropack', 'defu', 'h3', '@unhead/vue', 'vue', 'vue-router', '@nuxt/schema']
return val === false ? [] : (Array.isArray(val) ? val.concat(defaults) : defaults)
}
},

/**
* Include parent workspace in the Nuxt project. Mostly useful for themes and module authors.
*/
Expand Down

0 comments on commit 85166cc

Please sign in to comment.