-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[minify-backend用] フィジビリティ検証 #16878
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
[minify-backend用] フィジビリティ検証 #16878
Conversation
package.json
Outdated
| "start": "cd packages/backend && node ./built/entry.js", | ||
| "start:inspect": "cd packages/backend && node --inspect ./built/entry.js", | ||
| "start:test": "ncp ./.github/misskey/test.yml ./.config/test.yml && cd packages/backend && cross-env NODE_ENV=test node ./built/entry.js", | ||
| "start": "cd packages/backend && node ./built/boot/entry.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バックエンドのビルド成果物に依存しているcheck_connect.jsが動かないので、代替手段を考える必要がある
| const resolveTsPathsPlugin = { | ||
| name: 'resolve-ts-paths', | ||
| setup(build) { | ||
| build.onResolve({ filter: /^\.{1,2}\/.*\.js$/ }, (args) => { | ||
| if (args.importer) { | ||
| const absPath = join(args.resolveDir, args.path); | ||
| const tsPath = absPath.slice(0, -3) + '.ts'; | ||
| if (fs.existsSync(tsPath)) { | ||
| return { path: tsPath }; | ||
| } | ||
| } | ||
| }); | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
拡張子.jsを愚直にimportしようとするため、tsに置き換えておかないとfile not foundになる
| const externalIpaddrPlugin = { | ||
| name: 'external-ipaddr', | ||
| setup(build) { | ||
| build.onResolve({ filter: /^ipaddr\.js$/ }, (args) => { | ||
| return { path: args.path, external: true }; | ||
| }); | ||
| }, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esbuildがipaddr.jsを外部パッケージだと認識しないので
| //minify: process.env.NODE_ENV === 'production', | ||
| minify: false, | ||
| minify: true, | ||
| keepNames: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これが無いとNestJSのDIが破綻する
| format: 'esm', | ||
| sourcemap: false, | ||
| sourcemap: 'linked', | ||
| packages: 'external', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずnode_modulesは除外中
| swcPlugin({ | ||
| jsc: { | ||
| parser: { | ||
| syntax: 'typescript', | ||
| decorators: true, | ||
| dynamicImport: true, | ||
| }, | ||
| transform: { | ||
| legacyDecorator: true, | ||
| decoratorMetadata: true, | ||
| }, | ||
| experimental: { | ||
| keepImportAssertions: true, | ||
| }, | ||
| baseUrl: join(_dirname, 'src'), | ||
| paths: { | ||
| '@/*': ['*'], | ||
| }, | ||
| target: 'esnext', | ||
| keepClassNames: true, | ||
| }, | ||
| }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esbuild単体だとレガシーデコレーターの解釈が出来ずバックエンドの起動に失敗するため、SWCの力を借りる必要があった
packages/backend/build.js
Outdated
| const rootDir = resolve(_dirname, '../..'); | ||
| await Promise.all([ | ||
| copyBackendViews(rootDir), | ||
| buildBackendScript(rootDir, buildLocales()), | ||
| buildBackendStyle(rootDir), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build-assetsでコピーされるファイル群。
パスの解決やLANGSの置き換えなど、結構厳しい部分が残っているのでこれを機に整理するのが良さそう
| */ | ||
| const dir = `${_dirname}/../../../.config`; | ||
| /** Path of repository root directory */ | ||
| const rootDir = resolve(_dirname, '../../../../'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ビルド後のファイルからの相対パス
scripts/build-assets-func.mjs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バックエンドから無理くり引き回すため切り離したファイル。
前述したが、静的ファイルのコピーなどは改めて見直した方が良さそう
|
これブランチ追従してもらうことできるかしら |
|
いちおう現時点までの最新まで追従しますが、 #16889 も入れないと完全にはならなさそうです |
|
バンドルなしでnode_modulesのminifyは #16904 で一応可能ということが分かったのでひとまずバックエンド単体のminifyで十分かもしれない |
# Conflicts: # packages/backend/package.json # pnpm-lock.yaml # scripts/build-assets.mjs
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## minify-backend #16878 +/- ##
=================================================
Coverage ? 14.00%
=================================================
Files ? 237
Lines ? 11287
Branches ? 3733
=================================================
Hits ? 1581
Misses ? 7584
Partials ? 2122 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@syuilo |
|
#16889 は入った |
|
時間のあるとき再度ブランチ追従してもらえると助かる |
|
引き継ごうかしら |
|
(返信あったの気づいてなかった) |
|
あとでやっておきますわ |
# Conflicts: # package.json # packages/backend/package.json # packages/backend/src/config.ts # pnpm-lock.yaml # scripts/build-assets.mjs
|
やっておきましたわ |
|
🙏 |
|
最新のdevelopを直接取り込んでおります |
|
向き先はdevelopではなくminify-backendなので、よさそうであればそのまま持って行っちゃってください |
|
🙏🏻 |
|
若干だけど起動も速くなったような気がしないでもない |
* wip * Update build.js * Update build.js * [minify-backend用] フィジビリティ検証 (#16878) * fix: minify-backend * 間違えて入れちゃったのを戻す * 追従 * fix --------- Co-authored-by: syuilo <[email protected]> * test * use node 24 * Revert "use node 24" This reverts commit 7ae2deb. * Revert "test" This reverts commit d919879. * Update package.json * wip * Update compile_config.js * Revert "Update compile_config.js" This reverts commit 0ee286f. * Update config.ts * wip * Update .swcrc * Update ClientServerService.ts * [ci skip] update CHANGELOG --------- Co-authored-by: おさむのひと <[email protected]>






What
#16852 向け。developではなくminify-backendブランチに向けています。
backendのminifyが可能かどうかを検証 →node_modulesは含んでいないが、バックエンド単体のminifyそのものは出来た
Why
Additional info (optional)
Checklist