Frontend:
- Remove we_alloce - Replace webpack by rspack
This commit is contained in:
parent
1f03c01d1d
commit
ebdcb6a90a
10 changed files with 60 additions and 100 deletions
|
|
@ -33,7 +33,7 @@ console_error_panic_hook = { version = "0.1", optional = true }
|
|||
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
|
||||
# compared to the default allocator's ~10K. It is slower than the default
|
||||
# allocator, however.
|
||||
wee_alloc = { version = "0.4", optional = true }
|
||||
# wee_alloc = { version = "0.4", optional = true }
|
||||
|
||||
# [dev-dependencies]
|
||||
# wasm-bindgen-test = "0.3"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
wasm-pack build --target web -- --features wee_alloc
|
||||
wasm-pack build --target web
|
||||
cp pkg/frontend.js ../backend/static
|
||||
cp pkg/frontend_bg.wasm ../backend/static
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
{
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"serve": "webpack serve"
|
||||
"build": "rspack build",
|
||||
"serve": "rspack serve"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rspack/cli": "^1.0.14",
|
||||
"@rspack/core": "^1.0.14",
|
||||
"@wasm-tool/wasm-pack-plugin": "1.5.0",
|
||||
"html-webpack-plugin": "^5.3.2",
|
||||
"text-encoding": "^0.7.0",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^4.10.0",
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
"html-webpack-plugin": "^5.6.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,15 +14,9 @@ module.exports = {
|
|||
new WasmPackPlugin({
|
||||
crateDirectory: path.resolve(__dirname, ".")
|
||||
}),
|
||||
// Have this example work in Edge which doesn't ship `TextEncoder` or
|
||||
// `TextDecoder` at this time.
|
||||
new webpack.ProvidePlugin({
|
||||
TextDecoder: ['text-encoding', 'TextDecoder'],
|
||||
TextEncoder: ['text-encoding', 'TextEncoder']
|
||||
})
|
||||
],
|
||||
mode: 'development',
|
||||
experiments: {
|
||||
asyncWebAssembly: true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::Document;
|
||||
|
||||
pub fn edit_recipe(doc: &Document) {}
|
||||
pub fn edit_recipe(doc: &Document) {
|
||||
let title_input = doc.get_element_by_id("title_field").unwrap();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ mod utils;
|
|||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::console;
|
||||
|
||||
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
||||
// allocator.
|
||||
#[cfg(feature = "wee_alloc")]
|
||||
#[global_allocator]
|
||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
|
|
@ -27,7 +21,7 @@ pub fn main() -> Result<(), JsValue> {
|
|||
|
||||
let window = web_sys::window().expect("no global `window` exists");
|
||||
let document = window.document().expect("should have a document on window");
|
||||
//let body = document.body().expect("document should have a body");
|
||||
// let body = document.body().expect("document should have a body");
|
||||
|
||||
let location = window.location().pathname()?;
|
||||
let path: Vec<&str> = location.split('/').skip(1).collect();
|
||||
|
|
@ -46,14 +40,10 @@ pub fn main() -> Result<(), JsValue> {
|
|||
console_log!("recipe edit ID: {}", id);
|
||||
|
||||
handles::edit_recipe(&document);
|
||||
|
||||
let title_input = document.get_element_by_id("title_field").unwrap();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
//alert(&path);
|
||||
|
||||
// TEST
|
||||
// let val = document.create_element("p")?;
|
||||
// val.set_inner_html("Hello from Rust!");
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
# See 'package.json'.
|
||||
npm run serve
|
||||
Loading…
Add table
Add a link
Reference in a new issue