Skip to content

Commit 301447b

Browse files
committed
make into node module with exporter
1 parent a123d09 commit 301447b

16 files changed

+1150
-529
lines changed

exporter/build-defs.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { buildCoreJSX, buildModuleJSX, renderReact, renderSvelte } from 'nativescript-source-to-jsx-def'
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { chdir } from 'process';
5+
6+
function exportModule(moduleName: string) {
7+
console.log(`Exporting ${moduleName}`)
8+
let modulePath = path.dirname(require.resolve(moduleName+"/package.json"))
9+
let doc = buildModuleJSX(moduleName, modulePath, path.dirname(require.resolve("@nativescript/core/package.json")));
10+
let module_filename = moduleName.replace(/[^\w]/g, '-');
11+
12+
fs.writeFileSync(`../svelte-native-defs/svelte-native-jsx-${module_filename}.d.ts`, renderSvelte(doc));
13+
fs.writeFileSync(`../react-nativescript-defs/react-nativescript-jsx-${module_filename}.ts`, renderReact(doc));
14+
}
15+
16+
function exportCore(corePath: string) {
17+
console.log(`Exporting Core`)
18+
let doc = buildCoreJSX(corePath);
19+
20+
fs.writeFileSync("../svelte-native-defs/svelte-native-jsx-nativescript-core.d.ts", renderSvelte(doc));
21+
fs.writeFileSync("../react-nativescript-defs/react-nativescript-jsx.ts", renderReact(doc, true));
22+
}
23+
24+
function doExports() {
25+
const nativescriptSourcePath = path.resolve(__dirname, "./nativescript_src/packages/core");
26+
chdir(__dirname)
27+
28+
fs.mkdirSync("../svelte-native-defs", { recursive: true});
29+
fs.mkdirSync("../react-nativescript-defs", { recursive: true});
30+
31+
exportCore(nativescriptSourcePath)
32+
exportModule("nativescript-ui-listview")
33+
exportModule("nativescript-ui-chart")
34+
exportModule("nativescript-ui-sidedrawer")
35+
}
36+
37+
38+
doExports();

0 commit comments

Comments
 (0)