// tsup.config.ts import { defineConfig } from 'tsup' import fs from 'node:fs' import path from 'node:path' // --- 0) Atualiza package.json antes do build (determinístico) --- const pkgPath = path.resolve('package.json') const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')) // Define os campos ao estilo “dayjs-like”: 1 entry CJS + 1 bundle global const nextPkg = { ...pkg, main: 'dist/index.cjs', // Node / SSR (require) types: 'dist/index.d.ts', // Tipos // NÃO usar "module" aqui (muitos bundlers esperam ESM) — deixa sem. browser: 'dist/index.global.js', // Browser sem bundler (