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

[js] Added "-D js-global" to customizes the global object name #10282

Merged
merged 2 commits into from
Jun 23, 2021

Conversation

R32
Copy link
Contributor

@R32 R32 commented Jun 1, 2021

Related to #10258

It's used in some strange js environments, for example: You can use -D js-global=GameGlobal for WeChat mini-games,

And the one corresponding to AudioWorklet is -D js-global=globalThis

Even for nodejs, the code generated by -D js-global=global is more cleaner when you use @:expose

@R32 R32 changed the title Added "-D js-global" to customizes the global object name [js] Added "-D js-global" to customizes the global object name Jun 1, 2021
@skial skial mentioned this pull request Jun 2, 2021
1 task
@@ -1912,7 +1917,7 @@ let generate com =
in
(* Provide console for environments that may not have it. *)
let closureArgs = if ctx.es_version < 5 then
var_console :: closureArgs
("console", typeof_join ["console"; "{log:function(){}}"]) :: closureArgs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does any js environments miss console implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In IE8/9 the console only works when F12 is pressed

@nanjizal
Copy link
Contributor

I do remember someone targetting Rhino with Haxe, some googling suggests console is not part of standard javascript, and should not be assumed for any js used in embedded systems.
For instance this nashorn example seems to use print.
https://www.javaprogramto.com/2020/08/java-8-nashorn-javascript-with-examples.html
But suspect for most practical uses console can be assumed, but not when JS is implemented more as scripting within another language.

@RealyUniqueName RealyUniqueName merged commit 97fea9c into HaxeFoundation:development Jun 23, 2021
RealyUniqueName added a commit that referenced this pull request Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants