Skip to content

Commit 070114e

Browse files
committed
fix(app-service): fix db import error while building;
init.ts should not import db globally, because init.ts would be referenced in build time;
1 parent 0c83449 commit 070114e

File tree

1 file changed

+5
-2
lines changed
  • packages/app-service/src/support

1 file changed

+5
-2
lines changed

packages/app-service/src/support/init.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Constants } from '../constants'
55
import { execSync } from 'child_process'
66
import Config from '../config'
77
import { logger } from './logger'
8-
import { DatabaseAgent } from '../db'
98

109

1110
/**
@@ -59,9 +58,11 @@ interface AppConfigItem {
5958
* @returns
6059
*/
6160
export async function getExtraPackages() {
61+
const { DatabaseAgent } = require('../db') // init.ts should not import db globally, because init.ts would be referenced in build time
62+
6263
await DatabaseAgent.accessor.ready
6364
const db = DatabaseAgent.db
64-
const doc = await db.collection<AppConfigItem>(Constants.config_collection)
65+
const doc: AppConfigItem = await db.collection(Constants.config_collection)
6566
.findOne({ key: 'packages' })
6667

6768
return doc?.value ?? []
@@ -109,6 +110,8 @@ export function moduleExists(mod: string) {
109110
* @returns
110111
*/
111112
export async function ensureCollectionIndexes(): Promise<any> {
113+
const { DatabaseAgent } = require('../db') // init.ts should not import db globally, because init.ts would be referenced in build time
114+
112115
const db = DatabaseAgent.db
113116
await db.collection(Constants.function_log_collection)
114117
.createIndexes([

0 commit comments

Comments
 (0)