Just an update, I found a quick and dirty way to achieve this:

<script type="module">
        import * as PIXI from './pixi.mjs';
        window.PIXI = PIXI;
</script>

The pixi library can now be accessed from c++ by using 'emscripten::val 
pixi = val::global("PIXI")*'*
This isn't a good solution since it makes PIXI global including it inside 
the window object. I think there are better ways to do this, but I couldn't 
find any on the official emscripten documentation.

Il giorno domenica 9 aprile 2023 alle 20:31:53 UTC+2 vitopigno ha scritto:

I want to import an external JavaScript library (in this case Pixi.js, the 
module version if
possible) when compiling with emscripten, making it avaible to use inside 
JavaScript functions, for example:
#include <emscripten.h> int main() { EM_ASM( // Start PIXI.js let app = new 
PIXI.Application({//...}); ); return 0; }I have some experience with c++ 
and emscripten but I never tried to make c++ work with JavaScript so this 
code could be probably wrong. But I couldn't find anything about this other 
than some mentions on some GitHub posts. Did someone ever tried to do this? 
If yes could making a Pixi program inside c++ or at least importing a 
larger library without declare every function be feasible? 

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/e3c05a5a-1fcf-4af2-8b51-cd71ee4a53cen%40googlegroups.com.

Reply via email to