xtool/contrib/mORMot/SyNode/README.md

1.9 KiB

The server-side JavaScript execution using the SpiderMonkey library with nodeJS modules support

  • win32/64 target (FPC 3.1.1, Delphi), linux 64 (FPC 3.1.1)
  • based on SpiderMonkey52, almost full support of ES6
  • a remote debugger protocol, can be debugged remotely using Firefox - see SyNode\Samples\02 - Bindings
  • CommonJS modules, compatible with NPM modules
  • native modules can be implemented using Delphi/FPC (as a dll/so) - see SyNode\Samples\01 - Dll Modules
  • JavaScript prototype definition based on Delphi RTTI (supported both "new" and old)

SpiderMonkey library

Precompiled binary can be downloaded here:

Or compiled from sources as described in instructions inside mozjs folder

SpiderMonkey 45 (not supported)

Precompiled binary can be downloaded here:

Embadding SyNode JavaScript files into executable

Files from core_modules folder can be embadded into executable by enabling CORE_MODULES_IN_RES define in the SyNode.inc file (enabled by default).

Compiled core_modules.res resources is commited into the git repositiry.

To create your own resource pack use a /tool/core_res tool to prepare files for embadding.

To compile rc -> res we use mingq tools under linux

sudo apt install mingw-w64 mingw-w64-tools
cd SyNode
./tools/core_res -i ./core_modules/ -o ./.resources/
cd ./resources
x86_64-w64-mingw32-windres ./core_res.rc ../core_modules.res

From inside JS files embadded into resources can be evaluated using process.binding('modules').runInThisContextRes function

Form Pascal code using TSMEngine.EvaluateRes() function