enhance(backend): bundle backend using Rolldown (experimental)#17068
enhance(backend): bundle backend using Rolldown (experimental)#17068kakkokari-gtyih wants to merge 8 commits intomisskey-dev:developfrom
Conversation
|
このPRによるapi.jsonの差分 |
|
コード54.4MBになった(が、起動には成功してない) |
|
謎 |
|
通常ならその直後に |
|
どっちかというと EndpointsModule というよりは EndpointsModule に依存している ServerModule かも |
|
関係あるかわからないけど… クラス名は維持しておかないとDI周りが死ぬので、バンドルの過程でクラス名などが変わっているのであれば維持するようにしてみるといいかも…? |
いやさらに ServerModule に依存している CoreModule かも |
|
いかのどれかに問題があることは絞り込めた |
|
|
NoteEntityService に問題があることが判った |
|
NoteEntityServiceは循環参照があり、読み込み順的には |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #17068 +/- ##
===========================================
- Coverage 63.52% 62.43% -1.10%
===========================================
Files 1161 1161
Lines 115939 115944 +5
Branches 7684 8971 +1287
===========================================
- Hits 73655 72385 -1270
- Misses 40078 41368 +1290
+ Partials 2206 2191 -15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
いや嘘かも |
|
InstanceEntityServiceだけ読み込まれてないかも |
|
謎ということが判った |
|
とはいえ循環参照周りが原因な気はする |
|
バンドルでesmoduleそのままだと発生しない循環参照問題が発生するなら minify だけにしたい気がしてます。今後devなら問題ないのにbuildすると謎フリーズが今後増えるのはあまりうれしくないと思います |
|
ApAudienceService も正常に読み込まれていないserviceのひとつだけど、以下のように極限にシンプルな実装に書き換えると読み込まれるようになる before import { Injectable } from '@nestjs/common';
import promiseLimit from 'promise-limit';
import type { MiRemoteUser, MiUser } from '@/models/User.js';
import { concat, unique } from '@/misc/prelude/array.js';
import { bindThis } from '@/decorators.js';
import { getApIds } from './type.js';
import { ApPersonService } from './models/ApPersonService.js';
import type { ApObject } from './type.js';
import type { Resolver } from './ApResolverService.js';
type Visibility = 'public' | 'home' | 'followers' | 'specified';
type AudienceInfo = {
visibility: Visibility,
mentionedUsers: MiUser[],
visibleUsers: MiUser[],
};
type GroupedAudience = Record<'public' | 'followers' | 'other', string[]>;
@Injectable()
export class ApAudienceService {
constructor(
private apPersonService: ApPersonService,
) {
}
@bindThis
public async parseAudience(actor: MiRemoteUser, to?: ApObject, cc?: ApObject, resolver?: Resolver): Promise<AudienceInfo> {
const toGroups = this.groupingAudience(getApIds(to), actor);
const ccGroups = this.groupingAudience(getApIds(cc), actor);
const others = unique(concat([toGroups.other, ccGroups.other]));
const limit = promiseLimit<MiUser | null>(2);
const mentionedUsers = (await Promise.all(
others.map(id => limit(() => this.apPersonService.resolvePerson(id, resolver).catch(() => null))),
)).filter(x => x != null);
if (toGroups.public.length > 0) {
return {
visibility: 'public',
mentionedUsers,
visibleUsers: [],
};
}
if (ccGroups.public.length > 0) {
return {
visibility: 'home',
mentionedUsers,
visibleUsers: [],
};
}
if (toGroups.followers.length > 0 || ccGroups.followers.length > 0) {
return {
visibility: 'followers',
mentionedUsers,
visibleUsers: [],
};
}
return {
visibility: 'specified',
mentionedUsers,
visibleUsers: mentionedUsers,
};
}
@bindThis
private groupingAudience(ids: string[], actor: MiRemoteUser): GroupedAudience {
const groups: GroupedAudience = {
public: [],
followers: [],
other: [],
};
for (const id of ids) {
if (this.isPublic(id)) {
groups.public.push(id);
} else if (this.isFollowers(id, actor)) {
groups.followers.push(id);
} else {
groups.other.push(id);
}
}
groups.other = unique(groups.other);
return groups;
}
@bindThis
private isPublic(id: string): boolean {
return [
'https://www.w3.org/ns/activitystreams#Public',
'as:Public',
'Public',
].includes(id);
}
@bindThis
private isFollowers(id: string, actor: MiRemoteUser): boolean {
return id === (actor.followersUri ?? `${actor.uri}/followers`);
}
}after import { Injectable } from '@nestjs/common';
import type { MiRemoteUser } from '@/models/User.js';
import { bindThis } from '@/decorators.js';
import type { ApObject } from './type.js';
import type { Resolver } from './ApResolverService.js';
@Injectable()
export class ApAudienceService {
constructor(
) {
console.log('ApAudienceService initialized');
}
@bindThis
public async parseAudience(actor: MiRemoteUser, to?: ApObject, cc?: ApObject, resolver?: Resolver) {
return {
visibility: 'specified',
};
}
} |
コードに出てないわけでなさそう(ビルド成果物を検索したらヒットした) |
そもそもnestjsはバンドルされた環境で動かすことは想定されてるのかしら |

What
rolldownでバックエンドをバンドル(e2e用のみswcから移行していない)
途中まで起動するがここで固まる。同じような状況に遭遇していたら情報が欲しいかも
Why
Additional info (optional)
Checklist