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

Use --target web to reduce complexity of "Hello World" (cut down on tools needed to start) #181

Open
kud1ing opened this issue Jul 27, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@kud1ing
Copy link

kud1ing commented Jul 27, 2019

Suggested instructions that don't need a generator or a bundler:

<html>
  <head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
  </head>
  <body>
    <script type="module">
      import init, { greet } from './pkg/hello_world.js';

      async function run() {
        await init();

        greet("World");
      }

      run();
    </script>
  </body>
</html>
  • open index.html in a browser
@kud1ing
Copy link
Author

kud1ing commented Jul 27, 2019

Note:

[Error] Origin null is not allowed by Access-Control-Allow-Origin.
[Error] Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. (hello_world.js, line 0)
[Error] TypeError: Cross-origin script load denied by Cross-Origin Resource Sharing policy.
	promiseReactionJob

@kud1ing kud1ing changed the title Suggestion for a simple hello_world Suggestion for a simple hello_world instructions Jul 27, 2019
@kud1ing kud1ing changed the title Suggestion for a simple hello_world instructions Suggestion for a simple hello_world example Jul 27, 2019
@kud1ing kud1ing changed the title Suggestion for a simple hello_world example Suggestion for a simple wasm-bindgen hello_world example Jul 27, 2019
@fitzgen
Copy link
Member

fitzgen commented Jul 29, 2019

This is pretty close to what we already have here: https://rustwasm.github.io/docs/book/game-of-life/hello-world.html

The main difference is that it doesn't use --target web, but we would like it to eventually. The main thing blocking switching the tutorial to using --target web is the addition of watch and serve subcommands to wasm-pack, so that we don't regress dev server and file watching fromt he developer experience.

Since we don't have an issue open in the book repo to track this, I'll make this issue be that.

@fitzgen fitzgen added the enhancement New feature or request label Jul 29, 2019
@fitzgen fitzgen changed the title Suggestion for a simple wasm-bindgen hello_world example Use --target web to simplify tutorial / cut down on tools needed to start Jul 29, 2019
@fitzgen
Copy link
Member

fitzgen commented Jul 29, 2019

Upstream blockers:

rustwasm/rfcs#10

rustwasm/wasm-pack#457

@kud1ing
Copy link
Author

kud1ing commented Jul 29, 2019

I appreciate this, OTOH:

  • a typical C "Hello world" requires about 2 things: a text editor and a C compiler/linker.
  • a minimal WASM with Rust "hello world" would require about 3 things: a text editor/git client, Rust and wasm-bindgen.
  • The current "hello world" asks the reader to install a project generator and an advanced development tool. I would reserve that to later.

I am not a newcomer to Rust, but i've struggled for about 1 hour to figure out how to get the current "hello world" working without installing tools i don't understand the need for.

It' s subjective. I prefer to learn bottom up, from the simple towards the complex.

@kud1ing
Copy link
Author

kud1ing commented Aug 9, 2019

@kud1ing kud1ing changed the title Use --target web to simplify tutorial / cut down on tools needed to start Use --target web to reduce complexity of "Hello World" (cut down on tools needed to start) Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants