1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-25 09:44:22 +03:00

build(bridge/nodejs): usage of ncc

This commit is contained in:
Divlo 2023-05-06 15:38:49 +02:00
parent de08807f1a
commit 07e253f663
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9
3 changed files with 21 additions and 10 deletions

View File

@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/bin",
"rootDir": "../../",
"baseUrl": ".",
"paths": {
"@@/*": ["../../*"],

View File

@ -117,6 +117,7 @@
"@types/node-wav": "0.0.0",
"@typescript-eslint/eslint-plugin": "5.55.0",
"@typescript-eslint/parser": "5.55.0",
"@vercel/ncc": "0.36.1",
"cli-spinner": "0.2.10",
"eslint": "8.22.0",
"eslint-config-prettier": "8.5.0",

View File

@ -137,24 +137,33 @@ BUILD_TARGETS.set('tcp-server', {
* Build for binaries not requiring a Python environment
*/
try {
const tsconfigPath = path.join(NODEJS_BRIDGE_ROOT_PATH, 'tsconfig.json')
const currentWorkingDirectory = process.cwd()
process.chdir(NODEJS_BRIDGE_ROOT_PATH)
await command('npm install', {
shell: true,
stdio: 'inherit'
})
process.chdir(currentWorkingDirectory)
const distBinPath = path.join(NODEJS_BRIDGE_DIST_PATH, 'bin')
const distMainFilePath = path.join(
NODEJS_BRIDGE_DIST_PATH,
'bin',
'bridges',
'nodejs',
'src',
'main.js'
distBinPath,
'index.js'
)
const distRenamedMainFilePath = path.join(
NODEJS_BRIDGE_DIST_PATH,
'bin',
distBinPath,
NODEJS_BRIDGE_BIN_NAME
)
await fs.promises.rm(buildPath, { recursive: true, force: true })
await command(`tsc --project ${tsconfigPath}`, {
const inputMainFilePath = path.join(
NODEJS_BRIDGE_ROOT_PATH,
'src',
'main.ts'
)
await command(`ncc build ${inputMainFilePath} --out ${distBinPath}`, {
shell: true,
stdio: 'inherit'
})