Skip to content

Conversation

@cm-dyoshikawa
Copy link
Contributor

@cm-dyoshikawa cm-dyoshikawa commented Oct 24, 2025

📑 Summary

仕様の変更

ビルドツールをWebpackからRspackに変更。

pnpm -C packages/zenn-cli build:server 12.43s user 2.20s system 153% cpu 9.520 total を実行して検証。

webpack(before):

12.43s user 2.20s system 153% cpu 9.520 total

rspack(after):

2.56s user 0.41s system 142% cpu 2.089 total

(9.87 ÷ 12.43) × 100 = 79.4%の高速化
元の時間の 20.6% に短縮
約 4.9倍 の速度向上

コードの変更

  • packages/zenn-cli/webpack.server.js を削除し、packages/zenn-cli/rspack.server.js に置き換え
  • package.json に以下のスクリプトを追加:
    • clean: ビルド成果物(packages/*/dist, packages/*/lib)を削除
    • build:nocache: キャッシュなしでビルドを実行
  • packages/zenn-cli/package.json の依存関係を更新:
    • webpack 関連パッケージを削除
    • @rspack/core, @rspack/cli を追加

その他・備考

  • Rspackへの移行により、ビルド速度の向上が期待できます
  • 既存の設定との互換性を維持しています

📋 Tasks

プルリクエストを作成いただく際、お手数ですが以下の内容についてご確認をお願いします。

  • 📖 Contribution Guide を読んだ
  • 👩‍💻 canary ブランチに対するプルリクエストである
  • zenn-cli で実行して正しく動作しているか確認する
  • 不要なコードが含まれていないか( コメントやログの消し忘れに注意 )
  • XSS になるようなコードが含まれていないか
  • モバイル端末での表示が考慮されているか
  • Pull Request の内容は妥当か( 膨らみすぎてないか )

より詳しい内容は Pull Request Policy を参照してください。

- WebpackをRspackに置き換え
- package.jsonにcleanスクリプトを追加(packages/*/dist, packages/*/libを削除)
- package.jsonにbuild:nocacheスクリプトを追加(キャッシュなしでビルド)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@cm-dyoshikawa cm-dyoshikawa added the enhancement 機能以外の改善 label Oct 24, 2025
@cm-dyoshikawa cm-dyoshikawa self-assigned this Oct 24, 2025
パッケージのクリーンアップ処理を削除し、ビルドキャッシュのみを無効化するように変更。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@cm-dyoshikawa cm-dyoshikawa marked this pull request as ready for review October 24, 2025 05:00
parser: {
syntax: 'typescript',
},
target: 'es2020',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node20とか指定すると

6 │     "target": "node20",
   ·                      ▲
   ·                      ╰── Unknown ES version: node20 at line 6 column 22

とエラーになるのでESを指定する必要がある

Copy link
Member

@cm-wada-yusuke cm-wada-yusuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1点質問しました

{
test: /\.node$/,
loader: 'node-loader',
type: 'asset/resource',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] ここは変更する必要ありました?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以下はwebpack側の資料ですが、 node-loaderは現状は非推奨で、asset/resourceに移行すべきのようでした

https://github.com/webpack-contrib/node-loader
https://github.com/webpack/webpack/tree/main/examples/nodejs-addons

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

資料ありがとうございます!承知しました!

Copy link
Member

@cm-wada-yusuke cm-wada-yusuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです!

@cm-dyoshikawa cm-dyoshikawa merged commit 5b05591 into canary Oct 24, 2025
3 checks passed
@cm-dyoshikawa cm-dyoshikawa deleted the replace-webpack branch October 24, 2025 06:45
@cm-dyoshikawa cm-dyoshikawa mentioned this pull request Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement 機能以外の改善

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants