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

Abierto Apto para principiantes
#71 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
cli, tooling

Línea de trabajo

Empieza con la definición del módulo frontendTesting en src/steps/gen-ext-scaffolder.ts e inspecciona los archivos generados tsconfig.test.json, webpack.config.cjs y js/package.json. Compara las inclusiones de TypeScript generadas y la ruta del shim con la configuración de extensión independiente descrita en el issue, y comprueba cómo gestiona el generador la configuración antigua de webpack. El objetivo es que una extensión independiente permita comprobar correctamente los tipos de las pruebas, tenga solo la configuración de webpack prevista y presente un diff acotado en el archivo del paquete.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
47
Forks
4
Merge medio
8 min
PR fusionados (30 d)
13

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de flarum/cli

Todos los issues de flarum/cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.