Add a Nuxt module on top of an existing vue plugin library (without the official module-builder)
Hi everyone!
I have a TypeScript library which has its core implemented as a framework agnostic components (it's actually a repository pattern to connect with my APIs). Inside of this same library I built a Vue Plugin to be able to use this library out of the box inside of any of my Vue SPA applications (I use Vite as bundler btw).
So I can use
Know, as nuxt as a few other constraints that I have to handle like I need to keep the requests within the request context in SSR and manage cookies properly there, I wanted to create a module similarly to what I did with Vue to use like
My problem is that I could not manage to build the library as soon as I add nuxt! I used
Do you guys know any repo that I could get inspired to make this work? Or would anyone be able to guide me trhough that? I considered on creating a new library using the module builder with the
I really appreciate if anyone could shed some light.
The error I was getting while trying to build the application:
I have a TypeScript library which has its core implemented as a framework agnostic components (it's actually a repository pattern to connect with my APIs). Inside of this same library I built a Vue Plugin to be able to use this library out of the box inside of any of my Vue SPA applications (I use Vite as bundler btw).
So I can use
import { anyRepo } from "my-lib" or import { installVuePlugin, useMyLib } from "my-lib/vue" - I could do this by adding Vue as peer deps and externalizing it as I build the library with Vite and I have 2 outputs being the root generic one and the Vue-ish one.Know, as nuxt as a few other constraints that I have to handle like I need to keep the requests within the request context in SSR and manage cookies properly there, I wanted to create a module similarly to what I did with Vue to use like
// nuxtconfig -> modules: ['my-lib/nuxt'].My problem is that I could not manage to build the library as soon as I add nuxt! I used
@nuxt/kit, installed nuxt and @nuxt/schema as dev-deps but it fails while building as inside of my module I need to use things like useRequestFetch and useCookie among others that I need to import from nuxt/app - which leads to an error like nuxt.config.mjs missing... error.Do you guys know any repo that I could get inspired to make this work? Or would anyone be able to guide me trhough that? I considered on creating a new library using the module builder with the
my-lib being used under the hood but this is not a good option for me at the moment!I really appreciate if anyone could shed some light.
The error I was getting while trying to build the application:
