This repository was archived by the owner on Dec 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.js
More file actions
55 lines (47 loc) · 1.71 KB
/
build.js
File metadata and controls
55 lines (47 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
// Remove and recreate dist directory
const distDir = path.join(__dirname, 'dist');
if (fs.existsSync(distDir)) {
fs.rmSync(distDir, { recursive: true, force: true });
}
fs.mkdirSync(distDir, { recursive: true });
console.log('Building TypeScript...');
// Build CommonJS
try {
console.log('Building CommonJS (compatible components only)...');
execSync('npx tsc --project tsconfig.build.json --module commonjs --target es2019 --jsx react-native --outDir dist/commonjs --declaration false', {
stdio: 'inherit',
cwd: __dirname
});
console.log('✅ CommonJS build complete');
} catch (error) {
console.error('❌ CommonJS build failed:', error.message);
process.exit(1);
}
// Build ES Modules
try {
console.log('Building ES Modules (compatible components only)...');
execSync('npx tsc --project tsconfig.build.json --module esnext --target es2019 --jsx react-native --outDir dist/module --declaration false', {
stdio: 'inherit',
cwd: __dirname
});
console.log('✅ ES Module build complete');
} catch (error) {
console.error('❌ ES Module build failed:', error.message);
process.exit(1);
}
// Build TypeScript declarations
try {
console.log('Building TypeScript declarations (compatible components only)...');
execSync('npx tsc --project tsconfig.build.json --emitDeclarationOnly --declaration --jsx react-native --outDir dist/typescript', {
stdio: 'inherit',
cwd: __dirname
});
console.log('✅ TypeScript declarations build complete');
} catch (error) {
console.error('❌ TypeScript declarations build failed:', error.message);
process.exit(1);
}
console.log('Build complete!');