Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1610ee9
Put v8.0.0 manual in gitignore
ryyppy Apr 7, 2021
7f3687c
Remove bs. prefix
ryyppy Apr 7, 2021
7137766
Add open! docs
ryyppy Apr 7, 2021
1086eb7
Fix version number info regarding bs. prefix drop
ryyppy Apr 7, 2021
e4d6163
Update Array / Array2.from type
ryyppy Apr 7, 2021
6fbedc9
Document exotic module filename behavior
ryyppy Apr 7, 2021
d853033
Add 109 warning flag description and update playground default
ryyppy Apr 7, 2021
9daaa72
Add monorepo support doc
ryyppy Apr 7, 2021
4cbecd2
Update doc version to 8.4
ryyppy Apr 7, 2021
90806a3
Document lightweight poly var syntax
ryyppy Apr 7, 2021
1957356
Add external stdlib configuration page
ryyppy Apr 7, 2021
f1adede
when clause -> if clause
ryyppy Apr 7, 2021
94b730e
Update docs version to 9.0
ryyppy Apr 7, 2021
64ea2c8
Update test scripts to 9.0.2
ryyppy Apr 7, 2021
0163f10
Update external stdlib docs
ryyppy Apr 8, 2021
516b95d
Add pinned-dependencies / external-stdlib config in configuration page
ryyppy Apr 8, 2021
b937583
Update build schema and author image
ryyppy Apr 8, 2021
ba2c385
Remove monorepo term, call the doc "Pinned Dependencies" instead
ryyppy Apr 8, 2021
7f7758f
Remove monorepo mention from blogpost
ryyppy Apr 8, 2021
f8a2266
Remove theme cli doc from build-overview
ryyppy Apr 8, 2021
03605d8
Update build overview / pinned dependency doc
ryyppy Apr 8, 2021
023dd90
Add note about external-stdlib config in libraries section
ryyppy Apr 8, 2021
7b74cf0
Update pinned-dependency doc wording
ryyppy Apr 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ node_modules/
.next/
index_data/*.json

pages/docs/manual/v8.0.0/

yarn-error.log

.bsb.lock
Expand Down
27 changes: 3 additions & 24 deletions _blogposts/2020-12-07-release-8-4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,9 @@ dependent's command line flags for building binary artifacts. Such strategy bene

### Introducing `pinned-dependencies`

To make `bsb -make-world` more practical, we also introduce a new concept called: `pinned-dependencies`.
In general, packages are classified as three categories:

- toplevel
- warnings reported
- warn-error respected
- build dev dependency
- run custom rules
- package-specs like ES6/CommonJS overrides all its dependencies
- pinned dependencies
- warnings reported
- warn-error respected
- build dev dependency
- run custom rules
- normal dependencies
- warnings, warn-error ignored
- ignore dev directories
- ignore custom generator rules

Previously, we only had `toplevel` and `normal dependencies`, by introducing `pinned-dependencies`,
such package will be built mostly like `toplevel` packages.

The usage is quite simple, add `pinned-dependencies` in the toplevel package's `bsconfig.json`.
Note such field only make sense in toplevel's configuration.
To make `bsb -make-world` more practical for e.g. multi-package setups (`lerna`, `yarn workspaces`, etc.), we introduced a new concept called `pinned-dependencies`. A pinned dependency allows you to automatically rebuild packages that are pinned by a toplevel package, like your final webapp.

Please refer to our [pinned dependencies](/docs/manual/latest/build-pinned-dependencies) docs for more details.

### More robust handling of removal of staled output

Expand Down
42 changes: 1 addition & 41 deletions _blogposts/2021-02-09-release-9-0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,8 @@ Our compiler comes with a set of stdlib modules (such as `Belt`, `Pervasives`, e

In previous versions, users couldn't ship their compiled JS code without defining a `package.json` dependency on `bs-platform`. Whenever a ReScript developer wanted to publish a package just for pure JS consumption / lean container deployment, they were required to use a bundler to bundle up their library / stdlib code, which made things way more complex and harder to understand.

To fix this problem, we now publish our pre-compiled stdlib JS files as a separate npm package called [`@rescript/std`](https://www.npmjs.com/package/@rescript/std). Each new `bs-platform` release has a matching `@rescript/std` release for runtime compatibility.

We also introduced a new configuration within our `bsconfig.json` file to tell the compiler to use our pre-compiled package instead:

```json
{
/* ... */
"external-stdlib" : "@rescript/std"
}
```

With this configuration set, compiled JS code will now point to the defined `external-stdlib` path:

<CodeTab labels={["ReScript", "JavaScript"]}>

```res
Belt.Array.forEach([1, 2, 3], (num) => Js.log(num))
```

```js
// Note the import path starting with "@rescript/std"
import * as Belt_Array from "@rescript/std/lib/es6/belt_Array.js";

Belt_Array.forEach([
1,
2,
3
], (function (num) {
console.log(num);

}));
```

</CodeTab>

The JavaScript output above was compiled with an `es6` target, but will also work with `commonjs`.

**Important:** When using this option, you need to make sure that the version number of `bs-platform` and `@rescript/std` matches with the same version number in your `package.json` file, otherwise you'll eventually run into runtime problems due to mismatching stdlib behavior!

To prevent unnecessary complications, only use this feature when...
- You want to ship a library for JS / TS consumers without making them depend on `bs-platform`
- You can't depend on `bs-platform` due to toolchain size (docker containers, low-storage deployment devices, etc)
To fix this problem, we introduced an `external-stdlib` configuration that allows specifying a pre-compiled stdlib npm package (`@rescript/std`). More details on how to use that feature can be found in our [External Stdlib](/docs/manual/latest/build-external-stdlib) documentation.

### Less Bundle Bloat when Adding ReScript

Expand Down
5 changes: 5 additions & 0 deletions compilers/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions compilers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"rescript-902": "npm:bs-platform@9.0.2",
"rescript-820": "npm:bs-platform@8.2.0"
}
}
2 changes: 1 addition & 1 deletion data/blog_authors.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"username": "hongbo",
"fullname": "Hongbo Zhang",
"role": "Compiler & Build System",
"img_url": "https://pbs.twimg.com/profile_images/3157941111/cf58e90adce60b796f589b2ae5a0394a_400x400.jpeg",
"img_url": "https://pbs.twimg.com/profile_images/1369548222314598400/E2y46vrB_400x400.jpg",
"twitter": "bobzhang1988"
},
{
Expand Down
18 changes: 5 additions & 13 deletions data/build-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@

"type": {
"enum": [
"dev",
"lib"
"dev"
]
},
"files": {
Expand Down Expand Up @@ -481,24 +480,17 @@
"type": "boolean",
"description": "(Experimental) whether to use the OCaml standard library. Default: true"
},
"external-stdlib" : {
"type" : "string",
"description": "Use the external stdlib library instead of the one shipped with the compiler package"
},
"bs-external-includes": {
"type": "array",
"items": {
"type": "string"
},
"description": "(Not needed usually) external include directories, which will be applied `-I` to all compilation units"
},
"refmt": {
"$ref": "#/definitions/refmt-specs",
"description": "Reason syntax configuration"
},
"refmt-flags": {
"type": "array",
"items": {
"type": "string"
},
"description": "(Not needed usually) arguments to pass to `refmt` above. Default: `[\"--print\", \"binary\"]`."
},
"suffix" : {
"$ref" : "#/definitions/suffix-spec"
}
Expand Down
2 changes: 2 additions & 0 deletions data/sidebar_manual_latest.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
"build-overview",
"build-configuration",
"build-configuration-schema",
"build-external-stdlib",
"build-pinned-dependencies",
"interop-with-js-build-systems",
"build-performance"
],
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/api/js/array-2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ A type used to describe JavaScript objects that are like an array or are iterabl
## from

```res sig
let from: array_like<'a> => array<'b>
let from: array_like<'a> => array<'a>
```

Creates a shallow copy of an array from an array-like object. See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN.
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/api/js/array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A type used to describe JavaScript objects that are like an array or are iterabl
## from

```res sig
let from: array_like<'a> => array<'b>
let from: array_like<'a> => array<'a>
```

Creates a shallow copy of an array from an array-like object. See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN.
Expand Down
12 changes: 6 additions & 6 deletions pages/docs/manual/latest/attribute.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Like many other languages, ReScript allows annotating a piece of code to express
<CodeTab labels={["ReScript", "JS Output"]}>

```res
@bs.inline
@inline
let mode = "dev"

let mode2 = mode
Expand All @@ -22,7 +22,7 @@ var mode2 = "dev";

</CodeTab>

The `@bs.inline` annotation tells `mode`'s value to be inlined into its usage sites (see output). We call such annotation "attribute" (or "decorator" in JavaScript).
The `@inline` annotation tells `mode`'s value to be inlined into its usage sites (see output). We call such annotation "attribute" (or "decorator" in JavaScript).

An attribute starts with `@` and goes before the item it annotates. In the above example, it's hooked onto the let binding.

Expand All @@ -39,11 +39,11 @@ You can put an attribute almost anywhere. You can even add extra data to them by
@unboxed
type a = Name(string)

@bs.val external message: string = "message"
@val external message: string = "message"

type student = {
age: int,
@bs.as("aria-label") ariaLabel: string,
@as("aria-label") ariaLabel: string,
}

@deprecated
Expand All @@ -59,8 +59,8 @@ let customTriple = foo => foo * 3

1. `@@warning("-27")` is a standalone attribute that annotates the entire file. Those attributes start with `@@`. Here, it carries the data `"-27"`.
2. `@unboxed` annotates the type definition.
3. `@bs.val` annotates the `external` statement.
4. `@bs.as("aria-label")` annotates the `ariaLabel` record field.
3. `@val` annotates the `external` statement.
4. `@as("aria-label")` annotates the `ariaLabel` record field.
5. `@deprecated` annotates the `customDouble` expression. This shows a warning while compiling telling consumers to not rely on this method long-term.
6. `@deprecated("Use SomeOther.customTriple instead")` annotates the `customTriple` expression with a string to describe the reason for deprecation.

Expand Down
16 changes: 8 additions & 8 deletions pages/docs/manual/latest/bind-to-global-js-values.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Some JS values, like `setTimeout`, live in the global scope. You can bind to the
<CodeTab labels={["ReScript", "JS Output"]}>

```res example
@bs.val external setTimeout: (unit => unit, int) => float = "setTimeout"
@bs.val external clearTimeout: float => unit = "clearTimeout"
@val external setTimeout: (unit => unit, int) => float = "setTimeout"
@val external clearTimeout: float => unit = "clearTimeout"
```
```js
// Empty output
Expand All @@ -40,8 +40,8 @@ We're in a language with a great type system now! Let's leverage a popular featu

```res example
type timerId
@bs.val external setTimeout: (unit => unit, int) => timerId = "setTimeout"
@bs.val external clearTimeout: timerId => unit = "clearTimeout"
@val external setTimeout: (unit => unit, int) => timerId = "setTimeout"
@val external clearTimeout: timerId => unit = "clearTimeout"

let id = setTimeout(() => Js.log("hello"), 100)
clearTimeout(id)
Expand All @@ -62,12 +62,12 @@ Since `external`s are inlined, we end up with JS output as readable as hand-writ

## Global Modules

If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `bs.scope` to your `bs.val` external:
If you want to bind to a value inside a global module, e.g. `Math.random`, attach a `scope` to your `val` external:

<CodeTab labels={["ReScript", "JS Output"]}>

```res example
@bs.scope("Math") @bs.val external random: unit => float = "random"
@scope("Math") @val external random: unit => float = "random"
let someNumber = random()
```
```js
Expand All @@ -76,12 +76,12 @@ var someNumber = Math.random();

</CodeTab>

you can bind to an arbitrarily deep object by passing a tuple to `bs.scope`:
you can bind to an arbitrarily deep object by passing a tuple to `scope`:

<CodeTab labels={["ReScript", "JS Output"]}>

```res example
@bs.val @bs.scope(("window", "location", "ancestorOrigins"))
@val @scope(("window", "location", "ancestorOrigins"))
external length: int = "length"
```
```js
Expand Down
Loading