Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web demo using wasm #1

Closed
lzpel opened this issue Dec 26, 2024 · 4 comments
Closed

Add web demo using wasm #1

lzpel opened this issue Dec 26, 2024 · 4 comments

Comments

@lzpel
Copy link
Owner

lzpel commented Dec 26, 2024

Reference
https://nextjs.org/docs/messages/middleware-dynamic-wasm-compilation

@lzpel
Copy link
Owner Author

lzpel commented Jan 4, 2025

入力テンプレートをパス指定するシステムではファイルを開けないwasm環境でデモが動かない
include_str!マクロを前提としたシステムではbuiltinテンプレートへのパスを隠蔽できない
どうする?

builtin_template(str)->strを作る。内部はinclude_str!

@lzpel
Copy link
Owner Author

lzpel commented Jan 4, 2025

カスタムビルドコマンドをどうやって実行してgh-pagesに挙げるのかが問題

@lzpel
Copy link
Owner Author

lzpel commented Jan 5, 2025

Ref: rustwasm/wasm-bindgen#4211

> next build

   ▲ Next.js 15.1.2

   Creating an optimized production build ...
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|webassembly/async|/home/lzpel/mandolin/demo/lib/wasm_bg.wasm|ssr': No serializer registered for CompileError
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> webpack/lib/ModuleParseError -> CompileError
Failed to compile.

./lib/wasm_bg.wasm
Module parse failed: Internal failure: parseVec could not cast the value
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Error: Internal failure: parseVec could not cast the value
    at parseVec (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:1:119284)
    at parseTypeSection (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:1:119694)
    at parseSection (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:1:134162)
    at Object.decode (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:1:139551)
    at decode (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:1:144834)
    at WebAssemblyParser.parse (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:28:1473078)
    at /home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:28:410486
    at processResult (/home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:28:406448)
    at /home/lzpel/mandolin/demo/node_modules/next/dist/compiled/webpack/bundle5.js:28:407465
    at /home/lzpel/mandolin/demo/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8727

Import trace for requested module:
./lib/wasm_bg.wasm
./lib/wasm.js
./app/compare.tsx


> Build failed because of webpack errors
make: *** [Makefile:12: deploy] Error 1

@lzpel
Copy link
Owner Author

lzpel commented Jan 5, 2025

rustcのバージョンを1.81にダウングレードして動くようになった。完成

@lzpel lzpel closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant