From 9853c0ed02312fe5a3d189e9cdb2b40c6bbfe95f Mon Sep 17 00:00:00 2001 From: ioan-ghisoi-cko Date: Mon, 25 Nov 2024 22:24:10 +0000 Subject: [PATCH] Update build process to include type declarations --- package.json | 5 +++-- rollup.config.js | 19 ++++++++++++++++--- tsconfig.json | 16 ++++++++-------- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 822a455..29dc535 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frames-react", - "version": "1.2.1", + "version": "1.2.2", "main": "dist/cjs/index.js", "scripts": { "build": "rollup -c", @@ -14,6 +14,7 @@ "classnames": "^2.5.1", "react": "^17.0.0 || ^18.0.0", "react-dom": "^17.0.0 || ^18.0.0", + "rollup-plugin-typescript2": "^0.36.0", "tslib": "^2.8.1" }, "devDependencies": { @@ -39,7 +40,7 @@ "react-dom": "^17.0.0 || ^18.0.0" }, "module": "dist/esm/index.js", - "types": "dist/index.d.ts", + "types": "dist/types/index.d.ts", "files": [ "dist" ] diff --git a/rollup.config.js b/rollup.config.js index 93d89ef..d811a62 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,6 @@ import resolve from "@rollup/plugin-node-resolve"; +import typescript from "rollup-plugin-typescript2"; import commonjs from "@rollup/plugin-commonjs"; -import typescript from "@rollup/plugin-typescript"; import peerDepsExternal from "rollup-plugin-peer-deps-external"; import { terser } from "rollup-plugin-terser"; @@ -22,9 +22,22 @@ export default { ], plugins: [ peerDepsExternal(), - resolve(), + resolve({ + extensions: [".mjs", ".js", ".jsx", ".ts", ".tsx"], + }), commonjs(), - typescript({ tsconfig: "./tsconfig.json" }), terser(), + typescript({ + tsconfig: "./tsconfig.json", + tsconfigOverride: { + compilerOptions: { + declaration: true, + declarationDir: "dist/types", + }, + include: ["src/**/*"], + }, + useTsconfigDeclarationDir: true, + clean: true, + }), ], }; diff --git a/tsconfig.json b/tsconfig.json index 7de482c..8bbafe8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,15 +3,15 @@ "module": "ESNext", "target": "ES6", "jsx": "react", - "moduleResolution": "node", + "declaration": true, + "declarationDir": "./dist/types", "esModuleInterop": true, - "skipLibCheck": true, + "moduleResolution": "node", "strict": true, - "baseUrl": ".", - "paths": { - "frames-react": ["../dist"] - } + "skipLibCheck": true, + "outDir": "./dist", + "baseUrl": "." }, - "include": ["src/**/*", "tests/**/*"], - "exclude": ["node_modules", "dist"] + "include": ["src/**/*.ts", "src/**/*.tsx"], + "exclude": ["node_modules", "dist", "tests"] }