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

Introduce Vite #19

Merged
merged 5 commits into from
Sep 23, 2023
Merged

Introduce Vite #19

merged 5 commits into from
Sep 23, 2023

Conversation

surma
Copy link
Contributor

@surma surma commented Sep 23, 2023

This PR introduces Vite as the build system for RGBDS Live.

I tried to do minimal changes to the code, so currently there’s still lots of globals and stuff, but the PR got big enough as it is. This already does some nice optimizations in that it bundles all the JavaScript and CSS files and minifies them, which should make the site load faster.

These are the changes introduced by this PR:

  • Move website code to top-level so that the vite can put the bundled and optimized build into www.
  • Make this a “proper” JS project by using package.json to import vite and to declare npm run build and npm run dev build scripts.
  • add -s EXPORT_ES6=1 to Wasm builds so that the output is a ES6 module. This makes it easier to use the Wasm builds with vite.
  • add -s ENVIRONMENT=web to rgbds builds so that the JS files don’t contain references to Node runtimes.
  • type="module" which allows us to use ESM imports/exports in the code and will allow us to use top-level await in the future.
  • Explicitly use globalThis to declare globals as ES6 modules have an isolated global scope by default.
  • Remove script includes for Wasm builds and import their ES6 modules where they are used instead.

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

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

LGTM! I guess we're just missing the updated build command in the CI?

@surma
Copy link
Contributor Author

surma commented Sep 23, 2023

Calling ./build.sh is still the right thing to do, exactly so that CI keeps working. Is it broken?

@avivace
Copy link
Member

avivace commented Sep 23, 2023

build.sh is not called at all atm in the CI, as all the final files would end up in the www folder anyway, so we need another step after the wasm builds to call build.sh

edit: I added it in d07f634

@avivace avivace merged commit a98b9c3 into gbdev:master Sep 23, 2023
@avivace avivace mentioned this pull request Sep 23, 2023
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.

2 participants