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

未关闭 适合新手
#71 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
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 分钟
30 天内合并 PR
13

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flarum/cli 的其他 Issue

查看 flarum/cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。