Skip to content

Conversation

@RoiArthurB
Copy link
Contributor

Pull Request

Checklist

  • Code is complete and ready for review
  • Tests have been added/updated (if applicable)
  • Documentation has been updated (if applicable)

Description

This PR allow generating single binary application of the webplatform, removing all the difficulties and technical troubles of installing the project.

  • Tested on Linux
  • Tested on Mac ARM
  • Tested on Windows

This PR also adds some operational Github Actions to easily create releases compiling the platform, and trying to compile it on every commit to avoid regression on this.

Finally, this PR adds a lot of code cleanup, especially pro-actively catching a lot of bugs introduced with GAMALESS

Future work

Since the binary can be ran without anything around, a lot of verification should be added to not have the application crashing instantly (like if the folder learning-packages isn't found).

Also, this PR use @yao-pkg/pkg to package the project, however the support for native Mac ARM is experimental and not used at the moment (making the packaged platform running with Rosetta 2), this will need to be updated

- Limited to Linux x86 on Node20 at the moment !
+ Everything documented in BUILD_EXECUTABLE.md

AI Explaination :
1.  **Backend Bundling**:
    - Created a `vite.backend.config.ts` to bundle the TypeScript backend into a single CommonJS file (`dist-api/index.cjs`). This resolves issues with ESM, top-level await, and complex `node_modules` structures when packaging with `pkg`.
    - Dependencies are bundled into the executable (except for native modules), ensuring all assets and subpath imports work correctly.

2.  **Integrated Frontend Serving**:
    - Added `src/api/infra/StaticServer.ts` which uses `express` to serve the built Vite frontend from the bundled environment.
    - Modified `src/api/index.ts` to automatically start this static server when running in a packaged environment or production mode.

3.  **Dynamic Environment Loading**:
    - Updated the `.env` loading logic in `src/api/index.ts` to look for the `.env` file in the same directory as the executable, satisfying the requirement for external configuration.

4.  **Packaging Configuration**:
    - Configured `@yao-pkg/pkg` (a maintained fork supporting Node 20) in `package.json`.
    - Included the built frontend (`dist/**/*`) and the `uWebSockets.js` native binary (`.node` file) as assets in the executable.

5.  **Build Scripts**:
    - Added `npm run build:frontend`, `npm run build:backend`, and `npm run build:executable` to `package.json`.

6.  **Fixes for Bundled Context**:
    - Refactored `src/api/index.ts` to avoid top-level await, ensuring compatibility with the CommonJS bundle required by `pkg`.
    - Applied a global fix for a `ReferenceError` (`targetMatch`) found in the `evilscan` dependency when running in strict/bundled mode.
- At the moment, only compile for MacOS x86
- Add new runner to have the compiled package compress to save some size
Application is compiled using `yao-pkg/pkg`, caxa been tested in developpement of this work but isn't used in final workflow
Otherwise, the artifact is quite big
- Since the introduction of ESLint, a lot of error have been raised all over the application
  - Fixed code smell from the backend
  - Properly use logger (by giving the Object _inside_ the logger function instead of outside)
  - Add semi-colon everywhere
- The introduction of GAMALESS is prone to create a lot of error (since the PlayerManager still need to be active, but without interaction with GamaConnector which still could be requested but undefined... Catch most error)
- Make ESLint more flexible by allowing `any` type
@RoiArthurB RoiArthurB self-assigned this Feb 5, 2026
@RoiArthurB RoiArthurB added 🤗 Enhancement New feature or request 🖱️ UX Issues related to user experience and design. labels Feb 5, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 5, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@RoiArthurB
Copy link
Contributor Author

To keep everything documented here :

  • Linux works perfectly
  • MacOS has a working x86_64 (the support for Aarm646 is still experimental, but Rosetta 2 does an amazing job. Still need to investigate if the translation's latency is a problem for real-time streams ?)
  • Windows doesn't work with this issue :
pkg/prelude/bootstrap.js:1867
throw error;
^

Error: This version of uWS.js (v20.56.0) supports only Node.js versions 20, 22, 24 and 25 on (glibc) Linux, macOS and Windows, on Tier 1 platforms (https://github.com/nodejs/node/blob/master/BUILDING.md#platform-list).

Error: The specified module could not be found.
C:\Users\bouveta\.cache\pkg\2769bcb8a165b251490534539fce2db3637583e83a72e4a44adca3ad8eecce50\uWebSockets.js\uws_win32_x64_137.node
at C:\snapshot\simple.webplatform-qwen\node_modules\uWebSockets.js\uws.js:22:9
at Object.<anonymous> (C:\snapshot\simple.webplatform-qwen\node_modules\uWebSockets.js\uws.js:24:3)
at Module._compile (pkg/prelude/bootstrap.js:1925:22)
at Object..js (node:internal/modules/cjs/loader:1896:10)
at Module.load (node:internal/modules/cjs/loader:1484:32)
at Module._load (node:internal/modules/cjs/loader:1303:12)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:245:24)
at Module.<anonymous> (node:internal/modules/cjs/loader:1507:12)
at Module.require (pkg/prelude/bootstrap.js:1846:31)

Node.js v24.13.0

It looks like the uWebSocket's native lib for Windows isn't packaged.... However it should since the packaging add all libs (will need to be fixed later to have small packages. This increase the size by 50~100Mo).

@GuillaumeLeroy34 can you try to compile the app from Windows and see if the exe crash with the same error message please ?

npm run build:executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤗 Enhancement New feature or request 🖱️ UX Issues related to user experience and design.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant