Skip to content
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

Refactor build to use an hxml file #31

Open
elsassph opened this issue Apr 25, 2018 · 5 comments
Open

Refactor build to use an hxml file #31

elsassph opened this issue Apr 25, 2018 · 5 comments

Comments

@elsassph
Copy link
Collaborator

elsassph commented Apr 25, 2018

Currently the build process parses the hxml file and generates arguments list for haxe compilation - this is verbose, doesn't scale well, and has subtle edge case issues (like --macro with quotes in them, see #28).

Is it possible to use the hxml file as is?
It doesn't seem to be possible because we need to replace the JS output target and only a single -js is allowed - maybe using a macro could work? A macro could dynamically replace the output file without touching the hxml

Otherwise we could generate a temporary hxml file
It should include the original hxml content with just the JS output replaced. Other added arguments should still be added to the build command.

@jasononeil
Copy link
Owner

If we use a temporary file, and utilise an NPM like https://www.npmjs.com/package/tmp, we will need to take care to handle any relative paths. It might be easier to create a temporary hxml file in the same directory, and just be careful to clean it up.

If the macro option works that would probably be cleanest though.

@aliokan
Copy link

aliokan commented Apr 26, 2018

I have missed something, or --each and --next will do the job, about the multiple -js?
https://haxe.org/manual/compiler-usage-hxml.html

@elsassph
Copy link
Collaborator Author

@aliokan no, the loader supports only a single JS output, and we need to replace the output target to generate a the file in a temporary location. In a single output, having -js several times (once in the hxml and once as an override) isn't allowed - this is a shame.

@kevinresol
Copy link

Why it is needed to replace the -js path?

Is it possible that haxe-loader parses the input hxml and figure out and use the output path from there?

If the -js tag is from a included hxml, the webpack output would be basically empty, e.g.:

haxe build.hxml

build.hxml:

-cp src
path.hxml
-lib xx

path.hxml:

-js out.js

@elsassph
Copy link
Collaborator Author

elsassph commented Feb 19, 2019

@kevinresol the problem is that the HXML is usually also used for IDE autocomplete as-is, hence why it will usually have a -js otherwise Haxe completion doesn't work. It's very convenient to troubleshoot the build outside Webpack as well. But otherwise we want to completely hide the output.

@jasononeil for HXML the paths are relative to the working directory, not the HXML location, so we wouldn't even have to fix the paths (remember they become literally compiler arguments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants