restauração
This commit is contained in:
parent
9dd2c4025b
commit
8c8802d6f7
31 changed files with 1285 additions and 129 deletions
|
|
@ -1,93 +0,0 @@
|
|||
// 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'))
|
||||
|
||||
// Agora vamos de Day.js “turbinado”: CJS + ESM + IIFE
|
||||
const nextPkg = {
|
||||
...pkg,
|
||||
|
||||
|
||||
"main": "dist/index.cjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"browser": "dist/index.global.js",
|
||||
"unpkg": "dist/index.global.js",
|
||||
"jsdelivr": "dist/index.global.js",
|
||||
"sideEffects": false,
|
||||
|
||||
|
||||
module: undefined,
|
||||
type: undefined as unknown as string,
|
||||
exports: undefined as unknown as Record<string, unknown>,
|
||||
}
|
||||
// remove chaves undefined
|
||||
for (const k of Object.keys(nextPkg)) {
|
||||
// @ts-ignore
|
||||
if (nextPkg[k] === undefined) delete (nextPkg as any)[k]
|
||||
}
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(nextPkg, null, 2) + '\n')
|
||||
|
||||
// --- 1) Externals automáticos ---
|
||||
const external = [
|
||||
...Object.keys(pkg.dependencies ?? {}),
|
||||
...Object.keys(pkg.peerDependencies ?? {}),
|
||||
]
|
||||
|
||||
// --- 2) Config tsup: CJS + ESM + IIFE ---
|
||||
export default defineConfig([
|
||||
// 2.1) CJS para Node/SSR (gera dist/index.cjs + dist/index.d.ts)
|
||||
{
|
||||
entry: { index: 'src/index.ts' },
|
||||
outDir: 'dist',
|
||||
format: ['cjs'],
|
||||
dts: true, // emite tipos aqui
|
||||
platform: 'neutral',
|
||||
target: 'es2018',
|
||||
treeshake: true,
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
clean: true, // limpa dist nesta job
|
||||
external,
|
||||
skipNodeModulesBundle: true,
|
||||
outExtension: () => ({ js: '.cjs' }),
|
||||
},
|
||||
|
||||
// 2.2) ESM para bundlers (gera dist/index.mjs)
|
||||
{
|
||||
entry: { index: 'src/index.ts' },
|
||||
outDir: 'dist',
|
||||
format: ['esm'],
|
||||
dts: false, // tipos já emitidos
|
||||
platform: 'neutral',
|
||||
target: 'es2018',
|
||||
treeshake: true,
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
clean: false,
|
||||
external,
|
||||
skipNodeModulesBundle: true,
|
||||
outExtension: () => ({ js: '.mjs' }),
|
||||
},
|
||||
|
||||
// 2.3) IIFE global para <script> (gera dist/index.global.js)
|
||||
{
|
||||
entry: { index: 'src/index.ts' },
|
||||
outDir: 'dist',
|
||||
format: ['iife'],
|
||||
dts: false,
|
||||
platform: 'browser',
|
||||
target: 'es2015',
|
||||
globalName: 'PComuns', // window.PComuns
|
||||
treeshake: true,
|
||||
sourcemap: false,
|
||||
minify: true,
|
||||
clean: false,
|
||||
external,
|
||||
skipNodeModulesBundle: true,
|
||||
outExtension: () => ({ js: '.global.js' }),
|
||||
},
|
||||
])
|
||||
Loading…
Add table
Add a link
Reference in a new issue