Bytecode module
The bytecode module transforms your clientside code to V8 bytecode on the serverside before the files are sent to the client. Thus, it makes stealing the original source files by dumping them clientside completely impossible.
But it is still possible to dump the generated bytecode and reverse the logic, so the module does not 100% protect your code from being stolen. But again, that is a very time intensive and exhausting process, so it would be very hard to reverse actually accurate working code from the bytecode. Also, the structure of the V8 bytecode keeps changing over time and is barely documented at all, and there is currently no known public "tool" to reverse V8 bytecode into valid JavaScript code.
It is recommended to only use the bytecode module in production. This is because the source files are missing for the client, so it is not possible to generate a stack trace or any other additional debug information, making debugging errors and other issues a lot harder.
Setting up the bytecode module
Setting up the bytecode module is a relatively easy process, just follow the steps below:
- Download the bytecode module, and place the downloaded
.dll
or.so
in yourmodules
directory - Add
js-bytecode-module
to themodules
array in theserver.toml
- For every resource you want to use the bytecode module for set the
client-type
in theresource.toml
tojsb
- Start the server
Now every time you start the server you should get logs similiar to this one:
Converted file to bytecode: path/file.js
There is still an optional step left, but this step is only needed when the code is using dynamic import to import any files,
that are not otherwise imported. As the module compiles all imported files recursively, by starting from the main file and compiling
all its dependencies (modules imported with the import
statement), it is not possible for the module to know the files that are dynamically imported.
So these have to be manually specified, so they are also compiled.
To do this just:
- Add all files that should additionally be compiled to the
extra-compile-files
array in theresource.toml
That array accepts the same paths as the client-files
option does, so it is possible to include a whole folder for example.
Download
The module can be downloaded from the following sources:
- The official alt:V downloads page
- The CDN directly - Windows / Linux
- The bytecode module releases page
Troubleshooting
Help! I have an error saying...
First of all, make sure your code runs without any errors. If the code has any errors in the top level code (like syntax errors), the module will fail to compile.
If the code runs fine without the bytecode module but the module still reports an error, contact us on Discord.