mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-21 08:11:14 +08:00
fix the production package cannot run issue caused by glob(path-scurry) module error - maybe the version of glob is too new, and there exists different version of glob, so download rimraf and typeorm to makes major version of glob at 7
This commit is contained in:
27
packages/sqlite-plugin/src/utils/module-loader.ts
Normal file
27
packages/sqlite-plugin/src/utils/module-loader.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import * as path from 'node:path';
|
||||
import type typeormType from 'typeorm'
|
||||
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
|
||||
const isUiDev = process.env.NODE_ENV === 'development'
|
||||
|
||||
export function requireTypeorm () {
|
||||
let typeorm: typeof typeormType
|
||||
// production
|
||||
if (
|
||||
isRunFromUi && !isUiDev
|
||||
) {
|
||||
const electron = require('electron')
|
||||
const runtimeDependencies = require(
|
||||
path.resolve(
|
||||
electron.app.getAppPath(),
|
||||
'..',
|
||||
'external-node-runtime-dependencies/index.cjs'
|
||||
)
|
||||
)
|
||||
typeorm = runtimeDependencies.typeorm
|
||||
} else {
|
||||
const importResult = require('typeorm')
|
||||
typeorm = importResult
|
||||
}
|
||||
|
||||
return typeorm
|
||||
}
|
||||
Reference in New Issue
Block a user