From 904f54c0d55005971c439a6ec30ee3048bba9cd2 Mon Sep 17 00:00:00 2001 From: Rachit Singh Date: Tue, 20 Dec 2022 21:36:44 -0500 Subject: [PATCH] Note down one issue that definitely exists --- README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++ esbuild.config.mjs | 1 + 2 files changed, 68 insertions(+) diff --git a/README.md b/README.md index 710f75a..d094694 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,73 @@ Setting up yarn will install and run the `esbuild-plugin-wasm-pack` plugin, whic To test: try running the "Sample Plugin: Example Command" in the command bar (i.e. Cmd+P); you should see a "hello from rust" message. +Note: currently there is a bug (probably with esbuild-plugin-wasm-pack) where esbuild doesn't wait for output to be generated (I think); the solution for now is just to rerun it: + +```bash +(prod) test_repo> yarn run dev +yarn run v1.22.17 +$ node esbuild.config.mjs + +ℹ Compiling your crate in mode... + +[INFO]: Checking for the Wasm target... +[INFO]: Compiling to Wasm... + Compiling proc-macro2 v1.0.49 + Compiling quote v1.0.23 + Compiling unicode-ident v1.0.6 + Compiling syn v1.0.107 + Compiling log v0.4.17 + Compiling wasm-bindgen-shared v0.2.83 + Compiling cfg-if v1.0.0 + Compiling bumpalo v3.11.1 + Compiling once_cell v1.16.0 + Compiling wasm-bindgen v0.2.83 + Compiling wasm-bindgen-backend v0.2.83 + Compiling wasm-bindgen-macro-support v0.2.83 + Compiling wasm-bindgen-macro v0.2.83 + Compiling js-sys v0.3.60 + Compiling obsidian-rust-plugin v0.1.0 (/Users/rachit/Library/Mobile Documents/iCloud~md~obsidian/Documents/machine learning/.obsidian/plugins/test_repo) + Finished release [optimized] target(s) in 13.54s +node:internal/process/promises:246 + triggerUncaughtException(err, true /* fromPromise */); + ^ + +[Error: ENOENT: no such file or directory, open '/Users/rachit/Library/Mobile Documents/iCloud~md~obsidian/Documents/machine learning/.obsidian/plugins/test_repo/target/wasm32-unknown-unknown/release/obsidian_rust_plugin.d'] { + errno: -2, + code: 'ENOENT', + syscall: 'open', + path: '/Users/rachit/Library/Mobile Documents/iCloud~md~obsidian/Documents/machine learning/.obsidian/plugins/test_repo/target/wasm32-unknown-unknown/release/obsidian_rust_plugin.d' +} + +Node.js v17.0.1 +[INFO]: Installing wasm-bindgen... +error Command failed with exit code 1. +info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. +[INFO]: Optimizing wasm binaries with `wasm-opt`... +(prod) test_repo> [INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended +[INFO]: :-) Done in 13.94s +[INFO]: :-) Your wasm pkg is ready to publish at /Users/rachit/Library/Mobile Documents/iCloud~md~obsidian/Documents/machine learning/.obsidian/plugins/test_repo/pkg. + +(prod) test_repo> yarn run dev +yarn run v1.22.17 +$ node esbuild.config.mjs + +ℹ Compiling your crate in mode... + +[INFO]: Checking for the Wasm target... +[INFO]: Compiling to Wasm... + Finished release [optimized] target(s) in 0.06s +[INFO]: Installing wasm-bindgen... +[INFO]: Optimizing wasm binaries with `wasm-opt`... +[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended +[INFO]: :-) Done in 0.41s +[INFO]: :-) Your wasm pkg is ready to publish at /Users/rachit/Library/Mobile Documents/iCloud~md~obsidian/Documents/machine learning/.obsidian/plugins/test_repo/pkg. + +✅ Your crate was successfully compiled. + +[watch] build finished, watching for changes... +``` + I'm leaving the original Obsidian plugin docs below in case it's helpful: # Obsidian Sample Plugin docs diff --git a/esbuild.config.mjs b/esbuild.config.mjs index 14065f4..5a52665 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -74,6 +74,7 @@ esbuild.build({ plugins: [ wasmPlugin, wasmPack({ + 'target': 'web' // put wasm-pack plugin options }), ],