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

Expose sync/async option when loading bundle #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kevinresol
Copy link

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
Copy link
Owner

elsassph commented Aug 24, 2018

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
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
Copy link
Owner

elsassph commented Aug 24, 2018

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
Author

Yes as far as I understand

@kevinresol
Copy link
Author

kevinresol commented Aug 24, 2018

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

@elsassph
Copy link
Owner

You know we may as well just explicitly #if electron

@elsassph
Copy link
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
Copy link
Author

kevinresol commented Jul 22, 2019

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
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
Copy link
Author

kevinresol commented Jul 22, 2019

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