@@ -6,7 +6,7 @@ import type { WebSocket } from 'ws'
66import type { NuxtDiscordContext } from '../types'
77import fs from 'node:fs'
88import path from 'node:path'
9- import { addVitePlugin , isIgnored , updateTemplates } from '@nuxt/kit'
9+ import { addVitePlugin , isIgnored , resolveAlias , updateTemplates } from '@nuxt/kit'
1010import chokidar from 'chokidar'
1111import { listen } from 'listhen'
1212import { rollup } from 'rollup'
@@ -52,6 +52,7 @@ export function prepareHMR(ctx: NuxtDiscordContext) {
5252 ...nitroConfig . hooks ,
5353 'rollup:before' : ( nitroCtx , config ) => {
5454 originalBeforeHook ?.( nitroCtx , config )
55+ // TODO: might need to merge with user nuxt config.server.rollupConfig.plugins
5556 config . plugins = [
5657 config . plugins ,
5758 TransformPlugin ( ctx ) ,
@@ -247,8 +248,18 @@ async function generateDynamicCommandBuild(file: string, config: RollupConfig, c
247248 bundle = await rollup ( {
248249 ...config ,
249250 input : file ,
250- // externalize all modules except the command file itself, excluding .ts files
251- external : id => ! id . includes ( file ) && ! id . endsWith ( '.ts' ) ,
251+ plugins : [
252+ config . plugins ,
253+ {
254+ name : 'discord:resolve-alias-and-externalize' ,
255+ resolveId : ( id ) => {
256+ // externalize all modules except the command file itself, excluding .ts files
257+ if ( ! id . includes ( file ) && ! id . endsWith ( '.ts' ) ) {
258+ return { id : resolveAlias ( id ) , external : true }
259+ }
260+ } ,
261+ } ,
262+ ] ,
252263 } )
253264 const { output } = await bundle . generate ( { ...config . output , sourcemap : false } )
254265 fs . mkdirSync ( path . join ( ctx . nuxt . options . buildDir , 'discord' , 'commands' ) , { recursive : true } )
0 commit comments