Skip to content

Commit 10d3965

Browse files
authored
js webdemo (#18)
* draft
1 parent fd21f6d commit 10d3965

20 files changed

Lines changed: 3156 additions & 0 deletions

flake.lock

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

flake.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
description = "A very basic flake";
3+
4+
inputs = {
5+
nixpkgs = {
6+
type = "github";
7+
owner = "NixOS";
8+
repo = "nixpkgs";
9+
# nixpkgs-unstable:
10+
rev = "1b5c1881789eb8c86c655caeff3c918fb76fbfe6";
11+
};
12+
flake-utils = {
13+
url = "github:numtide/flake-utils";
14+
};
15+
};
16+
outputs = {
17+
nixpkgs,
18+
flake-utils,
19+
...
20+
}:
21+
flake-utils.lib.eachDefaultSystem (
22+
system: let
23+
pkgs = import nixpkgs {
24+
inherit system;
25+
config = {
26+
allowUnfree = false;
27+
};
28+
};
29+
in {
30+
devShells = {
31+
default = pkgs.mkShell {
32+
packages =
33+
with pkgs; [
34+
pnpm
35+
git
36+
];
37+
};
38+
};
39+
}
40+
);
41+
42+
}

webdemo-js/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

webdemo-js/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# React + TypeScript + Vite
2+
WORK IN PROGRESS
3+
4+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
5+
6+
Currently, two official plugins are available:
7+
8+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
9+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
10+
11+
## React Compiler
12+
13+
The React Compiler is enabled on this template. See [this documentation](https://react.dev/learn/react-compiler) for more information.
14+
15+
Note: This will impact Vite dev & build performances.
16+
17+
## Expanding the ESLint configuration
18+
19+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
20+
21+
```js
22+
export default defineConfig([
23+
globalIgnores(['dist']),
24+
{
25+
files: ['**/*.{ts,tsx}'],
26+
extends: [
27+
// Other configs...
28+
29+
// Remove tseslint.configs.recommended and replace with this
30+
tseslint.configs.recommendedTypeChecked,
31+
// Alternatively, use this for stricter rules
32+
tseslint.configs.strictTypeChecked,
33+
// Optionally, add this for stylistic rules
34+
tseslint.configs.stylisticTypeChecked,
35+
36+
// Other configs...
37+
],
38+
languageOptions: {
39+
parserOptions: {
40+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
41+
tsconfigRootDir: import.meta.dirname,
42+
},
43+
// other options...
44+
},
45+
},
46+
])
47+
```
48+
49+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
50+
51+
```js
52+
// eslint.config.js
53+
import reactX from 'eslint-plugin-react-x'
54+
import reactDom from 'eslint-plugin-react-dom'
55+
56+
export default defineConfig([
57+
globalIgnores(['dist']),
58+
{
59+
files: ['**/*.{ts,tsx}'],
60+
extends: [
61+
// Other configs...
62+
// Enable lint rules for React
63+
reactX.configs['recommended-typescript'],
64+
// Enable lint rules for React DOM
65+
reactDom.configs.recommended,
66+
],
67+
languageOptions: {
68+
parserOptions: {
69+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
70+
tsconfigRootDir: import.meta.dirname,
71+
},
72+
// other options...
73+
},
74+
},
75+
])
76+
```

webdemo-js/eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import tseslint from 'typescript-eslint'
6+
import { defineConfig, globalIgnores } from 'eslint/config'
7+
8+
export default defineConfig([
9+
globalIgnores(['dist']),
10+
{
11+
files: ['**/*.{ts,tsx}'],
12+
extends: [
13+
js.configs.recommended,
14+
tseslint.configs.recommended,
15+
reactHooks.configs.flat.recommended,
16+
reactRefresh.configs.vite,
17+
],
18+
languageOptions: {
19+
ecmaVersion: 2020,
20+
globals: globals.browser,
21+
},
22+
},
23+
])

webdemo-js/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>webdemo</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

webdemo-js/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "webdemo",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"onnxruntime-web": "^1.23.2",
14+
"react": "^19.2.0",
15+
"react-dom": "^19.2.0"
16+
},
17+
"devDependencies": {
18+
"@eslint/js": "^9.39.1",
19+
"@types/node": "^24.10.1",
20+
"@types/react": "^19.2.5",
21+
"@types/react-dom": "^19.2.3",
22+
"@vitejs/plugin-react": "^5.1.1",
23+
"babel-plugin-react-compiler": "^1.0.0",
24+
"eslint": "^9.39.1",
25+
"eslint-plugin-react-hooks": "^7.0.1",
26+
"eslint-plugin-react-refresh": "^0.4.24",
27+
"globals": "^16.5.0",
28+
"typescript": "~5.9.3",
29+
"typescript-eslint": "^8.46.4",
30+
"vite": "npm:rolldown-vite@7.2.5"
31+
},
32+
"pnpm": {
33+
"overrides": {
34+
"vite": "npm:rolldown-vite@7.2.5"
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)