ECMAScript icon indicating copy to clipboard operation
ECMAScript copied to clipboard

Javascript module plans

Open Geequlim opened this issue 2 years ago • 9 comments

Note These are plans about this project todo but not found enough time to make it happen yet.

  • [ ] Remove godot form global scope, make it as an esmodule.

    import { Vector2, Node, clamp } from 'godot';
    
  • [ ] Improved TypeScript support

    • [ ] Better signal/slot support
      • [ ] Remove extral signal value bindings, implements in TS declerations
      • [ ] Type checking and code completion for signals, callbacks and paramters
    • [ ] Add godot importer to compile TypeScript files with tsc/esbuild
      • [ ] We want writing TypeScript files and attach them to nodes in editor
  • [ ] Improved debugger for QuickJS

  • [ ] Standard ESModule/CommonJS implementation

    • [x] Rename jsx to mjs for esmodule
    • [ ] Add interface to native API for module code loading so that would be possible to
      • Load script from remote like deno
      • Load TypeScript and run it (after custom compile process)
      • Script content encryption
  • [ ] Add operators as methods like op_add op_divide to builtin math types for compatibility with more backends

  • [ ] Samples for complicated projects

    • [ ] Out of box configuration of webpack/esbuild etc
    • [ ] Out of box remote debugger/profiler configurations for VSCode to make it easier for mobile game development
    • [ ] Hot reload implementation for faster development
    • [ ] Remote update version ~~without ship new version on App Store/Google Play/Steam~~
  • [ ] Port to godot 4.x

    • [ ] Port QuickJS binding to godot 4.0
    • [ ] Add GDExtension support to make everyone can just download and using it
  • [ ] Some demo projects

    • [ ] For performance tests
    • [ ] For best practics
    • [ ] For make good use of TypeScript/JavaScript/NPM
  • Documentations

    • [ ] I can writing documentations in Chinese
    • [ ] It world be great if anyone can help translate them

About backends and improvements to current workflow

  • [ ] Add V8 backend
    • [ ] Professional debugger/inspector/profiler/memory tools support
    • [ ] Enable JIT as default and using jitless mode on iOS
  • [ ] Add NodeJS backend (Editor/PC Only)
    • [ ] Using full NodeJS API (and millions of libraries) to extend editor or make games on PC

Geequlim avatar Aug 08 '22 14:08 Geequlim

Also, there are some errors in the godot.d.ts (lines 4686 and 47134, I think), it would be nice to fix them, along with #126.

mageowl avatar Aug 10 '22 16:08 mageowl

Also, there are some errors in the godot.d.ts (lines 4686 and 47134, I think), it would be nice to fix them, along with #126.

I've fixed the first issue with #135. @Geequlim could you take a look?

poohcom1 avatar Aug 15 '22 08:08 poohcom1

Can you estimate the effort to add wasm support? Or describe how you would do it?

fire avatar Aug 24 '22 23:08 fire

Can you estimate the effort to add wasm support? Or describe how you would do it?

WASM is supported by V8 directly. For QuickJS backen we can using wasm3

Geequlim avatar Aug 25 '22 04:08 Geequlim

For note Latest stable V8 build is ready at https://github.com/Geequlim/v8-builder

Puerts seems integrated nodejs for unity and unreal engine on both desktop and mobile platforms with https://github.com/puerts/backend-nodejs

Geequlim avatar Sep 24 '22 18:09 Geequlim

Do you prefer v8 or quickjs + wasm3?

fire avatar Sep 24 '22 20:09 fire

For different usage choose different backend. QuickJS is smaller so it is suitable for most game projects.

v8 is large but fast with jit and much more stable with better toolchains including debugger/profiler etc.

We'd better develop games with v8 and publish with your choice.

The principle of the backend to choose is based on your project. If performance more important using V8 or if size is more important choose QuickJS.

Note:

  1. V8 is not supported on Web and quickjs is better for better load time.
  2. On iOS jit is not allowed so performance of V8 is not that obviously so maybe QuickJS is better choice.
  3. For editor and developers tools we'd better choose nodejs so we can benefit from the npm ecosystem to make life easier.

Geequlim avatar Sep 25 '22 04:09 Geequlim

Heya, @vignetteapp would love to help you out with the GDExtensions work item and (potentially) the CommonJS/ESM implementation, is there any progress in the 4.1 branch so far?

sr229 avatar Oct 08 '23 00:10 sr229

The master branch has had active work by @nmerget

fire avatar Oct 08 '23 00:10 fire