fix: remove require cache after install deps
Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -10,11 +10,13 @@ import { ApiName } from '~/common/decorators/openapi.decorator'
|
||||
import { DATA_DIR } from '~/constants/path.constant'
|
||||
import { installPKG } from '~/utils'
|
||||
|
||||
import { ServerlessService } from '../serverless/serverless.service'
|
||||
|
||||
@ApiController('dependencies')
|
||||
@Auth()
|
||||
@ApiName
|
||||
export class DependencyController {
|
||||
constructor() {}
|
||||
constructor(private readonly servierlessService: ServerlessService) {}
|
||||
|
||||
@Get('/graph')
|
||||
@HTTPDecorators.Bypass
|
||||
@@ -45,7 +47,7 @@ export class DependencyController {
|
||||
if (exitCode != 0) {
|
||||
subscriber.next(chalk.red(`Error: Exit code: ${exitCode}\n`))
|
||||
}
|
||||
|
||||
this.servierlessService.cleanRequireCache()
|
||||
subscriber.next(chalk.green('任务完成,可关闭此窗口。'))
|
||||
subscriber.complete()
|
||||
})
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
|
||||
import { ServerlessModule } from '../serverless/serverless.module'
|
||||
import { DependencyController } from './dependency.controller'
|
||||
|
||||
@Module({
|
||||
controllers: [DependencyController],
|
||||
providers: [],
|
||||
imports: [ServerlessModule],
|
||||
})
|
||||
export class DependencyModule {}
|
||||
|
||||
@@ -355,7 +355,7 @@ export class ServerlessService implements OnModuleInit {
|
||||
}
|
||||
|
||||
@Interval(5 * 60 * 1000)
|
||||
private cleanup() {
|
||||
public cleanRequireCache() {
|
||||
const { requireModuleIdSet, scopeContextLRU, scopeModuleLRU } =
|
||||
this.cleanableScope
|
||||
Array.from(requireModuleIdSet.values()).forEach((id) => {
|
||||
@@ -455,9 +455,7 @@ export class ServerlessService implements OnModuleInit {
|
||||
|
||||
// 2. if application third part lib
|
||||
|
||||
const allowedThirdPartLibs: UniqueArray<
|
||||
(keyof typeof PKG.dependencies)[]
|
||||
> = [
|
||||
const allowedThirdPartLibs: string[] = [
|
||||
'@babel/core',
|
||||
'@babel/types',
|
||||
'@babel/plugin-transform-typescript',
|
||||
@@ -482,7 +480,8 @@ export class ServerlessService implements OnModuleInit {
|
||||
'snakecase-keys',
|
||||
'ua-parser-js',
|
||||
'xss',
|
||||
]
|
||||
] as UniqueArray<(keyof typeof PKG.dependencies)[]>
|
||||
// .concat([''] as any[])
|
||||
|
||||
const trustPackagePrefixes = ['@innei/', '@mx-space/', 'mx-function-']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user