Skip to content

Update main yew examples (remove static dir)#1417

Merged
siku2 merged 14 commits into
yewstack:masterfrom
philip-peterson:peterson/remove-static-dir
Jul 22, 2020
Merged

Update main yew examples (remove static dir)#1417
siku2 merged 14 commits into
yewstack:masterfrom
philip-peterson:peterson/remove-static-dir

Conversation

@philip-peterson
Copy link
Copy Markdown
Contributor

Description

Several updates to the main yew examples:

  • Remove centralized static/ directory, in favor of each example directory's static dir
  • Automatically start a webserver after building, and open in browser
  • Update the index.htmls to load the generated JS properly

Fixes #1331

Checklist:

  • I have run ./ci/run_stable_checks.sh
  • I have reviewed my own code
  • [NA] I have added tests

@philip-peterson philip-peterson changed the title Peterson/remove static dir Update main yew examples (remove static dir) Jul 18, 2020
@siku2
Copy link
Copy Markdown
Member

siku2 commented Jul 20, 2020

@philip-peterson Would you mind rebasing this?
I believe these changes are still worth adding even with the advent of #1419.

@siku2
Copy link
Copy Markdown
Member

siku2 commented Jul 20, 2020

This will also break the ci/build_examples.sh script. That script isn't being used and if we want to add checks for the examples in the future we'll have to rewrite it anyway. I think we should remove it entirely.

I did some detective work and the script was added in #1165 where it was originally part of the CI but the same PR also removed it from the Travis configuration and it's been sitting there unused ever since.

@siku2 siku2 mentioned this pull request Jul 20, 2020
@philip-peterson philip-peterson force-pushed the peterson/remove-static-dir branch from 69b5c2c to 555bbce Compare July 21, 2020 05:30
@philip-peterson
Copy link
Copy Markdown
Contributor Author

@siku2 Done!

Copy link
Copy Markdown
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge step-up from what we currently have. Thanks!

The reason there are so many comments for the Python file is because I want to keep the code style consistent.
I realise that it's kind of silly to be pedantic about it though so I only left comments with suggestions so they can easily be applied.
The file used both double and single quotes for strings. I replaced all instances with double quotes, not only because of my personal bias but also because it's more in-line with a Rust codebase.

Comment thread examples/run_example.sh Outdated
Comment thread examples/run_example.sh
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
Comment thread examples/start_example_server.py Outdated
@siku2
Copy link
Copy Markdown
Member

siku2 commented Jul 22, 2020

I noticed that after stopping the server the script still prints:

[ Finished! Run EXAMPLE by serving the generated files in examples/static/ ]

as part of the EXIT trap.

Since I didn't want to hold this back another day I just made the edit myself. I hope you don't mind.

@siku2 siku2 merged commit 309dbcb into yewstack:master Jul 22, 2020
@siku2
Copy link
Copy Markdown
Member

siku2 commented Jul 22, 2020

@philip-peterson I just noticed that the web server always adds ; charset=utf-8 to the content type header regardless of the mime type. The charset parameter should only be added to MIME types whose main type is text[1].

This isn't a big issue, the examples still run perfectly fine. I only noticed because it logs a warning:

WebAssembly.instantiateStreaming failed because your server does not serve wasm with application/wasm MIME type. Falling back to WebAssembly.instantiate which is slower. Original error:
TypeError: Response has unsupported MIME type wasm.js:242:29

This is entirely on me for not noticing sooner, sorry about that.

jstarry pushed a commit that referenced this pull request Aug 16, 2020
* remove static directory, move script to run_example.sh

* gitignore

* server infra

* Support --build-only

* fix npm_and_rest example

* Fix various static index.html's

* Fix spacing

* newlines at the end

* Cleanup

* tabs -> spaces

* line ending

* remove build_examples.sh

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* format file and improve EXIT trap

Co-authored-by: Simon <simon@siku2.io>
teymour-aldridge pushed a commit to teymour-aldridge/yew that referenced this pull request Sep 1, 2020
* remove static directory, move script to run_example.sh

* gitignore

* server infra

* Support --build-only

* fix npm_and_rest example

* Fix various static index.html's

* Fix spacing

* newlines at the end

* Cleanup

* tabs -> spaces

* line ending

* remove build_examples.sh

* Apply suggestions from code review

Co-authored-by: Simon <simon@siku2.io>

* format file and improve EXIT trap

Co-authored-by: Simon <simon@siku2.io>
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.

Example static files are ignored by the build.sh script

2 participants