Всем привет, возникла вот такая вот проблема
Сделал библиотеку для react typescript, пытаюсь ее собрать, но почему то она собирается без index.d.ts
tsconfig
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"types": ["vite-plugin-svgr/client"],
"baseUrl": ".",
"paths": {
"@imagesEditor/*": ["src/lib/Editor/images"]
},
"declaration": true,
"outDir": "dist"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import checker from "vite-plugin-checker";
import svgrPlutin from "vite-plugin-svgr";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./src/**/*.{ts,tsx}"',
},
}),
svgrPlutin(),
],
server: {
port: 3000,
},
resolve: {
alias: {
"@imagesEditor": path.resolve(
__dirname,
"src",
"lib",
"Editor",
"images",
),
},
},
build: {
outDir: "dist",
lib: {
// путь к основному файлу библиотеки
entry: path.resolve(__dirname, "src/lib/index.ts"),
// название библиотеки
name: "react-custom-editor",
// форматы генерируемых файлов
formats: ["es", "umd"],
// названия генерируемых файлов
fileName: (format) => `react-custom-editor.${format}.js`,
},
// https://vitejs.dev/config/build-options.html#build-rollupoptions
rollupOptions: {
external: ["react", "react-dom"],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
},
},
},
},
});
package.json
{
"name": "react-custom-editor",
"version": "0.0.0",
"license": "MIT",
"files": [
"dist"
],
"type": "module",
"main": "./dist/react-custom-editor.umd.js",
"module": "./dist/react-custom-editor.es.js",
"types": "./dist/react-custom-editor.d.ts",
"scripts": {
"start": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"prepack": "json -f package.json -I -e \"delete this.devDependencies; delete this.dependencies\""
},
"exports": {
".": {
"import": "./dist/react-custom-editor.es.js",
"require": "./dist/react-custom-editor.umd.js"
}
},
"dependencies": {
"@types/node": "^20.4.5",
"classnames": "^2.3.2",
"draft-convert": "^2.1.13",
"draft-js": "^0.11.7",
"immutable": "^4.3.1",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/draft-convert": "^2.1.4",
"@types/draft-js": "^0.11.12",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"json": "^11.0.0",
"sass": "^1.64.2",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-checker": "^0.6.1",
"vite-plugin-dts": "^3.4.0",
"vite-plugin-svgr": "^3.2.0"
}
}
Но при сборке собирается вот так вот
Хотя в в папке lib вот есть и ts и d.ts
Как можно решить проблему?