Skip to content

Commit

Permalink
feat(electron): move @blocksuite/affine to peer dependences for packa…
Browse files Browse the repository at this point in the history
…ge speed on windows (#9756)

`@blocksuite/affine` is indirectly depended by electron package. It has around 120k files in total and will greatly slow down forge package build speed.
Move them to peer dependencies to mitigate the issue.
  • Loading branch information
pengx17 committed Jan 18, 2025
1 parent 7436c13 commit f689c2f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/common/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"private": true,
"type": "module",
"devDependencies": {
"@blocksuite/affine": "workspace:*",
"vitest": "2.1.8"
},
"exports": {
Expand All @@ -16,7 +15,8 @@
"./blocksuite": "./src/blocksuite/index.ts"
},
"peerDependencies": {
"@affine/templates": "workspace:*"
"@affine/templates": "workspace:*",
"@blocksuite/affine": "workspace:*"
},
"dependencies": {
"zod": "^3.24.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/common/env/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
},
"include": ["./src"],
"references": [{ "path": "../../../blocksuite/affine/all" }]
"references": []
}
1 change: 0 additions & 1 deletion packages/frontend/apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"make-nsis": "node ./scripts/make-nsis.ts"
},
"devDependencies": {
"@affine-test/kit": "workspace:*",
"@affine-tools/utils": "workspace:*",
"@affine/native": "workspace:*",
"@affine/nbstore": "workspace:*",
Expand Down
8 changes: 6 additions & 2 deletions packages/frontend/apps/electron/test/db/ensure-db.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path';
import { setTimeout } from 'node:timers/promises';

import { removeWithRetry } from '@affine-test/kit/utils/utils';
import fs from 'fs-extra';
import { v4 } from 'uuid';
import { afterAll, afterEach, beforeEach, expect, test, vi } from 'vitest';

Expand Down Expand Up @@ -44,7 +44,11 @@ beforeEach(() => {

afterEach(async () => {
existProcess();
await removeWithRetry(tmpDir);
try {
await fs.remove(tmpDir);
} catch (e) {
console.error(e);
}
vi.useRealTimers();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'node:path';

import { removeWithRetry } from '@affine-test/kit/utils/utils';
import fs from 'fs-extra';
import { v4 } from 'uuid';
import { afterAll, afterEach, beforeAll, expect, test, vi } from 'vitest';
Expand All @@ -17,7 +16,11 @@ beforeAll(() => {
});

afterEach(async () => {
await removeWithRetry(tmpDir);
try {
await fs.remove(tmpDir);
} catch (e) {
console.error(e);
}
});

afterAll(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import path from 'node:path';

import { removeWithRetry } from '@affine-test/kit/utils/utils';
import fs from 'fs-extra';
import { v4 } from 'uuid';
import { afterAll, afterEach, describe, expect, test, vi } from 'vitest';
Expand All @@ -21,7 +20,11 @@ vi.doMock('@affine/electron/helper/main-rpc', () => ({
}));

afterEach(async () => {
await removeWithRetry(tmpDir);
try {
await fs.remove(tmpDir);
} catch (e) {
console.error(e);
}
});

afterAll(() => {
Expand Down
1 change: 0 additions & 1 deletion packages/frontend/apps/electron/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"include": ["./src"],
"references": [
{ "path": "../../../../tests/kit" },
{ "path": "../../../../tools/utils" },
{ "path": "../../native" },
{ "path": "../../../common/nbstore" },
Expand Down
3 changes: 1 addition & 2 deletions tools/utils/src/workspace.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export const PackageList = [
{
location: 'packages/common/env',
name: '@affine/env',
workspaceDependencies: ['blocksuite/affine/all'],
workspaceDependencies: [],
},
{
location: 'packages/common/infra',
Expand Down Expand Up @@ -512,7 +512,6 @@ export const PackageList = [
location: 'packages/frontend/apps/electron',
name: '@affine/electron',
workspaceDependencies: [
'tests/kit',
'tools/utils',
'packages/frontend/native',
'packages/common/nbstore',
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/electron@workspace:packages/frontend/apps/electron"
dependencies:
"@affine-test/kit": "workspace:*"
"@affine-tools/utils": "workspace:*"
"@affine/native": "workspace:*"
"@affine/nbstore": "workspace:*"
Expand Down Expand Up @@ -556,11 +555,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/env@workspace:packages/common/env"
dependencies:
"@blocksuite/affine": "workspace:*"
vitest: "npm:2.1.8"
zod: "npm:^3.24.1"
peerDependencies:
"@affine/templates": "workspace:*"
"@blocksuite/affine": "workspace:*"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit f689c2f

Please sign in to comment.