Skip to content

Commit

Permalink
fix: dual package
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed May 31, 2024
1 parent 27d7883 commit a22cb3d
Show file tree
Hide file tree
Showing 3 changed files with 862 additions and 10 deletions.
18 changes: 16 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,27 @@
"url": "https://github.com/Gearbox-protocol/liquidator-v2-contracts"
},
"license": "BUSL-1.1",
"main": "dist/index.js",
"sideEffects": false,
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./dist/esm/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.cjs"
}
}
},
"files": [
"contracts",
"dist"
],
"scripts": {
"clean": "forge clean && rm -rf types dist",
"build": "forge build && yarn types && tsc",
"build": "forge build && yarn types && tsup",
"types": "typechain --target ethers-v6 --out-dir ./src/generated ./forge-out/**/*.json",
"forge-build": "forge clean && forge build",
"prepare": "husky",
Expand All @@ -38,6 +51,7 @@
"ethers": "^6.12.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"tsup": "^8.0.2",
"typechain": "^8.1.0",
"typescript": "^5.4.5"
},
Expand Down
28 changes: 28 additions & 0 deletions tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Options } from "tsup";
import { defineConfig } from "tsup";

export default defineConfig((options) => {
const commonOptions: Partial<Options> = {
entry: ["src/index.ts"],
clean: true,
dts: true,
splitting: false,
treeshake: true,
...options,
};

return [
{
...commonOptions,
format: "cjs",
outDir: "./dist/cjs/",
outExtension: () => ({ js: ".cjs" }),
},
{
...commonOptions,
format: ["esm"],
outExtension: () => ({ js: ".mjs" }),
outDir: "./dist/esm/",
},
];
});
Loading

0 comments on commit a22cb3d

Please sign in to comment.