Skip to content

Commit 9024e9d

Browse files
committed
chore: enhance type generation and build configuration
- Added type exports to native-modules package.json for improved module resolution. - Updated build script in native-modules to generate types with TypeScript. - Configured tsconfig.json in both native-modules and primitives to support declaration files and path mapping. - Adjusted GitHub Actions workflow to ensure consistent package installation during builds.
1 parent d0af91c commit 9024e9d

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- name: Build packages
3333
run: |
3434
pnpm -r --filter @native-ui-org/native-modules run build
35+
pnpm install --frozen-lockfile
3536
pnpm -r --filter @native-ui-org/primitives run build
3637
3738
- name: Configure pnpm for npm

packages/native-modules/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55
"main": "build/index.js",
66
"react-native": "build/index.native.js",
77
"types": "build/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./build/index.d.ts",
11+
"import": "./build/index.js",
12+
"require": "./build/index.js",
13+
"react-native": "./build/index.native.js"
14+
}
15+
},
816
"scripts": {
917
"build": "expo-module build && npm run build:types",
10-
"build:types": "node scripts/generate-types.js",
18+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap false && node scripts/post-build-types.js",
1119
"clean": "expo-module clean",
1220
"lint": "expo-module lint",
1321
"test": "expo-module test",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
// Ensure the build/index.d.ts file exists and exports correctly
5+
const buildDir = path.join(__dirname, '../build');
6+
const indexDtsPath = path.join(buildDir, 'index.d.ts');
7+
8+
// Check if index.d.ts exists, if not create it
9+
if (!fs.existsSync(indexDtsPath)) {
10+
fs.writeFileSync(indexDtsPath, "export * from './context-menu';\n");
11+
}
12+
13+
// Verify context-menu/index.d.ts exists
14+
const contextMenuIndexPath = path.join(buildDir, 'context-menu', 'index.d.ts');
15+
if (!fs.existsSync(contextMenuIndexPath)) {
16+
console.error('❌ context-menu/index.d.ts not found after TypeScript compilation');
17+
process.exit(1);
18+
}
19+
20+
console.log('✅ TypeScript declaration files verified');
21+

packages/native-modules/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "./build",
5-
"rootDir": "./src"
5+
"rootDir": "./src",
6+
"declaration": true,
7+
"declarationMap": false,
8+
"emitDeclarationOnly": true
69
},
710
"include": ["src/**/*"],
811
"exclude": ["node_modules", "build", "**/*.test.ts", "**/*.test.tsx"]

packages/primitives/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"outDir": "dist",
5-
"types": ["jest", "@testing-library/jest-dom"]
5+
"types": ["jest", "@testing-library/jest-dom"],
6+
"skipLibCheck": true,
7+
"baseUrl": ".",
8+
"paths": {
9+
"@native-ui-org/native-modules": ["../native-modules/build/index"]
10+
}
611
},
712
"include": ["tests/**/*.ts", "tests/**/*.tsx", "src/**/*.ts", "src/**/*.tsx", "src", "tests"]
813
}

0 commit comments

Comments
 (0)