Skip to content

Commit f29a667

Browse files
committed
feat: Create a component type file.
1 parent 76514dd commit f29a667

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

package/react-native-uiw/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ lib
22
src
33
node_modules
44
package-lock.json
5+
tsconfig.json
56
yarn.lock
67

78
# OSX

package/react-native-uiw/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "@uiw/react-native",
3-
"version": "1.0.6",
3+
"version": "1.0.8",
44
"description": "UIW for React Native",
55
"main": "lib/index.js",
66
"scripts": {
7-
"start": "node script/build.js"
7+
"start": "node script/build.js",
8+
"type": "tsbb types"
89
},
910
"keywords": [],
1011
"author": "",
@@ -34,7 +35,8 @@
3435
"@babel/preset-typescript": "^7.6.0",
3536
"babel-preset-react-native": "^4.0.1",
3637
"fs-extra": "^8.1.0",
38+
"metro-react-native-babel-preset": "^0.56.0",
3739
"react-native": "^0.60.0",
38-
"metro-react-native-babel-preset": "^0.56.0"
40+
"tsbb": "^1.1.3"
3941
}
4042
}

package/react-native-uiw/script/build.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,33 @@ function getPath(rootPath, result = []) {
2424
return result;
2525
}
2626

27+
const tsc = {
28+
compilerOptions: {
29+
// allowJs: true,
30+
allowSyntheticDefaultImports: true,
31+
esModuleInterop: true,
32+
outDir: 'lib',
33+
// isolatedModules: true,
34+
declaration: true,
35+
jsx: 'react',
36+
lib: ['es6'],
37+
resolveJsonModule: true,
38+
moduleResolution: 'node',
39+
strict: true,
40+
target: 'esnext',
41+
baseUrl: '.',
42+
},
43+
exclude: ['node_modules'],
44+
include: ['src/**/*'],
45+
};
46+
2747
(async () => {
2848
const root = path.join(process.cwd(), 'src');
2949
const output = path.join(process.cwd(), 'lib');
30-
await fs.emptyDir(root);
50+
const tscPath = path.join(process.cwd(), 'tsconfig.json');
51+
await fs.remove(output);
52+
await fs.writeJSON(tscPath, tsc);
53+
await fs.remove(root);
3154
await fs.copy(path.join(process.cwd(), '../../components'), root);
3255
const files = await getPath(root);
3356
files.forEach(itemPath => {
@@ -36,12 +59,21 @@ function getPath(rootPath, result = []) {
3659
const outputFile = itemPath.replace(root, output);
3760
fs.outputFileSync(outputFile.replace(/.(tsx|ts)$/, '.js'), code);
3861
// eslint-disable-next-line prettier/prettier
39-
console.log(`♻️: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputFile.replace(process.cwd(), '').replace(/^\//, '')}`);
62+
console.log(`♻️: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputFile.replace(process.cwd(), '').replace(/^\//, '').replace(/\.tsx$/, '.js')}`);
63+
}
64+
if (/.(md)$/.test(itemPath)) {
65+
const outputMd = itemPath.replace(root, output);
66+
fs.ensureFileSync(outputMd);
67+
fs.copyFileSync(itemPath, outputMd);
68+
// eslint-disable-next-line prettier/prettier
69+
console.log(`📋: ${itemPath.replace(process.cwd(), '').replace(/^\//, '')} -> ${outputMd.replace(process.cwd(), '').replace(/^\//, '')}`);
4070
}
4171
});
72+
await execute('npm run type');
4273
await execute('npm publish');
4374
await fs.remove(root);
4475
await fs.remove(output);
76+
await fs.remove(tscPath);
4577
await fs.remove(path.join(process.cwd(), 'package-lock.json'));
4678
await fs.remove(path.join(process.cwd(), 'node_modules'));
4779
})();

0 commit comments

Comments
 (0)