aboutsummaryrefslogtreecommitdiff
path: root/CONTRIBUTING.md
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-09 14:09:50 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-09 14:09:50 -0800
commitad9d4fb0c41c1fe79e29a0fff18084937b2d8a2d (patch)
treeaf7519b53a3fdd0305c932bb312061c90e25c6bc /CONTRIBUTING.md
parent523b112945d20f7aa59ad3de327348cc77353a1f (diff)
downloadbun-ad9d4fb0c41c1fe79e29a0fff18084937b2d8a2d.tar.gz
bun-ad9d4fb0c41c1fe79e29a0fff18084937b2d8a2d.tar.zst
bun-ad9d4fb0c41c1fe79e29a0fff18084937b2d8a2d.zip
Add a note about builtins
Diffstat (limited to 'CONTRIBUTING.md')
-rw-r--r--CONTRIBUTING.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 19f7dcff7..5f7ddbc9c 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -53,6 +53,22 @@ The ESM modules in Bun are located in `src/bun.js/*.exports.js`. Unlike other co
The module loader is in `src/bun.js/module_loader.zig`.
+### JavaScript Builtins
+
+JavaScript builtins are located in `src/bun.js/builtins/*.js`.
+
+These files support a JavaScriptCore-only syntax for internal slots. `@` is used to access an internal slot. For example: `new @Array(123)` will create a new `Array` similar to `new Array(123)`, except if a library modifies the `Array` global, it will not affect the internal slot (`@Array`). These names must be allow-listed in `BunBuiltinNames.h` (though JavaScriptCore allowlists some names by default).
+
+They can not use or reference ESM-modules. The files that end with `*Internals.js` are automatically loaded globally. Most usage of internals right now are the stream implementations (which share a lot of code from Safari/WebKit) and ImportMetaObject (which is how `require` is implemented in the runtime)
+
+To regenerate the builtins:
+
+```sh
+make clean-bindings && make generate-builtins && make bindings -j10
+```
+
+It is recommended that you have ccache installed or else you will spend a lot of time waiting for the bindings to compile.
+
### Memory management in Bun's JavaScript runtime
TODO: fill this out (for now, use `JSC.Strong` in most cases)