Skip to content
This repository was archived by the owner on Jul 19, 2020. It is now read-only.
This repository was archived by the owner on Jul 19, 2020. It is now read-only.

The instructions at “Getting Started/Project Setup/Using wasm-pack” are extremely unclear #60

Open
@loewenheim

Description

@loewenheim

I’ve been trying and failing for a while to apply the instructions to the web-sys examples in the yew repository. I’ll take todomvc as an example. Everything up to and including wasm-pack build is fine. The problems start at the next line:

rollup ./main.js --format iife --file ./pkg/bundle.js

Ok, there is no main.js, so maybe I should put pkg/todomvc.js? Well,

> rollup pkg/todomvc.js --file ./pkg/bundle.js

pkg/todomvc.js → ./pkg/bundle.js...
[!] Error: Unexpected character '' (Note that you need plugins to import files that are not JavaScript)
pkg/todomvc_bg.wasm (1:0)
1: asm
…

Ok, so I need to install a wasm plugin for rollup with npm install @rollup/plugin-wasm --save-dev and add a file rollup.config.js containing

import wasm from '@rollup/plugin-wasm';

export default {
  plugins: [wasm()]
};

Now I can run rollup -c rollup.config.js pkg/todomvc.js --file pkg/bundle.js. Cool. The next step is

python -m http.server 8000

(or any other server, as the tutorial notes). Running this and visiting localhost:8000 in my browser shows me the contents of the todomvc directory. Ok, not exactly what I wanted, so I run

python -m http.server 8000 --directory static

because index.html is in the static directory. This time I get a page with the title Yew • TodoMVC, which is good, but the page is entirely blank. The console shows the error message Loading failed for the <script> with source “http://localhost:8000/todomvc.js”., which makes sense to me because todomvc.js resides in pkg. Also, I am now unsure whether using rollup even accomplished anything because I haven’t interacted with bundle.js in any way.

Maybe I’m going about this very stupidly. After all, I am a complete beginner when it comes to any sort of web development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions