Skip to content

Commit d76fabd

Browse files
authored
Convert all the mentions of bsc and bsb (#342)
1 parent 0b938da commit d76fabd

File tree

8 files changed

+74
-56
lines changed

8 files changed

+74
-56
lines changed

pages/docs/gentype/latest/getting-started.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ For running `gentype` with ReScript via `npm` workflow, add following script in
3939

4040
```
4141
scripts: {
42-
"build": "bsb -make-world",
43-
"clean": "bsb -clean-world"
42+
"build": "rescript",
43+
"clean": "rescript clean"
4444
}
4545
```
4646

47-
> **Note:** `bsb` will automatically
48-
> detect your installed `genType` version.
47+
> **Note:** `rescript` will automatically detect your installed `genType` version.
4948
5049
## Configuration
5150

@@ -84,7 +83,7 @@ Configure your shim files within `"gentypeconfig"` in your [`bsconfig.json`](htt
8483

8584
Open any relevant `*.res` file and add `@genType` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [Hooks.res](https://github.com/reason-association/genType/blob/master/examples/typescript-react-example/src/Hooks.res).
8685

87-
Save the file and rebuild the project via `npm run bs:build` or similar. You should now see a `*.gen.tsx` (for TypeScript, or `*.gen.js` for Flow) file with the same name (e.g. `MyComponent.res` -> `MyComponent.gen.tsx`).
86+
Save the file and rebuild the project via `npm run bs:build` or similar. You should now see a `*.gen.tsx` (for TypeScript, or `*.gen.js` for Flow) file with the same name (e.g. `MyComponent.res` -> `MyComponent.gen.tsx`).
8887

8988
Any values exported from `MyComponent.res` can then be imported from JS. For example:
9089

pages/docs/manual/latest/build-configuration.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ The warning number are shown in the build output when they're triggered. The com
178178

179179
## bsc-flags
180180

181-
Extra flags to pass to the underlying `bsc` call. Notably: `["-bs-super-errors"]` for turning on cleaner error output. No need to pass this flag for a new ReScript project; it's enabled by default.
181+
Extra flags to pass to the compiler. For advanced usages.
182182

183183
## Environment Variables
184184

@@ -192,4 +192,4 @@ When `NINJA_ANSI_FORCED` is set to `1`: `rescript` produces color.
192192
When `NINJA_ANSI_FORCED` is set to `0`: `rescript` doesn't produce color.
193193
When `NINJA_ANSI_FORCED` is not set: `rescript` might or might not produce color, depending on a smart detection of where it's outputted.
194194

195-
> Note that bsc, the barebone compiler, will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript-compiler/issues/2984#issuecomment-410669163).
195+
> Note that the underlying compiler will always be passed `-color always`. See more details in [this issue](https://github.com/rescript-lang/rescript-compiler/issues/2984#issuecomment-410669163).

pages/docs/manual/latest/build-overview.mdx

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,66 @@ canonical: "/docs/manual/latest/build-overview"
77

88
# Build System Overview
99

10-
ReScript comes with a build system, bsb, that's meant to be fast, lean and used as the authoritative build system of the community.
10+
ReScript comes with a build system, [`rescript`](https://www.npmjs.com/package/rescript), that's fast, lean and used as the authoritative build system of the community.
1111

12-
The build description file is called `bsconfig.json`. Every ReScript project needs one.
12+
Every ReScript project needs a build description file, `bsconfig.json`.
1313

14-
## Build Project
14+
## Options
15+
16+
See `rescript -help`:
17+
18+
```
19+
❯ rescript -help
20+
Available flags
21+
-v, -version display version number
22+
-h, -help display help
23+
Subcommands:
24+
build
25+
clean
26+
format
27+
convert
28+
help
29+
Run rescript subcommand -h for more details,
30+
For example:
31+
rescript build -h
32+
rescript format -h
33+
The default `rescript` is equivalent to `rescript build` subcommand
34+
```
35+
36+
## Build Project
1537

1638
Each build will create build artifacts from your project's source files.
1739

1840
**To build a project (including its dependencies / pinned-dependencies)**, run:
1941

2042
```sh
21-
bsb -make-world
43+
rescript
2244
```
2345

24-
Add `-w` to keep the built-in watcher running. Any new file change will be picked up and the build will re-run.
46+
Which is an alias for `rescript build`.
2547

26-
**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit.
48+
To keep a build watcher, run:
2749

28-
**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`yarn workspaces` / `lerna`) where changes in your sub packages should be noticed by the compiler (`bsb -make-world`), you will need to define pinned dependencies in your main project's `bsconfig.json`. More details [here](./build-pinned-dependencies).
50+
```sh
51+
rescript build -w
52+
```
2953

30-
**To build only your project's files (without dependencies)**, run:
54+
Any new file change will be picked up and the build will re-run.
3155

56+
**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit.
3257

33-
```sh
34-
bsb
35-
```
58+
**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`npm` and `yarn` workspaces) where changes in your sub packages should be noticed by the build, you will need to define pinned dependencies in your main project's `bsconfig.json`. More details [here](./build-pinned-dependencies).
3659

3760
## Clean Project
3861

3962
If you ever get into a stale build for edge-case reasons, use:
4063

4164
```sh
42-
bsb -clean-world
65+
rescript clean
4366
```
4467

45-
This will clean all your project's build artifacts, including those in your dependencies. Alternatively you can run `bsb -clean` to clean your project's build artifacts only.
68+
This will clean your own project's build artifacts. To also clean the dependencies' artifacts:
4669

47-
For more infos, run `bsb -help` to see all the available options.
70+
```sh
71+
rescript clean -with-deps
72+
```

pages/docs/manual/latest/build-performance.mdx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ canonical: "/docs/manual/latest/build-performance"
77

88
# Build Performance
99

10-
ReScript considers performance at install time, build time and run time as a serious feature. Here are some more info, and tips on keeping the build fast. **Feel free to skip this section** if you're just starting out.
10+
ReScript considers performance at install time, build time and run time as a serious feature; it's one of those things you don't notice until you realize it's missing.
1111

1212
## Profile Your Build
1313

@@ -25,62 +25,58 @@ import Image from "src/components/Image";
2525

2626
## Under the Hood
2727

28-
ReScript itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for bsb.
28+
ReScript itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for `rescript`.
2929

30-
ReScript reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level `bsc`-related commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build.
30+
ReScript reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level compiler commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build.
3131

3232
## The JS Wrapper
3333

34-
`bsb` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, true `bsb` is called `bsb.exe`. It can be located in the same directory as where `bsb` is found:
34+
`rescript` itself is a Node.js wrapper which takes care of some miscellaneous tasks, plus the watcher. The lower-level, watcher-less, fast native `rescript` is called `rescript.exe`. It's located at `node_modules/rescript/{your-platform}/rescript.exe`.
3535

36-
```sh
37-
> bsb -where
38-
/usr/local/lib/node_modules/bs-platform/lib
39-
```
40-
41-
The path varies across systems.
42-
43-
If you don't need the watcher, you can run said `bsb.exe`: `/usr/local/lib/node_modules/bs-platform/lib/bsb.exe`. This side-steps the node.js startup time, which can be big (in the order of `100ms`).
36+
If you don't need the watcher, you can run said `rescript.exe`. This side-steps Node.js' long startup time, which can be in the order of `100ms`. Our editor plugin finds and uses this native `rescript.exe` for better performance.
4437

4538
## Numbers
4639

47-
Raw `bsb.exe` build on a small project should be around `70ms`. This doubles when you use the more common `bsb` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `bsb.exe` for programmatic usage, e.g. inserting bsb into your existing JS build pipeline).
40+
Raw `rescript.exe` build on a small project should be around `70ms`. This doubles when you use the JS `rescript` wrapper which comes with a watcher, which is practically faster since you don't manually run the build at every change (though you should opt for the raw `rescript.exe` for programmatic usage, e.g. inserting rescript into your existing JS build pipeline).
4841

4942
No-op build (when no file's changed) should be around `15ms`. Incremental rebuild (described soon) of a single file in a project is around `70ms` too.
5043

5144
Cleaning the artifacts should be instantaneous.
5245

5346
### Extreme Test
5447

55-
We've stress-tested bsb on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/ocaml-omake/omake/blob/perf-test/performance/generate.ml, on Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7).
48+
We've stress-tested `rescript.exe` on a big project of 10,000 files (2 directories, 5000 files each, first 5000 no dependencies, last 5000 10 dependencies on files from the former directory) using https://github.com/rescript-lang/build-benchmark, on a Retina Macbook Pro Early 2015 (3.1 GHz Intel Core i7).
5649

5750
<!-- TODO: better repro -->
5851

5952
- No-op build of 10k files: `800ms` (the minimum amount of time required to check the mtimes of 10k files).
6053
- Clean build: <3 minutes.
6154
- Incremental build: depends on the number of the dependents of the file. No dependent means `1s`.
6255

63-
Note that bsb is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors and others. The bsb watcher, on the other hand, can stay open for days.
56+
### Stability
6457

65-
## Incrementality
58+
`rescript` is a file-based build system. We don't do in-memory build, even if that speeds up the build a lot. In-memory builds risk memory leaks, out-of-memory errors, corrupt halfway build and others. Our watcher mode stays open for days or months with no leak.
59+
60+
The watcher is also just a thin file watcher that calls `rescript.exe`. We don't like babysitting daemon processes.
61+
62+
## Incrementality & Correctness
6663

6764
ReScript doesn't take whole seconds to run every time. The bulk of the build performance comes from incremental build, aka re-building a previously built project when a few files changed.
6865

69-
In short, thanks to our bsc compiler and bsb build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementality in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose.
66+
In short, thanks to our compiler and the build system's architecture, we're able to **only build what's needed**. E.g. if `MyFile.res` isn't changed, then it's not recompiled. You can roughly emulate such incrementalism in languages like JavaScript, but the degree of correctness is unfortunately low. For example, if you rename or move a JS file, then the watcher might get confused and not pick up the "new" file or fail to clean things up correctly, resulting in you needing to clean your build and restart anew, which defeats the purpose.
67+
68+
Say goodbye to stale build from your JavaScript ecosystem!
7069

7170
## Speed Up Incremental Build
7271

7372
ReScript uses the concept of interface files (`.resi`) (or, equivalently, [module signatures](module.md#signatures)). Exposing only what you need naturally speeds up incremental builds. E.g. if you change a `.res` file whose corresponding `.resi` file doesn't expose the changed part, then you've reduced the amount of dependent files you have to rebuild.
7473

75-
<!-- TODO: validate this -->
76-
7774
## Programmatic Usage
7875

7976
Unfortunately, JS build systems are usually the bottleneck for building a JS project nowadays. Having parts of the build blazingly fast doesn't matter much if the rest of the build takes seconds or literally minutes. Here are a few suggestions:
8077

8178
- Convert more files into ReScript =). Fewer files going through fewer parts of the JS pipeline helps a ton.
82-
- Careful with bringing in more dependencies: libraries, syntax transforms, build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide.
83-
- Wait for us to create our own super fast linker (aka bundler).
79+
- Careful with bringing in more dependencies: libraries, syntax transforms (e.g. the unofficially supported PPX), build step loaders, etc. The bulk of these dragging down the editing & building experience might out-weight the API benefits they provide.
8480

8581
## Hot Reloading
8682

pages/docs/manual/latest/build-pinned-dependencies.mdx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ canonical: "/docs/manual/latest/build-pinned-dependencies"
1111

1212
Usually we'd recommend to use ReScript in a single-codebase style by using one `bsconfig.json` file for your whole codebase.
1313

14-
There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`yarn workspaces`-like "monorepos"). This is where `pinned-dependencies` come into play.
15-
14+
There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`npm` workspaces-like "monorepos"). This is where `pinned-dependencies` come into play.
1615

1716
## Package Types
1817

@@ -22,7 +21,7 @@ Before we go into detail, let's first explain all the different package types re
2221
- Pinned dependencies (these are your local packages that should always rebuild when you build your toplevel, those should be listed in `bs-dependencies` and `pinned-dependencies`)
2322
- Normal dependencies (these are packages that are consumed from npm and listed via `bs-dependencies`)
2423

25-
Whenever a package is being built (`bsb -make-world`), the build system will build the toplevel package with its pinned-dependencies. So any changes made in a pinned dependency will automatically be reflected in the final app.
24+
Whenever a package is being built (`rescript build`), the build system will build the toplevel package with its pinned-dependencies. So any changes made in a pinned dependency will automatically be reflected in the final app.
2625

2726
## Build System Package Rules
2827

@@ -108,7 +107,6 @@ Our `app` folder would be our toplevel package, consuming our `common` and `mypl
108107
}
109108
```
110109

111-
Now, whenever we are running `npx bsb -make-world` within our `app` package, the compiler would always rebuild any changes within its pinned dependencies as well.
112-
113-
**Important:** ReScript will not rebuild any `pinned-dependencies` in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs `bsb -make-world` on specific file changes. E.g. you could use [`watchman-make`](https://facebook.github.io/watchman/docs/watchman-make.html) to automatically run the build task when a file in `common` or `myplugin` has been changed.
110+
Now, whenever we are running `rescript build` within our `app` package, the compiler would always rebuild any changes within its pinned dependencies as well.
114111

112+
**Important:** ReScript will not rebuild any `pinned-dependencies` in watch mode! This is due to the complexity of file watching, so you'd need to set up your own file-watcher process that runs `rescript build` on specific file changes.

pages/docs/manual/latest/converting-from-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ let queryResult = (usePayload, payload) => {
153153

154154
</CodeTab>
155155

156-
Format the code: `./node_modules/.bin/bsc -format src/Main.res`.
156+
Format the code: `./node_modules/.bin/rescript format src/Main.res`.
157157

158158
We have a type error: "The record field student can't be found". That's fine! **Always ensure your code is syntactically valid first**. Fixing type errors comes later.
159159

0 commit comments

Comments
 (0)