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

Aperta Adatta ai principianti
#71 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
cli, tooling

Direzione di ricerca

Inizia dalla definizione del modulo frontendTesting in src/steps/gen-ext-scaffolder.ts ed esamina i file generati tsconfig.test.json, webpack.config.cjs e js/package.json. Confronta gli include TypeScript generati e il percorso dello shim con la configurazione dell’estensione autonoma descritta nell’issue e verifica come il generatore gestisce la vecchia configurazione webpack. L’obiettivo è consentire a un’estensione autonoma di verificare correttamente i tipi dei test, avere solo la configurazione webpack prevista e presentare un diff mirato nel file del package.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
47
Fork
4
Merge medio
8m
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di flarum/cli

Tutte le issue di flarum/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.