[!WARNING] Work in progress!
A collection of utility functions for Nuxt module authors.
npm i nuxt-module-utils
While Nuxt provides the typescript.hoist
option to generate aliases for nested dependencies within pnpm monorepos, it is processed before modules are set up.
The hoistDependencies
utility allows you to hoist dependencies from within your module's setup
function. It works by resolving the paths of the specified packages and adding them to Nuxt's TypeScript configuration, ensuring they are included in the generated tsconfig.json
.
// src/module.ts
import { defineNuxtModule } from '@nuxt/kit'
import { hoistDependencies } from 'nuxt-module-utils'
export default defineNuxtModule({
async setup() {
await hoistDependencies(['my-lib', 'my-other-lib'])
}
})