From 060eb367d870c68d9a9efbc77d4d2af4e651b6ab Mon Sep 17 00:00:00 2001 From: Hyko Date: Mon, 13 Apr 2026 15:16:02 -0400 Subject: [PATCH] build(tsup): add `@zen/core/api` to external list and document rule - Add `@zen/core/api` to the `external` array in `tsup.config.js` to prevent build failures caused by unresolved `dist/` imports at build time - Document the externals rule in `docs/DEV.md`: any `@zen/core/*` import used in bundled module files must be declared as external, with an explanation of why and a code example to follow --- docs/DEV.md | 20 ++++++++++++++++++++ tsup.config.js | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/DEV.md b/docs/DEV.md index 5d2f678..7440f98 100644 --- a/docs/DEV.md +++ b/docs/DEV.md @@ -32,6 +32,26 @@ Pour les conventions de commit : [COMMITS.md](./dev/COMMITS.md). --- +## Build et configuration tsup + +### Règle des externals + +Tout import de la forme `@zen/core/*` dans un fichier bundlé par tsup (typiquement `src/modules/*/api.js`, `src/modules/*/actions.js`, `src/modules/*/crud.js`) **doit figurer dans la liste `external`** du premier bloc de config dans `tsup.config.js`. + +Pourquoi : tsup tente de résoudre ces imports au moment du build. Or les fichiers `dist/` n'existent pas encore — le build échoue avec `Could not resolve "@zen/core/..."`. + +**Règle :** quand on crée ou refactorise un module `src/core/*/index.js` exposé via `package.json` `exports`, on ajoute immédiatement l'entrée correspondante dans `external` de `tsup.config.js`. + +```js +// tsup.config.js — external (premier bloc) +'@zen/core/api', // ← à ajouter si src/core/api/index.js est un entry tsup +'@zen/core/database', +'@zen/core/storage', +// etc. +``` + +--- + ## Sécurité ### Données entrantes diff --git a/tsup.config.js b/tsup.config.js index 66132a7..74ebd79 100644 --- a/tsup.config.js +++ b/tsup.config.js @@ -41,7 +41,7 @@ export default defineConfig([ splitting: false, sourcemap: false, clean: true, - external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@zen/core/database', '@zen/core/email', '@zen/core/email/templates', '@zen/core/storage', '@zen/core/toast', '@zen/core/modules/actions', '@zen/core/modules/storage', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'], + external: ['react', 'react-dom', 'next', 'pg', 'dotenv', 'dotenv/config', 'resend', '@react-email/components', 'node-cron', 'readline', 'crypto', 'url', 'fs', 'path', 'net', 'dns', 'tls', '@zen/core/api', '@zen/core/database', '@zen/core/email', '@zen/core/email/templates', '@zen/core/storage', '@zen/core/toast', '@zen/core/modules/actions', '@zen/core/modules/storage', '@aws-sdk/client-s3', '@aws-sdk/s3-request-presigner'], noExternal: [], bundle: true, banner: {