Skip to content

chore(webapp): 純粋な JS/TS パッケージを dependencies から devDependencies へ移動する #213

Description

@konokenj

executor 07(全コードベースのコードレビュー)が発見し、独立したセキュリティレビュー(サブエージェント, opus-4.7)で裏付けた。

問題

AGENTS.md にはこう書かれている:「Dependencies: esbuild and Next.js bundle everything, so only packages with native binaries needed at Lambda runtime belong in dependencies. Everything else goes in devDependencies.」(esbuild と Next.js がすべてをバンドルするため、Lambda 実行時にネイティブバイナリを必要とするパッケージのみが dependencies に属する。それ以外はすべて devDependencies へ。)

apps/webapp/package.json:18-39 は、純粋な JavaScript/TypeScript パッケージを dependencies 配下に宣言している:

  • @aws-amplify/adapter-nextjs, @aws-sdk/client-lambda, @aws-sdk/client-ssm
  • @repo/db, @repo/event-utils, @repo/shared-types(ワークスペースパッケージ)
  • aws-amplify
  • class-variance-authority, clsx
  • drizzle-orm
  • lucide-react
  • next, next-safe-action, next-themes
  • react, react-dom, react-hook-form
  • sonner
  • tailwind-merge, tw-animate-css
  • zod

比較として、apps/async-job/package.jsonapps/db-migrator/package.json はすべてを devDependencies に正しく配置し、ビルド時の esbuild によるバンドルに依存している。

webapp の Docker イメージは Next.js の output: 'standalone' を使うため、実行時に Lambda が実行するのは apps/webapp/.next/standalone/* のみである。standalone がトレースして出力に含めたものが実際に動作する対象であり、dependencies リストは実行時のクロージャではない。実行時に不要なパッケージを dependencies に残すと、推移的なインストールクロージャが肥大化し、Dependabot の監査対象が不明瞭になり、キットのコピー利用者に誤ったパターンを示してしまう。

根拠

  • 正規表現: apps/webapp/package.jsondependencies
  • AGENTS.md の Conventions セクション。
  • Docker ビルド: apps/webapp/Dockerfile:1-29(ビルダはワークスペース全体をインストールし、ランナーには .next/standalone + .next/static + run.sh のみをコピーする)。

対応の方向性

Next.js の standalone トレーシングが実行時の外部依存として必要としない各パッケージを devDependencies へ移動する。イメージを再ビルドしてスモークテストで検証する。ネイティブ限定の例外(もし現れれば、例: sharp)はコメント付きで dependencies に残してよい。

apps/webapp はこの点で apps/async-job と同じ見た目になるはずである。

サンプルとしての教育的リスク

コピー利用者は肥大化した本番依存セットを引き継ぎ、サプライチェーンアラートの対象を広げ、ベースイメージサイズに関するコスト/複雑さの議論を悪化させる。

関連

  • executor 07 の発見まとめ: .kiro/specs/v3-release-prep/review-full-report.md (M3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-triageAwaiting maintainer review and classification

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions