Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use tsup for building; package.json exports for better compat #33

Merged
merged 10 commits into from
Dec 22, 2024
22 changes: 16 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,29 @@
"author": "James M Snell <jasnell@gmail.com>",
"license": "MIT",
"main": "./dist/lib/index.js",
"module": "./dist/lib/index.mjs",
"types": "./dist/lib/index.d.ts",
"exports": {
"import": "./dist/esm-wrapper.mjs",
"require": "./dist/lib/index.js"
".": {
"import": {
"types": "./dist/lib/index.d.mts",
"default": "./dist/lib/index.mjs"
},
"require": {
"types": "./dist/lib/index.d.ts",
"default": "./dist/lib/index.js"
},
"types": "./dist/lib/index.d.ts",
"default": "./dist/lib/index.js"
}
},
"types": "./dist/lib/index.d.ts",
"scripts": {
"prebuildify": "prebuildify --napi --strip",
"install": "node-gyp-build",
"build": "npm run prebuildify && tsc && npm run gen-esm-wrapper",
"build": "npm run prebuildify && tsup",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsc was removed, but with dts: true, tsup will call tsc.

"lint": "standardx \"**/*.{ts,mjs,js,cjs}\" | snazzy",
"test-only": "tap --ts",
"test": "npm run lint && npm run build && npm run test-only",
"gen-esm-wrapper": "gen-esm-wrapper . dist/esm-wrapper.mjs",
"prepack": "npm run build"
},
"repository": {
Expand Down Expand Up @@ -58,12 +68,12 @@
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"abort-controller": "^3.0.0",
"gen-esm-wrapper": "^1.1.3",
"prebuildify": "^6.0.1",
"snazzy": "^9.0.0",
"standardx": "^7.0.0",
"tap": "^15.0.6",
"ts-node": "^10.9.2",
"tsup": "^8.2.4",
"typescript": "^5.3.3"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"resolveJsonModule": true, /* Include modules imported with '.json' extension */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["lib"],
"include": ["lib", "tsup.config.ts"],
}
21 changes: 21 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from "tsup";
import { copyFile } from "node:fs/promises";
import { join } from "node:path";

export default defineConfig({
outDir: "dist/lib",
entry: ["./lib/index.ts"],
format: ["cjs", "esm"],
target: "node18",
sourcemap: true,
clean: true,
minify: false,
shims: true,
dts: true,
async onSuccess() {
await copyFile(
join(__dirname, "package.json"),
join(__dirname, "dist/package.json"),
);
},
});
Loading