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

Add "Hello world" example for build_node_compilers #17

Open
pulyaevskiy opened this issue Apr 4, 2018 · 7 comments
Open

Add "Hello world" example for build_node_compilers #17

pulyaevskiy opened this issue Apr 4, 2018 · 7 comments

Comments

@pulyaevskiy
Copy link
Owner

Requested in #15 (comment).

@pulyaevskiy
Copy link
Owner Author

Could probably just copy-paste e2e_interop_test to build_node_compilers/example/.

@chalin
Copy link

chalin commented Apr 4, 2018

It takes all that just to translate void main() => print('Hello world');?

@pulyaevskiy
Copy link
Owner Author

Not sure if I'm following, sorry. Could you be more specific about "all that"?

A minimal project would have to consist of at least:

  1. pubspec.yaml with dependency on the compilers package
  2. build.yaml to configure compilers
  3. node/main.dart with "hello world" code

@chalin
Copy link

chalin commented Apr 4, 2018

Ok, that's looking good. Do the files need to be under node? Might it be possible / make sense to use build_node_compilers without node_interop (e.g., I'd assume that print() might just map to console.log())? Thanks

@chalin
Copy link

chalin commented Apr 4, 2018

(Oh, and by "all that", I was expressing my hope that a minimal "hello world" example might indeed contain fewer files. :)

@pulyaevskiy
Copy link
Owner Author

a minimal "hello world" example might indeed contain fewer files.

Sorry, I wasn't clear. :) What I really meant by "copy-paste" is "copy-paste and cleanup by removing extra stuff".

Do the files need to be under node?

This is convention I'm trying to follow (and promote). Similarly how web projects put their entrypoints inside web. You probably can put your entrypoints in some other fodler but this would require more configuration in build.yaml.

Note: by "entrypoint" I mean a Dart file containing main function. Everything else can and should go in lib/ as usual.

Might it be possible / make sense to use build_node_compilers without node_interop.

Possible - yes, using node_interop is completely optional.
Makes sense - depends on your use case, I guess. If you don't need to access any Node-specific APIs then yeah, you can just write plain Dart code, compile and use in Node.

node_interop itself is purely bindings to Node APIs.

You are also free to define your own Node API bindings and use those instead of node_interop.

@chalin
Copy link

chalin commented Apr 5, 2018

What I really meant by "copy-paste" is "copy-paste and cleanup by removing extra stuff".

That sounds good! And thanks for answering my questions.

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

No branches or pull requests

2 participants