[bug]: TypeScript Export Path Issue with Strapi Plugin Build

Aperta
#96 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 6 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
56/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
typescript
Ambito
build-system, cli

Direzione di ricerca

Start with package.json exports, tsconfig.build.json, and the default build and verify scripts. Run npm run build followed by npm run verify and compare the generated dist//admin/src and server/src declarations with the export paths. Done means the build output and package.json agree so verification passes without running watch first.

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

Descrizione

issue: bug
What version of @strapi/sdk-plugin are you using?
  • Npm version: 10.8.2
  • Node.js version: 20.18.3
  • React version: 18.3.1
  • Strapi version: 5.23.3
  • @strapi/sdk-plugin version: 5.3.2
  • Browser: Chrome
What's Wrong?

When building a Strapi plugin with TypeScript, the generated type definitions (.d.ts) are placed in a nested folder (e.g. dist/<plugin-name>/admin/src/index.d.ts).

However, the default package.json configuration expects the types in dist/admin/src/index.d.ts and dist/server/src/index.d.ts, causing verification errors when running the script:

"verify": "strapi-plugin verify"

The error output:

[ERROR]  Missing files for exports:
    ./dist/admin/src/index.d.ts
    ./dist/server/src/index.d.ts
Image
To Reproduce
  1. Create or update a Strapi plugin with TypeScript in a monorepo (Nx or similar).

  2. Use the default build scripts and tsconfig.build.json.

  3. Run the build and verify commands:

    npm run build
    npm run verify
    
  4. Observe that the type files are generated in dist/<plugin-name>/admin/src and dist/<plugin-name>/server/src.

  5. The verification fails due to missing files in the expected export paths.

Expected Behaviour
  • The plugin build should generate type files in the exact paths expected by the package.json exports field, or the package.json should be updated to match the actual output structure.

  • After updating the package.json to:

    "types": "./dist/<plugin-name>/admin/src/index.d.ts"
    

    and

    "types": "./dist/<plugin-name>/server/src/index.d.ts"
    

    the verification passes and the plugin works as expected

Additional Notes

  • If you run watch: strapi-plugin watch before running verify, the verification will pass without errors. This is because the watch command generates the type files in the expected locations before verification.
Lingua principale
TypeScript
Stelle
24
Fork
13
Merge medio
5g 3h
PR unite (30g)
5

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

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 strapi/sdk-plugin

Tutte le issue di strapi/sdk-plugin

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.