Skip to content

Commit

Permalink
fix: add dts plugin to roll-up definition files (#320)
Browse files Browse the repository at this point in the history
re #319
  • Loading branch information
cedoor authored Sep 13, 2024
1 parent de43718 commit 500d240
Show file tree
Hide file tree
Showing 33 changed files with 290 additions and 121 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rollup-plugin-dts": "^6.1.1",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/baby-jubjub/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
5 changes: 3 additions & 2 deletions packages/baby-jubjub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -43,6 +43,7 @@
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/baby-jubjub/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import terser from "@rollup/plugin-terser"
import typescript from "@rollup/plugin-typescript"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"
import { dts } from "rollup-plugin-dts"
import nodePolyfills from "rollup-plugin-polyfill-node"

const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
Expand Down Expand Up @@ -57,5 +58,11 @@ export default [
nodePolyfills(),
cleanup({ comments: "jsdoc" })
]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
external: ["@zk-kit/utils/f1-field"],
plugins: [dts()]
}
]
3 changes: 1 addition & 2 deletions packages/eddsa-poseidon/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
5 changes: 3 additions & 2 deletions packages/eddsa-poseidon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -45,6 +45,7 @@
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0"
},
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/eddsa-poseidon/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commonjs from "@rollup/plugin-commonjs"
import { nodeResolve } from "@rollup/plugin-node-resolve"
import { dts } from "rollup-plugin-dts"
import terser from "@rollup/plugin-terser"
import typescript from "@rollup/plugin-typescript"
import fs from "fs"
Expand Down Expand Up @@ -64,5 +65,10 @@ export default [
nodePolyfills(),
cleanup({ comments: "jsdoc" })
]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()]
}
]
3 changes: 1 addition & 2 deletions packages/imt/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
5 changes: 3 additions & 2 deletions packages/imt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -43,6 +43,7 @@
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0"
},
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/imt/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { nodeResolve } from "@rollup/plugin-node-resolve"
import terser from "@rollup/plugin-terser"
import { dts } from "rollup-plugin-dts"
import typescript from "@rollup/plugin-typescript"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"
Expand Down Expand Up @@ -52,5 +53,10 @@ export default [
nodePolyfills(),
cleanup({ comments: "jsdoc" })
]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()]
}
]
3 changes: 1 addition & 2 deletions packages/lazytower/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
7 changes: 4 additions & 3 deletions packages/lazytower/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -41,7 +41,8 @@
"@rollup/plugin-typescript": "^11.1.6",
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1"
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1"
},
"dependencies": {
"poseidon-lite": "^0.2.0"
Expand Down
48 changes: 28 additions & 20 deletions packages/lazytower/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import terser from "@rollup/plugin-terser"
import typescript from "@rollup/plugin-typescript"
import { dts } from "rollup-plugin-dts"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"

Expand All @@ -14,23 +15,30 @@ const banner = `/**
*/`
const name = pkg.name.substr(1).replace(/[-/]./g, (x: string) => x.toUpperCase()[1])

export default {
input: "src/index.ts",
output: [
{
file: pkg.iife,
name,
format: "iife",
banner
},
{
file: pkg.unpkg,
name,
format: "iife",
plugins: [terser({ output: { preamble: banner } })]
},
{ file: pkg.exports["."].require, format: "cjs", banner },
{ file: pkg.exports["."].default, format: "es", banner }
],
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
}
export default [
{
input: "src/index.ts",
output: [
{
file: pkg.iife,
name,
format: "iife",
banner
},
{
file: pkg.unpkg,
name,
format: "iife",
plugins: [terser({ output: { preamble: banner } })]
},
{ file: pkg.exports["."].require, format: "cjs", banner },
{ file: pkg.exports["."].default, format: "es", banner }
],
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()]
}
]
3 changes: 1 addition & 2 deletions packages/lean-imt/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
5 changes: 3 additions & 2 deletions packages/lean-imt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -43,6 +43,7 @@
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-polyfill-node": "^0.13.0"
},
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions packages/lean-imt/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import terser from "@rollup/plugin-terser"
import typescript from "@rollup/plugin-typescript"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"
import { dts } from "rollup-plugin-dts"
import nodePolyfills from "rollup-plugin-polyfill-node"

const pkg = JSON.parse(fs.readFileSync("./package.json", "utf8"))
Expand Down Expand Up @@ -52,5 +53,10 @@ export default [
nodePolyfills(),
cleanup({ comments: "jsdoc" })
]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()]
}
]
1 change: 0 additions & 1 deletion packages/logical-expressions/build.tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types",
"resolveJsonModule": true
},
"include": ["src"]
Expand Down
7 changes: 4 additions & 3 deletions packages/logical-expressions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"type": "module",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand Down Expand Up @@ -38,6 +38,7 @@
"@rollup/plugin-typescript": "^11.1.6",
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1"
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1"
}
}
24 changes: 16 additions & 8 deletions packages/logical-expressions/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typescript from "@rollup/plugin-typescript"
import { dts } from "rollup-plugin-dts"
import fs from "fs"
import cleanup from "rollup-plugin-cleanup"

Expand All @@ -12,11 +13,18 @@ const banner = `/**
* @see [Github]{@link ${pkg.homepage}}
*/`

export default {
input: "src/index.ts",
output: [
{ file: pkg.exports["."].require, format: "cjs", banner },
{ file: pkg.exports["."].default, format: "es", banner }
],
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
}
export default [
{
input: "src/index.ts",
output: [
{ file: pkg.exports["."].require, format: "cjs", banner },
{ file: pkg.exports["."].default, format: "es", banner }
],
plugins: [typescript({ tsconfig: "./build.tsconfig.json" }), cleanup({ comments: "jsdoc" })]
},
{
input: "src/index.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [dts()]
}
]
3 changes: 1 addition & 2 deletions packages/poseidon-cipher/build.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"declarationDir": "dist/types"
"baseUrl": "."
},
"include": ["src"]
}
7 changes: 4 additions & 3 deletions packages/poseidon-cipher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"unpkg": "dist/index.iife.min.js",
"jsdelivr": "dist/index.iife.min.js",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"default": "./dist/index.js"
}
Expand All @@ -46,7 +46,8 @@
"circomlibjs": "^0.0.8",
"rimraf": "^5.0.5",
"rollup": "^4.12.0",
"rollup-plugin-cleanup": "^3.2.1"
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^6.1.1"
},
"dependencies": {
"@zk-kit/baby-jubjub": "1.0.1",
Expand Down
Loading

0 comments on commit 500d240

Please sign in to comment.