init runtime with playground

This commit is contained in:
Yanzhen Yu 2021-07-02 18:23:20 +08:00
parent a200468dbb
commit 2fc08d5687
8 changed files with 91 additions and 0 deletions

5
packages/runtime/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>meta-ui runtime example: delete button</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="../../src/main.tsx"></script>
</body>
</html>

View File

@ -0,0 +1,18 @@
{
"name": "@meta-ui/runtime",
"version": "0.0.0",
"scripts": {
"dev": "vite"
},
"dependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react-refresh": "^1.3.1",
"typescript": "^4.3.2",
"vite": "^2.3.8"
}
}

View File

@ -0,0 +1,19 @@
import React, { useState } from "react";
function App() {
const [count, setCount] = useState(0);
return (
<div className="App">
<header className="App-header">
<p>
<button type="button" onClick={() => setCount((count) => count + 1)}>
count is: {count}
</button>
</p>
</header>
</div>
);
}
export default App;

View File

@ -0,0 +1,10 @@
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);

1
packages/runtime/src/vite-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["./src"]
}

View File

@ -0,0 +1,7 @@
import { defineConfig } from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [reactRefresh()],
});