Skip to content

Commit

Permalink
🐛 fix: fix entry type error
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 16, 2023
1 parent e0f5c61 commit 25d40f9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ next-env.d.ts
.next
.env
public/*.js
bun.lockb
bun.lockb
react.d.ts
server.d.ts
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@
"module": "es/index.js",
"types": "es/index.d.ts",
"files": [
"es"
"es",
"server.d.ts",
"react.d.ts"
],
"scripts": {
"build": "father build",
"build": "father build && npm run build:entry",
"build:entry": "tsx scripts/build-entries.ts",
"ci": "npm run lint && npm run type-check",
"clean": "rm react.d.ts server.d.ts",
"dev": "father dev",
"docs:build": "npm run setup && npm run build && dumi build",
"docs:build-analyze": "ANALYZE=1 dumi build",
"docs:dev": "npm run setup && dumi dev",
"docs:dev": "npm run clean && npm run setup && dumi dev",
"doctor": "father doctor",
"lint": "eslint \"{src,api,lib}/**/*.{js,jsx,ts,tsx}\" --fix",
"lint:md": "remark . --quiet --frail --output",
Expand Down Expand Up @@ -115,6 +119,7 @@
"remark": "^14",
"remark-cli": "^11",
"semantic-release": "^21",
"tsx": "^4.1.2",
"typescript": "^5",
"vercel": "^28"
},
Expand Down
17 changes: 17 additions & 0 deletions scripts/build-entries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { writeFileSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

// 获取当前模块文件的路径
const __filename = fileURLToPath(import.meta.url);

// 获取当前模块文件的目录路径
const __dirname = path.dirname(__filename);

const dir = path.join(__dirname, '..');

const entries = ['react', 'server'];

entries.forEach((name) => {
writeFileSync(path.join(dir, `${name}.d.ts`), `export * from './es/${name}';`);
});
16 changes: 16 additions & 0 deletions tsconfig.entry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"declaration": true,
"downlevelIteration": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"strict": true,
"emitDeclarationOnly": true
},
"include": ["react.ts", "server.ts"]
}
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"resolveJsonModule": true,
"module": "ESNext",
"moduleResolution": "node",
"skipLibCheck": true,
"strict": true,
"paths": {
Expand All @@ -16,5 +18,6 @@
"@lobehub/tts/*": ["src/*"]
}
},
"exclude": ["react.d.ts", "server.d.ts"],
"include": ["src", "docs", "lib", ".dumirc.ts", "api", "**/*.ts", "**/*.d.ts", "**/*.tsx"]
}

0 comments on commit 25d40f9

Please sign in to comment.