perf: avoid silk encoding blocking the main event loop (#527)

This commit is contained in:
pk5ls20 authored and GitHub committed 2024-11-15 20:39:18 +08:00
1 parent 74b4d9bf49
commit e44595334a
4 files changed
+44 -16

No files matched your search

+15 -6
View File
@@ -3,12 +3,14 @@ import { defineConfig, PluginOption, UserConfig } from 'vite';
import { resolve } from 'path';
import nodeResolve from '@rollup/plugin-node-resolve';
import { builtinModules } from 'module';
//依赖排除
const external = ['silk-wasm', 'ws', 'express', 'qrcode-terminal', 'fluent-ffmpeg'];
const external = ['silk-wasm', 'ws', 'express', 'qrcode-terminal', 'fluent-ffmpeg', 'piscina'];
const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].flat();
function genCpModule(module: string) {
return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false };
}
let startScripts: string[] | undefined = undefined;
if (process.env.NAPCAT_BUILDSYS == 'linux') {
startScripts = [];
@@ -17,6 +19,7 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') {
} else {
startScripts = ['./script/KillQQ.bat'];
}
const FrameworkBaseConfigPlugin: PluginOption[] = [
cp({
targets: [
@@ -66,9 +69,12 @@ const ShellBaseConfig = () => defineConfig({
target: 'esnext',
minify: false,
lib: {
entry: 'src/shell/napcat.ts',
entry: {
'napcat': 'src/shell/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
},
formats: ['es'],
fileName: () => 'napcat.mjs',
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],
@@ -90,9 +96,12 @@ const FrameworkBaseConfig = () => defineConfig({
target: 'esnext',
minify: false,
lib: {
entry: 'src/framework/napcat.ts',
entry: {
'napcat': 'src/framework/napcat.ts',
'audio-worker': 'src/common/audio-worker.ts',
},
formats: ['es'],
fileName: () => 'napcat.mjs',
fileName: (_, entryName) => `${entryName}.mjs`,
},
rollupOptions: {
external: [...nodeModules, ...external],