Skip to content

Commit

Permalink
web: Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahien committed Nov 15, 2024
1 parent 7535065 commit 09716de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
15 changes: 4 additions & 11 deletions src/www/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ use web_sys::{Request, RequestInit, RequestMode, Response};
use crate::*;

pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://github.com/rustwasm/console_error_panic_hook#readme
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
}

Expand Down Expand Up @@ -58,9 +51,9 @@ fn get_canvas(id: &str) -> Result<CanvasRenderingContext2d, JsValue> {
}

async fn get_model() -> Result<Model, JsValue> {
let mut opts = RequestInit::new();
opts.method("GET");
opts.mode(RequestMode::Cors);
let opts = RequestInit::new();
opts.set_method("GET");
opts.set_mode(RequestMode::Cors);

let url = "https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Box/glTF-Embedded/Box.gltf";

Expand Down Expand Up @@ -136,7 +129,7 @@ pub struct Context {
#[wasm_bindgen]
impl Context {
pub async fn new() -> Result<Context, JsValue> {
set_panic_hook();
//set_panic_hook();

let canvas = get_canvas("area")?;

Expand Down
11 changes: 5 additions & 6 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@
"rayca": "file:../pkg"
},
"devDependencies": {
"hello-wasm-pack": "^0.1.0",
"webpack": "^4.29.3",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.5",
"copy-webpack-plugin": "^5.0.0"
"copy-webpack-plugin": "^12.0.2",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
}
}
}
7 changes: 6 additions & 1 deletion www/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ const path = require('path');

module.exports = {
entry: "./bootstrap.js",
experiments: {
asyncWebAssembly: true,
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
plugins: [
new CopyWebpackPlugin(['index.html'])
new CopyWebpackPlugin({
patterns: ['index.html']
})
],
};

0 comments on commit 09716de

Please sign in to comment.