-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
enhance(backend): bundle backend using Rolldown (experimental) #17068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
enhance(backend): bundle backend using Rolldown (experimental) #17068
Conversation
|
このPRによるapi.jsonの差分 |
|
コード54.4MBになった(が、起動には成功してない) |
|
謎 |
|
通常ならその直後に |
|
どっちかというと EndpointsModule というよりは EndpointsModule に依存している ServerModule かも |
|
関係あるかわからないけど… クラス名は維持しておかないとDI周りが死ぬので、バンドルの過程でクラス名などが変わっているのであれば維持するようにしてみるといいかも…? |
いやさらに ServerModule に依存している CoreModule かも |
|
いかのどれかに問題があることは絞り込めた |
|
|
NoteEntityService に問題があることが判った |
|
NoteEntityServiceは循環参照があり、読み込み順的には |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #17068 +/- ##
===========================================
+ Coverage 63.09% 63.19% +0.10%
===========================================
Files 1152 1154 +2
Lines 115196 115410 +214
Branches 7976 8023 +47
===========================================
+ Hits 72680 72938 +258
+ Misses 40369 40325 -44
Partials 2147 2147 ☔ 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