-
Notifications
You must be signed in to change notification settings - Fork 70
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
Build error on rebuild after code update #129
Comments
I just spent a while debugging this, because it's been driving me insane too, wth the two processes trampling over each other, corrupting the output, and crashing my Typescript watcher. I had all sorts of theories: editor code formatting, WSL filesystem race conditions, plugin bugs... but it turns out that Next.js just initializes webpack twice. Topically, this rant about SSR and function colors was shared today. Fortunately, we can pull an module.exports = {
webpack(config, { isServer }) {
// ...
if (!isServer) {
config.plugins.push(
new WasmPackPlugin({
crateDirectory: resolve("./rust"),
outDir: resolve("./rust/pkg"),
args: "--log-level warn",
}),
);
}
// ...
}
} |
Thanks you very much for your help. What you are saying totally make sense and match with what I've experimented 🤓 . I will test it later today and close this issue if it works 🚀 . |
I tested it and your suggestion fix the problem of double compilation. Thanks you very much. But sadly, I still got some errors on the library rebuild but on my personal work not the example repository so I will work on this bug to try to debug/reproduce it so I can ask again. Until I provide more details with a reproducible repo, here is the current behavior of my personal project: The rust crate use the web audio api. The next app actually doesn't old that much of logic but display the module available on the web audio api thought the wasm library. And I load / use the wasm library in a component that has SSR disable It alternate between two errors: The same error as before that seems to appear after some rebuild not the first one: And this one:
Again I will try to provide a reproducible repository as soon as possible. |
Hey I m back, I have successfully reproduced the bug thanks to rustwasm game of life: https://github.com/rustwasm/wasm_game_of_life . You can test it on the same repository and same branch: https://github.com/Arcahub/rust-wasm-next-nx/tree/feat/webpack It seems that it came from the "life time" of the wasm module that is still in use while the plugin rebuild it and make the error happens. Is there a possibility to put on hold the process of the development server while wasm-pack rebuild the library and then restart the development server ? If you have any other ideas I would happily test them. |
Hello,
I'm using your plugin in a Next application to build a rust library in wasm. I'm using @nrwl/nx to manage my monorepo and both the Nest app and the rust lib are integrated in it.
But I encounter a problem when developing my application. Every time I modify the rust code the plugin attempt to rebuild the wasm library, that is really cool but it always ends with this error:
Error: invalid type: sequence, expected a string at line 4 column 11
The wasm lib is not updated and so I need to restart the application.
To be honest, I don't know if the problem laid in @nrwl/nx file structure or in Next or in your plugin but since the plugin in the main actor you may have some ideas about why it is not working.
I've a test repository with a branch named
feat/webpack
: https://github.com/Arcahub/rust-wasm-next-nx/tree/feat/webpackYou can clone the repository, checkout the branch
feat/webpack
and then runyarn nx serve my-next-app
to start the development server. The application is located inapps/my-next-app
and the rust library is inlibs/my-rust-lib
.To reproduce the bug, after you have started the development server, you can edit the file
libs/my-rust-lib/src/lib.rs
, save it and then you should have an error like the one I send earlier.Note: The compilation seems to run two times, I don't think it's wanted but that may be link to my problem.
Thanks for reading, if you have any question feel free to ask me.
The text was updated successfully, but these errors were encountered: