@@ -3,10 +3,11 @@ import type { NpmCommandOptions, NpmCommandType, NuxtDevtoolsServerContext, Pack
33import fs from 'node:fs/promises'
44import { startSubprocess } from '@nuxt/devtools-kit'
55import { parseModule } from 'magicast'
6- import { addNuxtModule , getDefaultExportOptions } from 'magicast/helpers'
6+ import { addNuxtModule } from 'magicast/helpers'
77import { detect } from 'package-manager-detector/detect'
88import { checkForUpdateOf } from '../npm'
99import { magicastGuard } from '../utils/magicast'
10+ import { removeNuxtModuleFromCode } from '../utils/nuxt-config'
1011
1112export function setupNpmRPC ( { nuxt } : NuxtDevtoolsServerContext ) {
1213 let detectPromise : Promise < DetectResult | null > | undefined
@@ -145,20 +146,7 @@ export function setupNpmRPC({ nuxt }: NuxtDevtoolsServerContext) {
145146 const filepath = nuxt . options . _nuxtConfigFile
146147 const source = await fs . readFile ( filepath , 'utf-8' )
147148 const generated = await magicastGuard ( async ( ) => {
148- const mod = parseModule ( source , { sourceFileName : filepath } )
149-
150- // TODO: remove module from config
151- // removeNuxtModule(mod, name)
152- const config = getDefaultExportOptions ( mod )
153- config . modules ||= [ ]
154- if ( config . modules . includes ( name ) ) {
155- Object . values ( config . modules ) . forEach ( ( value , index ) => {
156- if ( value === name )
157- config . modules . splice ( index - 1 , 1 )
158- } )
159- }
160-
161- return mod . generate ( ) . code
149+ return removeNuxtModuleFromCode ( source , name , filepath )
162150 } )
163151
164152 const processId = `nuxt:remove-module:${ name } `
0 commit comments