Code Monkey home page Code Monkey logo

seed-quickstart's People

Contributors

azzamsa avatar ben-ph avatar brandondong avatar coalunicorn avatar david-oconnor avatar drmason13 avatar eopb avatar frozar avatar gemmaro avatar martinkavik avatar naufraghi avatar pingiun avatar tshepang avatar whazor avatar zakaluka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

seed-quickstart's Issues

use cargo generate for templating

Cargo generate is a cargo subcommand for templating new projects.

Integrating with it should only require a few changes to cargo.toml and then anyone who uses cargo-generate will be happy :)
I'd like to make a pull request for these.

Example usage of cargo generate to use this quickstart:

cargo generate --git https://github.com/seed-rs/seed-quickstart --name my-new-seed-project

Wasm-pack installation required

Related PR from Seed repo: seed-rs/seed#185

quickstart's Makefile.toml:

[tasks.create_wasm]
description = "Build with wasm-pack"
install_crate = "wasm-pack"
command = "wasm-pack"
args = ["build", "--target", "no-modules", "--out-name", "package", "--dev"]

[tasks.create_wasm_release]
description = "Build with wasm-pack"
install_crate = "wasm-pack"
command = "wasm-pack"
args = ["build", "--target", "no-modules", "--out-name", "package"]

also quickstart's Makefile.toml:

[tasks.test]
description = "Run tests. Ex: 'cargo make test firefox'. Test envs: [chrome, firefox, safari]"
clear = true
workspace = false
install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }
command = "wasm-pack"
args = ["test", "--${@}"]

See install_crate. The first two tasks should be probably updated with

install_crate = { crate_name = "wasm-pack", binary = "wasm-pack", test_arg = "-V" }

Tips for improvements

RealWorld example is based on this quickstart, so I want to write a list of changes / missing features before I forget:

  1. Some copy & pasted task descriptions in Makefile.toml doesn't make sense in quickstart's context (e.g. "Run Seed's tests. Ex:..").
  2. Missing tasks for linting and CI like clippy, fmt, verify, verify_only, ..
  3. Missing default rustfmt.toml, .travis.yml and maybe netlify.toml.
  4. wasm-bindgen-test is missing in dev-dependencies.
  5. cargo make watch builds before starting watcher so its annoying if you have more compilation errors and want to start watcher for easier debugging.
  6. Missing auto-reload. Temporary solution probably can be http://livereload.com/. I found only https://gitlab.com/MJDSys/reload-rs in Rust world which should do what we want but its a little bit older and it has probably incompatible license.
  7. Minification / uglify - its a relatively big problem, RealWorld's first start is quite slow.
    1. Minification/Uglify for CSS/HTML/JS - I don't know if something in Rust exists.
    2. Optimize *.wasm size (it's possible to strip several hundred of KBs):
      1. The first way is easy - just add compiler flags (see the end of RealWorld's Cargo.toml, opt-level should be s or z ).
      2. The second way is to call external optimizer https://github.com/WebAssembly/binaryen#wasm-opt. It's written in C++ so it cannot be used directly but if I remember correctly there were some plans to integrate it into wasm-pack. Or it can be probably installed with cargo-make. I'm using NodeJS API wrapper - see this script in seed-quickstart-webpack.

Watch task - autoinstall cargo-watch

Nice addition. Ideally, it would automatically install cargo-watch, but I've been unable to get it to do so; must install explicitly before.

I tried to uninstall cargo-watch and then run cargo make watch - it fails with a cargo-watch compilation error, because cargo-make installs version 7.0.8 (see source code) which seems to be buggy. The latest version 7.2.1 works for me.

[tasks.watch]
description = "Build, and create wasms, then watch files for changes"
workspace = false
dependencies = ["build", "create_wasm"]
watch = { ignore_pattern="pkg/*", version="7.2.1" }

If it's working for you as well, please, create issue in cargo-make repo.

Part of 0.7.0 revamp: Refer to website for instructions?

The website provides more context and referring to that could could prevent duplication issues.

The Readme in this repo could serve for more conceptual content, with things like instructions, guides, etc., managed from the site and linked to.

Change type Model = i32 to struct Model { counter: i32 } in App 1: Counter

I think using this pattern doesn't make it obvious for how users might expand on the example. If a user does decide to use a struct as their model, the code written in update and view also need to updated, while not always obvious. For example, a user might try to do this:

struct Model {
    name: String,
}
fn view(model: &Model) -> Node<Msg> {
    div![
        button![model],
    ]
}

...and not realize that you can't use model in this way as you could when it was a type alias. I think more modular the first example is the best it is for the user experience.

Error when add [dependencies] mongodb="0.9.0" to Cargo.toml

When I add mongodb to the dependencies, like this,
[dependencies]
mongodb = "0.9.0"
and then run cargo make watch in the terminal, then, so many errors occurs, like this,

    error[E0425]: cannot find value `IPV6_V6ONLY` in this scope
       --> C:\Users\zh\.cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.34\src\ext.rs:871:50
        |
    871 |         get_opt(self.as_sock(), v(IPPROTO_IPV6), IPV6_V6ONLY).map(int2bool)
        |                                                  ^^^^^^^^^^^ not found in this scope

    error[E0425]: cannot find value `SOL_SOCKET` in this scope
       --> C:\Users\zh\.cargo\registry\src\github.com-1ecc6299db9ec823\net2-0.2.34\src\ext.rs:879:33
        |
    879 |         get_opt(self.as_sock(), SOL_SOCKET, SO_ERROR).map(int2err)
        |                                 ^^^^^^^^^^ not found in this scope

......

Add task build_dist

Example:

[tasks.build_dist]
description = "Build with wasm-pack in release mode and move important files to dist folder"
dependencies = ["build_release"]
script = [
'''
#!@duckscript
rm -r dist
mkdir dist
cp public dist
cp netlify.toml dist/netlify.toml
cp index.html dist/index.html
cp pkg/package.js dist/pkg/package.js
cp pkg/package_bg.wasm dist/pkg/package_bg.wasm
'''
]

Invalid paths when deployed to project's GitHub Pages

Hello, guys. I'm not very js-guy, and I have tried to make a little project with a seed library and publish it as a github.io page.

And i know, that it is not a seed bug, but can you help me to understand, how to import the package.js correct way? Every time I have 404 error because of when i opens my github.io page from the browser, it is makes next get request for package.js:

GET https://ivmazurenko.github.io/pkg/package.js
But as I understands, it should make
GET https://ivmazurenko.github.io/protodec/pkg/package.js

So, I have an next structure:
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="css/new.css">    
    <link rel="stylesheet" href="css/app.css">
</head>
<body>
    <section id="app"></section>
    <script type="module">
        import init from '/pkg/package.js';
        init('/pkg/package_bg.wasm');
    </script>
</body>
</html>

And the pkg directory in entire repository is published like this:

.
├── build.rs
├── Cargo.lock
├── Cargo.toml
├── css
│   ├── app.css
│   └── new.css
├── index.html
├── Makefile.toml
├── pkg
│   ├── package_bg.d.ts
│   ├── package_bg.wasm
│   ├── package.d.ts
│   ├── package.js
│   ├── package.json
│   └── README.md
├── README.md
└── src

https://github.com/ivmazurenko/protodec is a my pet project, currently my problem is reproducing on it. So, if you can help a little, it will be very nice.

Thanks for any answers!

Build error

Hi!
I try to build the example

cargo build --target wasm32-unknown-unknown

and I got the error:

error[E0107]: wrong number of type arguments: expected 2, found 1
  --> src/lib.rs:29:38
   |
29 | fn update(msg: Msg, model: Model) -> Update<Model> {
   |                                      ^^^^^^^^^^^^^ expected 2 type arguments

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
error: Could not compile `appname`.

Mime-Type problem

Versions

  • Rust v1.38.0
  • cargo make v0.22
  • Commit 2980c62

Steps to reproduce

git clone https://github.com/David-OConnor/seed-quickstart
cd seed-quickstart/
git checkout 2980c62f9f866c3e3e43fddcf13e8add1542036e
cargo make serve

Errors

Firefox:
Bildschirmfoto_2019-10-05_17-30-27
Chromium:
Bildschirmfoto_2019-10-05_17-30-42

error: could not compile `log`

I have run cargo clean, and tried to do cargo c multiple times.
Even desperately restart my machine (sometimes works if there is a problem with cargo).
Now it doesn't.
Am I missing something?

seed-quickstart on  master [!] is 📦 v0.1.0 via 🦀 v1.50.0 took 53s
❯ cargo c
    Checking cfg-if v1.0.0
   Compiling libc v0.2.81
    Checking itoa v0.4.7
    Checking futures-sink v0.3.8
    Checking futures-core v0.3.8
    Checking once_cell v1.5.2
    Checking futures-io v0.3.8
    Checking ppv-lite86 v0.2.10
    Checking pin-utils v0.1.0
    Checking slab v0.4.2
    Checking unicode-width v0.1.8
    Checking hashbrown v0.9.1
    Checking cfg-if v0.1.10
    Checking percent-encoding v2.1.0
    Checking enclose v1.1.8
   Compiling wasm-bindgen v0.2.69
   Compiling getrandom v0.1.16
   Compiling memchr v2.3.4
   Compiling proc-macro-nested v0.1.6
    Checking futures-channel v0.3.8
   Compiling bitflags v1.2.1
   Compiling pulldown-cmark v0.8.0
    Checking futures-task v0.3.8
   Compiling unicase v2.6.0
   Compiling time v0.2.23
   Compiling cookie v0.14.3
   Compiling seed v0.8.0
   Compiling log v0.4.11
    Checking ryu v1.0.5
   Compiling const_fn v0.4.5
   Compiling indexmap v1.6.1
error: unexpected closing delimiter: `}`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/src/macros.rs:181:1
    |
147 | macro_rules! debug {
    |                    - this opening brace...
...
154 | }
    | - ...matches this closing brace
...
181 | }
    | ^ unexpected closing delimiter

error: aborting due to previous error

error: could not compile `log`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Template could be much simpler with `trunk`.

The seed README recommends using trunk to quickstart, but this template doesn't use it. If you do use trunk, much of this template is unnecessary: index.html can be much simpler, Makefile.toml can just be deleted, and you can use a binary project instead of a cdylib.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.