-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-tsx.ts
74 lines (70 loc) · 1.88 KB
/
test-tsx.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// @ts-ignore
// import { build } from "arenaless-bundler";
// @ts-ignore
import { build } from "./dist/index";
import * as fs from "fs";
async function test() {
let files_text: Record<string, string> = {
"clientApp.tsx":`import { AUIApp, hooks } from "npm:dao3-aui";
let aui = new AUIApp();
function App() {
const [count,setCount]=hooks.useState<number>(0);
return (<>
<ui-text x="0" y="0" height="50px" width="200px"
background-color="#ffffff" background-opacity="100%"
onClick={()=>setCount(count+1)}
text-content={"点击次数:"+count.toString()+"次"}></ui-text>
</>)
}
aui.mount(<App />, ui);
`
}
// let imagebuf=fs.readFileSync("./image.png");
// to uint array
// let image=new Uint8Array(imagebuf);
let files: Record<string, Uint8Array> = {
//"image.png": image,
};
for (let key in files_text) {
files[key] = new TextEncoder().encode(files_text[key]);
}
let res = await build(files, "clientApp.tsx", `{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"baseUrl": "./",
"rootDir": "./",
"outDir": "dist", // do not change this
"lib": [],
"noImplicitAny": false,
"jsxFactory": "AUIApp.h",
"jsxFragmentFactory": "AUIApp.frag",
"jsx": "react",
"paths": {
},
},
"include": [
"./**/*.ts",
"./**/*.d.ts",
"./types"
],
"exclude": [
"node_modules",
"dist"
]
}`, console, "es", `{
"imports":{}
}`, false);
// console.log(res)
return res;
};
(async () => {
let res = await test();
console.log(res)
})();