Skip to content

Commit ae1e3c1

Browse files
authored
feat(rslib): add ReactLynx examples (#501)
1 parent 4f6c020 commit ae1e3c1

16 files changed

Lines changed: 2011 additions & 42 deletions

‎pnpm-lock.yaml‎

Lines changed: 1741 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rslib/reactlynx-basic/README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Rslib + ReactLynx
2+
3+
## Setup
4+
5+
Install the dependencies:
6+
7+
```bash
8+
pnpm install
9+
```
10+
11+
## Get started
12+
13+
Build the library:
14+
15+
```bash
16+
pnpm build
17+
```
18+
19+
Build the library in watch mode:
20+
21+
```bash
22+
pnpm dev
23+
```

‎rslib/reactlynx-basic/package.json‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "@rslib-example/reactlynx-basic",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"default": "./dist/index.jsx"
9+
}
10+
},
11+
"types": "./dist/index.d.ts",
12+
"files": [
13+
"dist"
14+
],
15+
"scripts": {
16+
"build": "rslib",
17+
"dev": "rslib --watch"
18+
},
19+
"devDependencies": {
20+
"@lynx-js/react": "^0.126.0",
21+
"@lynx-js/types": "^4.2.1",
22+
"@rsbuild/plugin-react": "^2.1.0",
23+
"@rslib/core": "^1.0.0",
24+
"@types/react": "^19.2.18",
25+
"typescript": "^6.0.3"
26+
},
27+
"peerDependencies": {
28+
"@lynx-js/react": ">=0.100.0",
29+
"@lynx-js/types": ">=4",
30+
"@types/react": ">=19"
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
bundle: false,
6+
dts: true,
7+
output: {
8+
target: 'web',
9+
filename: {
10+
js: '[name].jsx',
11+
},
12+
},
13+
plugins: [
14+
pluginReact({
15+
swcReactOptions: {
16+
runtime: 'preserve',
17+
},
18+
}),
19+
],
20+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { JSX } from '@lynx-js/react';
2+
3+
export function ScrollList(): JSX.Element {
4+
return (
5+
<scroll-view scroll-orientation="horizontal" style={{ width: '240px', height: '80px' }}>
6+
{['red', 'green', 'blue'].map((color) => (
7+
<view key={color} style={{ width: '120px', height: '80px', backgroundColor: color }}>
8+
<text style={{ color: 'white' }}>{color}</text>
9+
</view>
10+
))}
11+
</scroll-view>
12+
);
13+
}

‎rslib/reactlynx-basic/src/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { ScrollList } from './ScrollList';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"lib": ["DOM", "ES2022"],
4+
"jsx": "preserve",
5+
"jsxImportSource": "@lynx-js/react",
6+
"target": "ES2022",
7+
"noEmit": true,
8+
"skipLibCheck": true,
9+
"types": ["@lynx-js/types", "@rslib/core/types"],
10+
"useDefineForClassFields": true,
11+
"rootDir": "src",
12+
13+
/* modules */
14+
"isolatedModules": true,
15+
"moduleDetection": "force",
16+
"moduleResolution": "bundler",
17+
"resolveJsonModule": true,
18+
"allowImportingTsExtensions": true,
19+
20+
/* type checking */
21+
"noUnusedLocals": true,
22+
"noUnusedParameters": true
23+
},
24+
"include": ["src"]
25+
}

‎rslib/reactlynx-rstest/README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Rslib + ReactLynx
2+
3+
## Setup
4+
5+
Install the dependencies:
6+
7+
```bash
8+
pnpm install
9+
```
10+
11+
## Get started
12+
13+
Build the library:
14+
15+
```bash
16+
pnpm build
17+
```
18+
19+
Build the library in watch mode:
20+
21+
```bash
22+
pnpm dev
23+
```
24+
25+
Run the tests:
26+
27+
```bash
28+
pnpm test
29+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@rslib-example/reactlynx-rstest",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"default": "./dist/index.jsx"
9+
}
10+
},
11+
"types": "./dist/index.d.ts",
12+
"files": [
13+
"dist"
14+
],
15+
"scripts": {
16+
"build": "rslib",
17+
"dev": "rslib --watch",
18+
"test": "rstest",
19+
"test:watch": "rstest --watch"
20+
},
21+
"devDependencies": {
22+
"@lynx-js/react": "^0.126.0",
23+
"@lynx-js/react-rsbuild-plugin": "^0.20.1",
24+
"@lynx-js/types": "^4.2.1",
25+
"@rsbuild/plugin-react": "^2.1.0",
26+
"@rslib/core": "^1.0.0",
27+
"@rstest/adapter-rslib": "^0.11.12",
28+
"@rstest/core": "^0.11.12",
29+
"@types/node": "^24.13.3",
30+
"@types/react": "^19.2.18",
31+
"happy-dom": "^20.14.0",
32+
"typescript": "^6.0.3"
33+
},
34+
"peerDependencies": {
35+
"@lynx-js/react": ">=0.100.0",
36+
"@lynx-js/types": ">=4",
37+
"@types/react": ">=19"
38+
}
39+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { pluginReact } from '@rsbuild/plugin-react';
2+
import { defineConfig } from '@rslib/core';
3+
4+
export default defineConfig({
5+
bundle: false,
6+
dts: true,
7+
output: {
8+
target: 'web',
9+
filename: {
10+
js: '[name].jsx',
11+
},
12+
},
13+
plugins: [
14+
pluginReact({
15+
swcReactOptions: {
16+
runtime: 'preserve',
17+
},
18+
}),
19+
],
20+
});

0 commit comments

Comments
 (0)