infra frontendTesting: tsconfig.test.json doesn't work in a standalone extension, and webpack.config.js is left behind

オープン 初心者向け
#71 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
cli, tooling

調査の方向性

src/steps/gen-ext-scaffolder.ts の frontendTesting モジュール定義から始め、生成される tsconfig.test.json、webpack.config.cjs、js/package.json を調べます。生成される TypeScript の include と shim のパスを、issue に記載された単独の extension の構成と比較し、ジェネレーターが古い webpack 設定をどのように扱うか確認します。完了条件は、単独の extension でテストの型チェックが機能し、意図した webpack 設定だけが存在し、package ファイルの diff が必要な範囲に絞られていることです。

索引モデルが issue の本文から書いたものです。

説明

Running flarum-cli infra frontendTesting -n (3.0.15) on an existing standalone (Composer-installed) Flarum 2 extension gives a setup where yarn test runs, but the tests don't type-check and an old file is left behind:

  1. js/tsconfig.test.json points at the monorepo's node_modules. "files": ["../../../node_modules/@flarum/jest-config/shims.d.ts"] only resolves inside flarum/framework. In a standalone extension it should be ./node_modules/@flarum/jest-config/shims.d.ts, as the testing docs show.
  2. js/tsconfig.test.json replaces the base include with ["tests/**/*"]. Tests that import the extension's src then lose core's global typings (../vendor/*/*/js/dist-typings/@types/**/*) and the extension's own declaration files. tsc -p tsconfig.test.json --noEmit fails with Cannot find name 'm', Cannot find name 'flarum', and errors on model attributes added through declaration merging. Repeating the base include with tests added fixes it:
    "include": ["src/**/*", "tests/**/*", "../vendor/*/*/js/dist-typings/@types/**/*", "@types/**/*"],
    
  3. js/webpack.config.js is left in place next to the new js/webpack.config.cjs. The module adds the .cjs file (needed now that "type": "module" is set) but doesn't remove the .js one, which the docs say to rename.
  4. Minor: js/package.json is rewritten with 4-space indentation, so the whole file shows up in the diff.

3.x has the same skeleton tsconfig.test.json and the same frontendTesting module definition in src/steps/gen-ext-scaffolder.ts.

主要言語
TypeScript
スター
47
フォーク
4
平均マージ
8分
マージ済み PR(30日)
13

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

flarum/cli のほかの issue

flarum/cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。