It’s unclear what you are trying to do, what do you mean by “emscripten via javascript”?
If you want to generate javascript from haxe you can use the javascript target -js myfile.js
see Getting started with Haxe/JavaScript - Haxe - The Cross-platform Toolkit you don’t need emscripten at all.
If you need to use hxcpp it can target emscripten with -D emscripten
,
I’ve never tried it so you might need other things, Haxe and Emscripten may have some information.