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

[refactor] overhaul bundle & run cli commands #58

Closed

Conversation

FaberVitale
Copy link
Contributor

@FaberVitale FaberVitale commented Sep 4, 2021

Description

This is an ongoing effort to overhaul run and bundle commands.

Goals

  • run & bundle should reuse the same config provided by runtimes/web/webpack.config.js.
  • add more configuration options to bundle.
  • other? Feedback and suggestions are welcomed!

To do

  • refactor: ovehaul runtimes/web/webpack.config.js
  • refactor: Use runtimes/web/webpack.config.js in cli/lib/bundle.js.
  • refactor: Use runtimes/web/webpack.config.js in cli/lib/server.js.
  • refactor: Move z85 encoder & decoder to its own module.
  • feat: Add bundle options description title favicon.

Changes

* adds configurable favicon.ico

* add build date and WASM4 version metadata

* add configurable title

* add configurable description

* runtime/web can now optionally (see build:inline) inline wasm4.js, wasm4.css and the cartridge

* faster HTML loading time when inlining the cartridge.

References

* https://v8.dev/blog/cost-of-javascript-2019#json

* script[type="application/json"] -> https://www.youtube.com/watch?v=ff4fgQxPaO0

* https://underscorejs.org/#template

* https://lodash.com/docs/4.17.15#template
@netlify
Copy link

netlify bot commented Sep 4, 2021

✔️ Deploy Preview for wasm4 ready!

🔨 Explore the source changes: ad9d29b

🔍 Inspect the deploy log: https://app.netlify.com/sites/wasm4/deploys/61335cd28544ce00083aef79

😎 Browse the preview: https://deploy-preview-58--wasm4.netlify.app/embed

@aduros
Copy link
Owner

aduros commented Sep 4, 2021

I think we should avoid adding webpack as a dependency to the CLI. Webpack is a necessary evil for building the JS runtime, but I'd like to keep the CLI as small and dependency-free as possible.

Adding w4 bundle options like description, title, etc. sounds great to me, but I think that can be done with the simple string replacement rather than refactoring to bring in webpack.

@FaberVitale FaberVitale closed this Sep 5, 2021
@FaberVitale
Copy link
Contributor Author

I think we should avoid adding webpack as a dependency to the CLI. Webpack is a necessary evil for building the JS runtime, but I'd like to keep the CLI as small and dependency-free as possible.

Adding w4 bundle options like description, title, etc. sounds great to me, but I think that can be done with the simple string replacement rather than refactoring to bring in webpack.
Fair enough

I'd like to add configurable description, title & favicon but manipulating html with regex can be really problematic.
I think that part really could use a proper html parser and manipulation library like cheerio.

Is cheerio ok? Alternatives?

@aduros
Copy link
Owner

aduros commented Sep 6, 2021

I wonder if it wouldn't be better to include a separate html file for the bundle template. It could be rendered using something like mustache.

That might involve duplicating some parts of index.html, but I feel like it would be much simpler... As an extra, maybe we can move the gamepad divs and other elements that are currently in index.html into the runtime JS to remove duplication.

About the favicon, is it possible to base64 an image data URL to use as the favicon? That would be pretty cool if so!

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.

None yet

2 participants