chore: migrate to tsup to fix ESM related issues

This commit is contained in:
c4605
2025-11-17 11:05:12 +01:00
parent ee6cf70cf4
commit f69066659c
4 changed files with 1067 additions and 20 deletions

View File

@@ -2,11 +2,10 @@
"name": "clarity-codegen", "name": "clarity-codegen",
"version": "1.1.3", "version": "1.1.3",
"main": "./lib/index.js", "main": "./lib/index.js",
"module": "./dist/index.js", "module": "./lib/index.mjs",
"types": "./dist/index.d.ts", "types": "./lib/index.d.ts",
"files": [ "files": [
"lib/", "lib/"
"dist/"
], ],
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@@ -14,22 +13,22 @@
}, },
"scripts": { "scripts": {
"prepare": "pnpm run build", "prepare": "pnpm run build",
"build": "rm -rf lib && rm -rf dist && tsc -p tsconfig.json && tsc -p tsconfig.cjs.json" "build": "rm -rf lib && tsup-node src"
}, },
"exports": { "exports": {
".": { ".": {
"types": "./dist/index.d.ts", "types": "./lib/index.d.ts",
"import": "./dist/index.js", "import": "./lib/index.mjs",
"require": "./lib/index.js" "require": "./lib/index.js"
}, },
"./generate": { "./generate": {
"types": "./dist/generate/index.d.ts", "types": "./lib/generate/index.d.ts",
"import": "./dist/generate/index.js", "import": "./lib/generate/index.mjs",
"require": "./lib/generate/index.js" "require": "./lib/generate/index.js"
}, },
"./lib/generate": { "./lib/generate": {
"types": "./dist/generate/index.d.ts", "types": "./lib/generate/index.d.ts",
"import": "./dist/generate/index.js", "import": "./lib/generate/index.mjs",
"require": "./lib/generate/index.js" "require": "./lib/generate/index.js"
} }
}, },
@@ -40,6 +39,7 @@
"@types/node": "^20.1.5", "@types/node": "^20.1.5",
"@types/yargs": "^17.0.24", "@types/yargs": "^17.0.24",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"tsup": "^8.5.1",
"typescript": "^5.7.3" "typescript": "^5.7.3"
}, },
"dependencies": { "dependencies": {

1042
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"module": "commonjs" /* Specify what module code is generated. */,
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
"outDir": "./lib" /* Specify an output folder for all emitted files. */,
}
}

14
tsup.config.ts Normal file
View File

@@ -0,0 +1,14 @@
import { defineConfig } from "tsup"
export default defineConfig({
outDir: "lib",
format: ["cjs", "esm"],
treeshake: true,
sourcemap: true,
dts: true,
env: {
ENV_NAME: process.env.ENV_NAME ?? "prod",
},
inject: [],
noExternal: []
})