Commit 7ed10efd authored by Chunchi Che's avatar Chunchi Che

succeed in integrating wasm

parent 507f5eab
Pipeline #20646 failed with stages
in 5 minutes and 45 seconds
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
"react-redux": "^8.0.4", "react-redux": "^8.0.4",
"react-router-dom": "^6.4.0", "react-router-dom": "^6.4.0",
"react-scripts": "^2.1.3", "react-scripts": "^2.1.3",
"rust-src": "file:rust-src/pkg",
"socket.io-client": "^4.5.1", "socket.io-client": "^4.5.1",
"sql.js": "^1.8.0", "sql.js": "^1.8.0",
"vite-plugin-svgr": "^2.4.0", "vite-plugin-svgr": "^2.4.0",
...@@ -22770,6 +22771,10 @@ ...@@ -22770,6 +22771,10 @@
"aproba": "^1.1.1" "aproba": "^1.1.1"
} }
}, },
"node_modules/rust-src": {
"resolved": "rust-src/pkg",
"link": true
},
"node_modules/rxjs": { "node_modules/rxjs": {
"version": "6.6.7", "version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
...@@ -27133,6 +27138,9 @@ ...@@ -27133,6 +27138,9 @@
"funding": { "funding": {
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
},
"rust-src/pkg": {
"version": "0.1.0"
} }
}, },
"dependencies": { "dependencies": {
...@@ -44511,6 +44519,9 @@ ...@@ -44511,6 +44519,9 @@
"aproba": "^1.1.1" "aproba": "^1.1.1"
} }
}, },
"rust-src": {
"version": "file:rust-src/pkg"
},
"rxjs": { "rxjs": {
"version": "6.6.7", "version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
...@@ -30,15 +30,17 @@ ...@@ -30,15 +30,17 @@
"sql.js": "^1.8.0", "sql.js": "^1.8.0",
"vite-plugin-svgr": "^2.4.0", "vite-plugin-svgr": "^2.4.0",
"web-vitals": "^2.1.4", "web-vitals": "^2.1.4",
"ygopro-deck-encode": "^1.0.3" "ygopro-deck-encode": "^1.0.3",
"rust-src": "file:rust-src/pkg"
}, },
"scripts": { "scripts": {
"dev": "vite", "wasm": "cd rust-src && wasm-pack build",
"build": "tsc && vite build && cp -r neos-assets dist/", "dev": "npm run wasm && vite",
"build:prod": "tsc && vite build --base=https://cdn02.moecube.com:444/neos/", "build": "npm run wasm && tsc && vite build && cp -r neos-assets dist/",
"build:prod": "npm run wasm && tsc && vite build --base=https://cdn02.moecube.com:444/neos/",
"preview": "vite preview", "preview": "vite preview",
"lint": "eslint --ext .ts --ext .tsx src", "lint": "eslint --ext .ts --ext .tsx src",
"fmt": "eslint --ext .ts --ext .tsx src --fix", "fmt": "eslint --ext .ts --ext .tsx src --fix && cd rust-src && cargo fmt",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
......
...@@ -9,7 +9,7 @@ use wasm_bindgen::prelude::*; ...@@ -9,7 +9,7 @@ use wasm_bindgen::prelude::*;
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
#[wasm_bindgen] #[wasm_bindgen]
extern { extern "C" {
fn alert(s: &str); fn alert(s: &str);
} }
......
import React, { Suspense } from "react"; import React, { Suspense } from "react";
import { Routes, Route } from "react-router-dom"; import { Routes, Route } from "react-router-dom";
import LazyLoad, { Loading } from "./LazyLoad"; import LazyLoad, { Loading } from "./LazyLoad";
import { greet } from "rust-src";
const Login = React.lazy(() => import("./Login")); const Login = React.lazy(() => import("./Login"));
const WaitRoom = React.lazy(() => import("./WaitRoom")); const WaitRoom = React.lazy(() => import("./WaitRoom"));
...@@ -8,6 +9,8 @@ const Mora = React.lazy(() => import("./Mora")); ...@@ -8,6 +9,8 @@ const Mora = React.lazy(() => import("./Mora"));
const NeosDuel = React.lazy(() => import("./Duel/main")); const NeosDuel = React.lazy(() => import("./Duel/main"));
export default function () { export default function () {
greet();
return ( return (
<Routes> <Routes>
<Route path="/" element={<LazyLoad lazy={<Login />} />} /> <Route path="/" element={<LazyLoad lazy={<Login />} />} />
......
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react' import react from '@vitejs/plugin-react'
import svgr from 'vite-plugin-svgr' import svgr from 'vite-plugin-svgr'
import wasm from "vite-plugin-wasm";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [react(), svgr()] plugins: [react(), svgr(), wasm()]
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment