aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/builtins/README.md
blob: 8ec32e8b52ecf979ea70778c93328e3f73394c01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# JavaScript Builtins

JavaScript files in [./js](./js) use JavaScriptCore's builtins syntax

```js
@getter
function foo() {
    return @getByIdDirectPrivate(this, "superSecret");
}
```

It looks kind of like decorators but they're not. They let you directly call engine intrinsics and help with avoiding prototype pollution issues.

V8 has a [similar feature](https://v8.dev/blog/embedded-builtins) (they use `%` instead of `@`)

They usually are accompanied by a C++ file.

The `js` directory is necessary for the bindings generator to work.

To regenerate the builtins, run this from Bun's project root (where the `Makefile` is)

```bash
make generate-builtins
```

You'll want to also rebuild all the C++ bindings or you will get strange crashes on start

```bash
make clean-bindings
```