mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-24 05:07:06 +08:00
fix(electron): optimize bundle size by removing unused dependencies (#6415)
Should greatly reduce the size of helper.js and could speed up the time on starting the client app. fix https://github.com/toeverything/AFFiNE/issues/6312 Before:  After: 
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
import * as esbuild from 'esbuild';
|
||||
|
||||
import { config, mode } from './common';
|
||||
import { config, mode, rootDir } from './common';
|
||||
|
||||
async function buildLayers() {
|
||||
const common = config();
|
||||
@@ -16,10 +19,20 @@ async function buildLayers() {
|
||||
`"${process.env.BUILD_TYPE_OVERRIDE}"`;
|
||||
}
|
||||
|
||||
await esbuild.build({
|
||||
const metafile = process.env.METAFILE;
|
||||
|
||||
const result = await esbuild.build({
|
||||
...common,
|
||||
define: define,
|
||||
metafile: !!metafile,
|
||||
});
|
||||
|
||||
if (metafile) {
|
||||
await fs.writeFile(
|
||||
path.resolve(rootDir, `metafile-${Date.now()}.json`),
|
||||
JSON.stringify(result.metafile, null, 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await buildLayers();
|
||||
|
||||
Reference in New Issue
Block a user