mirror of
https://github.com/hanzoai/iam-sdk.git
synced 2026-10-30 14:54:01 +00:00
tsup started tsc from onSuccess without waiting for it, and set an exit code only when tsc returned a nonzero one. A tsc killed by a signal returns none, so `pnpm build` exited 0 with the JS built and no declarations. Under `tsup --watch`, the clean step deleted every .d.ts on each rebuild, so linked consumers lost their types until tsc caught up. tsc now runs after tsup in the build script, joined by &&, so the shell reports its failure (137 when killed). tsup cleans nothing; `build` empties dist first, and `dev` reruns the declarations after each rebuild. prepare is `pnpm build`, so an install no longer skips the build when an old dist is there. The tsup comment blamed baseUrl and TS5101. On TypeScript 7 the dts plugin cannot load at all: there is no JS API for it to call. Co-authored-by: Hanzo Dev <[email protected]>
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { defineConfig } from 'tsup'
|
|
|
|
// Optional peer deps that consumers install themselves — keep them as
|
|
// runtime requires so tsup doesn't attempt to bundle them.
|
|
//
|
|
// Note: `passport-oauth2` is intentionally NOT external. Marking it
|
|
// external makes tsup emit `__require("passport-oauth2")` (a dynamic
|
|
// require wrapper for ESM/CJS compat), which downstream bundlers like
|
|
// esbuild can't statically resolve. The team monorepo bundles every
|
|
// pod's __start.ts via esbuild and ships a single bundle.js without a
|
|
// runtime node_modules — `__require("passport-oauth2")` then fails at
|
|
// startup with MODULE_NOT_FOUND. Letting tsup bundle passport-oauth2
|
|
// into the SDK's dist (via a static `import OAuth2Strategy from
|
|
// "passport-oauth2"` in src/passport.ts) lets the downstream bundler
|
|
// inline it through normal static resolution.
|
|
const optionalPeers = [
|
|
'react',
|
|
'react-dom',
|
|
'next',
|
|
'next-auth',
|
|
'better-auth',
|
|
'passport'
|
|
]
|
|
|
|
export default defineConfig({
|
|
entry: [
|
|
'src/index.ts',
|
|
'src/paths.ts',
|
|
'src/auth.ts',
|
|
'src/browser.ts',
|
|
'src/session.ts',
|
|
'src/server.ts',
|
|
'src/types.ts',
|
|
'src/react.ts',
|
|
'src/views.tsx',
|
|
'src/nextauth.ts',
|
|
'src/sveltekit.ts',
|
|
'src/remix.ts',
|
|
'src/express.ts',
|
|
'src/hono.ts',
|
|
'src/passport.ts',
|
|
'src/betterauth.ts',
|
|
'src/validation.ts'
|
|
],
|
|
format: ['esm', 'cjs'],
|
|
// No dts and no clean. TypeScript 7 has no JS API for tsup's dts plugin to
|
|
// load, so tsc writes the declarations ("declarations" in package.json),
|
|
// and a `tsup --watch` rebuild must leave them where they are. `build`
|
|
// empties dist itself.
|
|
sourcemap: true,
|
|
splitting: false,
|
|
treeshake: true,
|
|
target: 'es2022',
|
|
outDir: 'dist',
|
|
external: optionalPeers
|
|
})
|