-
Notifications
You must be signed in to change notification settings - Fork 9
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
Error when bundling with webpack #2
Comments
Hi, glad to hear it's useful :) Thank you for attaching the project. I'm not an expert in how different modules are resolved in different bundlers (it's a mess), but I'll give it a look. |
@ostryhub It seems the source of the issue is that Javascript "glue" code generated by Emscripten messes up with Webpack mechanisms, see webpack/webpack#7352. I've tried building the library with The problem is that I cannot use this build config since that would break node compatibility (which at least the library tests require). I suggest either changing your bundler to e.g. Vite, or try some of the suggestions in the mentioned issue. Alternatively, you may create a separate fork of this library with the altered build config, the change is in I might also investigate if there is a way to include multiple different wasm builds into the library. That could also fix your problem. |
@thes01 Thank you for such a quick answer and looking into the problem. Regarding the multi wasm build, I am unabe to help unfortunately, but maybe checking this great occt wasm port https://github.com/donalffons/opencascade.js/ could shed some more light on the possible configuration. |
Yes, no problem :). In OpenCascade.js, it seems that they ship just one build with the possibility of customization. (But anyway, there is a pretty nice process of the build configuration, which I might apply to planegcs as well) I think it could be possible to just include multiple .wasm builds in the library (at least one for the browser-only). And then by using the locateFile argument, you could choose, which wasm variant to load. |
The web build did work when packaged into UMD module with webpack.
I am loading this UMD module into a vanialla v8 JS runtime and what also helped me a lot is this single file option that emdeds the wasm file as base64 encoded string into the js module loading file
Vanilla v8 doesn't have Base64 atob decoder needed for embedded wasm loading, so one last thing one needs is to include the Base64 js library and expose it as global atob variable, like so:
Thank you @thes01 for the help and this wrapper again! |
Hi, great wrapper around PlaneGCS, something I was looking for a long time, thank you for putting this project together!
I am trying to use this npm module in my js lib I am packing with webpack as UMD module.
When I try to build with this this package installed and imported I do get an error about module resolution.
In particular it complains that:
Does it have to do with how target javascript version emscripten is confoigured for ES5/ES6 and new js modules vs commonJS ?
Any pointers on why this happens and potentially how to solve would be greatly appreciated!
the test project attached as zip
planegcs-js.zip
The text was updated successfully, but these errors were encountered: