COMMUNITY

Multi-target *.hxml not correctly acknowledged in vshaxe

Hi,

When I use an *.hxml file that contains more than one target, like so:

-cp src
-D analyzer-optimize
-main Main
-dce full
-cmd start "" "C:\Program Files\Mozilla Firefox\firefox.exe" "http://localhost/index.php"
--each
-js bin/Commerce.js
--next
-lib easylog
-php bin

the vshaxe extension doesn’t seem to acknowledge the second target at all.

In this case, the php target doesn’t get compiled, and errors in my php-targeted haxe source code don’t get picked up; i.e., the -cmd gets executed anyway, as if all compilations were successful.

Also, the php-targeted source code is dimmed.

If I swap the js and php targets around, then only the php target gets compiled, and the js target is completely ignored, and dimmed.

Is this as expected?

The HaxeDevelop IDE does this correctly, i.e. it will compile the targets, and will un-dim them.

But I don’t want to use HaxeDevelop, I want to use vshaxe on VS Code…

How to correct this behaviour?

Many thanks in advance :slight_smile:

Yes, code completion doesn’t support --next. It should work fine for compilation though.

Pretty sure HaxeDevelop doesn’t “dim” anything in the first place? :wink: Compiler completion still won’t work in those inactive blocks, HaxeDevelop just doesn’t tell you.

Sometimes it does, and sometimes it doesn’t; it’s entirely unpredictable.

Sometimes with errors in the source code, -cmd still runs; sometimes with no errors in the source code, -cmd doesn’t run…

What I need is some way to check where all this flakiness is coming from…

It’s extremely frustrating, and I am not getting any work done whatsoever.

Yeah, it seems you’re right, I remembered that incorrectly.

HaxeDevelop does however compile both targets, something VS Code / vshaxe doesn’t always do (or maybe it does but then refuses to execute -cmd), see above.

For completion, you really need one .hxml file per target or else the compiler gets really confused. You can still have a separate .hxml for actually building everything.

1 Like

As @Simn stated using separate hxmls will be easier, as long as you don’t do it too often you can switch the hxml used in the status bar and it’s not too much of an issue.
But if you need to switch between the js and php part very quickly there’s no good solution.

Your hxml as an issue, the --cmd is run for both the js and php compilation, which is probably not what you want, the webpage might be loaded before the php finished compiling.
I suggest moving this as the last line of your hxml.

1 Like

Many thanks, yes, I will adjust my workflow :slight_smile:

Thank you.

Yes, I think getting rid of my all-encompassing “all.hxml” in favour of just having the js.hxml and php.hxml will probably be the road to less frustration.

I will adjust my workflow.

I’ll adapt :slight_smile:

I’m writing a web framework where there will be messages going back and forth between client and server, so there is a lot of switching between php and js, but I’ll manage :slight_smile:

Ah, I didn’t realise the order of things contained within separate --each and --next sections matters.

But if I stick with just the js.hxml and php.hxml then it won’t matter :slight_smile:

By the way, does haxe have a “live/hot reload” mode, where haxe is basically always running and it can e.g. automatically refresh the browser, like Svelte has with “npm run dev”?

Two options for live/hot reload:

Of course, I advise you to opt for the first option.

2 Likes

Not hot reload but if you want something really quick to setup the firefox debugger for vscode can reload the tab when a path specified changed: https://github.com/firefox-devtools/vscode-firefox-debug#further-optional-configuration-properties the reloadOnChange.
Very basic but might be enough.

Note that when using this extension you need to configure it to use a different port, by default it uses the same as haxe and doesn’t work.

2 Likes