Hello,
On CMake-based projects where I want to keep separate the web app
code (= several vanilla JS files) from the various emscripten
modules that are used (= several emscripten-generated JS/wasm), I
conveniently use Closure as provided by Emscripten directly from
my CMakefile to bundle/optimize the web app code.
=> CMakeList.txt is looking like:
add_executable(<my_emscripten_module_1> file_1.cpp file_2.cpp --closure 1) # => my_emscripten_module_1.js/wasm add_executable(<my_emscripten_module_2> file_3.cpp file_4.cpp --closure 1) # => my_emscripten_module_2.js/wasm add_custom_target(<my_webapp_using_the_emscripten_modules> COMMAND "java" "-jar" "$ENV{EMSDK}/upstream/emscripten/third_party/closure-compiler/compiler.jar" "--js" "<file_1>.js" "--js" "<file_2>.js" "--js_output_file" "<my_webapp_using_the_emscripten_module>.js" "--language_in=ECMASCRIPT_2017" "--language_out=ECMASCRIPT_2017" "--compilation_level" "<BUNDLE|SIMPLE|ADVANCED>" DEPENDS <my_emscripten_module_1> <my_emscripten_module_2) # => my_webapp_using_the_emscripten_modules.js
Then, to build the app, I just have to do:
make <my_webapp_using_the_emscripten_modules>
And pretty much, that's it, the 3 bundles are created: the web
app code (closure optimized/bundled vanilla JS), the emscripten
module 1 (closure optimized generated JS+wasm), and emscripten
module 2 (closure optimized generated JS+wasm)
I find this very convenient to do, as it allows to do everything
from CMake, and without having to use another module bundler
(Webpack, and co.) and the full node/npm ecosystem that I simply
don't need. I admit it feels a bit old-school/an heterodox way of
doing things on the Web (using Make!?), but I find this much more
in spirit with the C++ way of building projects. After all, we
are using Emscripten for a reason, isn't it ?
But I suppose that scenario would be feasible also if Closure was
provided through npm and not through a .jar directly in Emscripten
distribution (I would have to call some npm command for this,
right ?). I can live with a scary 'node_module' folder ;)
Cheers,
gabriel
--
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-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B6sJ-2YQX9ku%3DPrwhDP0pnNoRZGjF8WtEnRPPMp0jFXJ-6Fsw%40mail.gmail.com.
If this change does not impact end-users of Emscripten, that just
want to do C++ development targeting WebAssembly, then this is
perfectly fine. This change would just be an EMSDK
"implementation detail", and I agree that from this point of view,
removing the Java dependency is interesting.
However, if the users are expected to use Node/npm at some point, then please, please, don't do this :) Not everyone is willing to / can use the Node/npm ecosystem on the projects they are working on.
An alternative suggestion: instead of having to rely on 3rd party
distribution system, why not "precompile/bundle" closure (as well
as minify-html, or any other 3rd party dep), and use a more
classic CDN-approach to deliver these big files. This would
remove the need for a package management system (npm, or even PIP
if you have the same idea for Python tools) running on users
machine... and potentially breaking for various reasons (network
failures, misconfiguration of PATH, weird interaction with
system-wide installation of Node/npm, etc..)
Cheers,
Gabriel
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpQOBVM6EHiVZwrwGmD_Qub-koAFey%3DLLq_uHXi12E4-RQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/549820ac-3512-3b28-4dca-ec47892848ef%40gmail.com.
Well... Git LFS is one solution, but maybe not the easiest one to
handle for the devs.
But a simple file server with a nice directory structure
containing each precompiled/packaged 3rd party dependency is
another alternative (just have to be correctly tag/name the
folders and files, so that Emsdk can download the correct versions
according to the Emscripten release being pulled). Put it
differently, the simplest thing that could possibly work.
By doing so, there is some "reinvent the wheel" syndrome , as npm/pip/etc. are already addressing such kind of needs (manage packages/dependencies/delivery/etc.). The issue is that they are heavily tied to their own respective language/platforms (be it Node, Python, etc.). I wonder if there exist some kind of package management system that is programming language-neutral (and OS neutral also), and only focusing on having a bunch of files to be installed in a particular location according to some spec in a git branch. Basically, this is the need there.
But of course, I am probably not the right person to take any decision on this :)
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGbSVvrHo2PTjqyTsAHyVfyURjH7pNc0%2BTp-EeGAjJtOxw%40mail.gmail.com.
--
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-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B6sJ-2kMqBLJ%3D-3zjRFGTYM8yLOZOFx4ALhXrudWtXu-HyXNQ%40mail.gmail.com.
--
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-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/982257b1-153e-eb6b-db22-4385f3ae1b19%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGYR3xrSVT52Rd1jJ9dFiwHyO-8oeVHqHYHhvk8hgEZxPA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpSMQQK4g%2BoLK5r32OXjq7nWr4YCMF52s63sc_V1%2B7aRgg%40mail.gmail.com.