N
Nuxt2w ago
Yan

Nuxt with PM2 and TypeScript

I have a project with a Nuxt application and PM2. For the PM2 application we have a file named worker.cjs. I turned this into a TypeScript file, so that I can leverage the types we have from our Supabase database. I am trying to have it compiled when Nuxt builds, so I've added an extra tsconfig as composite. Does somebody have experience with this?
TS6305: Output file '/dist/workers/worker.d.ts' has not been built from source file '/workers/worker.ts'.
The file is in the program because:
Matched by include pattern '.nuxt/../**/*' in '/tsconfig.json'
TS6305: Output file '/dist/workers/worker.d.ts' has not been built from source file '/workers/worker.ts'.
The file is in the program because:
Matched by include pattern '.nuxt/../**/*' in '/tsconfig.json'
2 Replies
kapa.ai
kapa.ai2w ago
Hi @Skyleos. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the knowledge sources provided, I don't have enough specific information to fully address your question about compiling a PM2 worker file with TypeScript alongside a Nuxt application. The knowledge sources don't contain information about integrating PM2 workers or compiling external TypeScript files as part of the Nuxt build process. However, I can provide some general information about TypeScript configuration in Nuxt that might be helpful: 1. Nuxt automatically generates a .nuxt/tsconfig.json file with sensible defaults and your aliases. You can extend this in your project's root tsconfig.json file:
{
"extends": "./.nuxt/tsconfig.json"
}
{
"extends": "./.nuxt/tsconfig.json"
}
Docs > Guide > Directory-structure > tsconfig.json (https://nuxt.com/docs/guide/directory-structure/tsconfig) 2. You can extend the generated TypeScript configuration using the tsConfig option in your nuxt.config.ts file:
export default defineNuxtConfig({
typescript: {
tsConfig: {
// Your custom TypeScript configuration
}
}
})
export default defineNuxtConfig({
typescript: {
tsConfig: {
// Your custom TypeScript configuration
}
}
})
Docs > Api > Nuxt Configuration > typescript > tsConfig (https://nuxt.com/docs/api/nuxt-config#tsconfig) 3. For type-checking at build time, you can use the typescript.typeCheck option:
export default defineNuxtConfig({
typescript: {
typeCheck: true
}
})
export default defineNuxtConfig({
typescript: {
typeCheck: true
}
})
Docs > Guide > Concepts > TypeScript (https://nuxt.com/docs/guide/concepts/typescript) Regarding your specific error, it seems that the Nuxt TypeScript configuration is trying to include your worker file, but it hasn't been compiled. You might need to adjust your TypeScript configuration or build process to handle this external file separately from the Nuxt build. Unfortunately, the provided knowledge sources don't contain information about integrating PM2 workers or compiling external TypeScript files as part of the Nuxt build process. You might need to look into separate TypeScript compilation for your worker file or explore Nuxt modules that could help with this specific use case. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@245519377066229760> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server