Skip to content

Expose sync/async option when loading bundle - #85

Open
kevinresol wants to merge 1 commit into
elsassph:masterfrom
kevinresol:electron
Open

Expose sync/async option when loading bundle#85
kevinresol wants to merge 1 commit into
elsassph:masterfrom
kevinresol:electron

Conversation

@kevinresol

Copy link
Copy Markdown

This is mainly for electron. Because I would have to add -lib hxnodejs to enable some nodejs API while I still want to load bundles from remote asynchronously.

@elsassph

elsassph commented Aug 24, 2018

Copy link
Copy Markdown
Owner

I'm a bit confused by Electron, shouldn't the election client NOT have the nodejs flag? Because in my understanding Electron is providing a shim node API to the client.
Also this change is going to generate more code for everybody.

@kevinresol

Copy link
Copy Markdown
Author

I simply understand electron as allowing one to run node.js scripts in a html file:

<script>
  var fs = require('fs');
  fs.createReadStream(...);
</script>

So I have always been simply adding -lib hxnodejs and use all the sys/node features in a electron app.

Also this change is going to generate more code for everybody.

Why? the sync flag is evaluated at compile time and the macro only emits either branch of the code.

@elsassph

elsassph commented Aug 24, 2018

Copy link
Copy Markdown
Owner

Aha, pardon my ignorance, so there really is the full node API basically in the browser context?

Because what I've seen is reports that when Haxe thinks it's nodeJS it uses a different Http implementation which doesn't work in Electron...

@kevinresol

Copy link
Copy Markdown
Author

Yes as far as I understand

@kevinresol

kevinresol commented Aug 24, 2018

Copy link
Copy Markdown
Author

I don't know about haxe http, I always use fetch in electron

@elsassph

Copy link
Copy Markdown
Owner

You know we may as well just explicitly #if electron

@elsassph

Copy link
Copy Markdown
Owner

@kevinresol not sure it's still a need for you but -D nodejs should provide you with the synchronous node behaviour you are looking for.

@kevinresol

kevinresol commented Jul 22, 2019

Copy link
Copy Markdown
Author

The problem here is that I need both async and sync in electron.

sync is for loading node modules
async is for loading web modules

@elsassph

Copy link
Copy Markdown
Owner

From last time I did an Electron app you can use the synchronous require both for the server and client side of the apps - or do you intend to use the same build for Electron and a web app?

@kevinresol

kevinresol commented Jul 22, 2019

Copy link
Copy Markdown
Author

As I said in OP I need to load bundles from remote asynchronously. Both sync and async are needed in the same build, a single js output.

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.

2 participants