Skip to content

Commit b661756

Browse files
committed
Merge branch 'master' into new-react-docs
2 parents fe901b1 + 50fcb04 commit b661756

17 files changed

+390
-294
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44

55
# rescript-lang.org
66

7-
This is the repository for [rescript-lang.org](https://rescript-lang.org) and
8-
is currently **work in progress**.
7+
This is the official documentation platform for the [ReScript](https://rescript-lang.org) programming language.
8+
9+
**In case you want to report a technical issue, please refer to the appropriate repository:**
10+
- [rescript-compiler](https://github.com/rescript-lang/rescript-compiler): The compiler and build system
11+
- [rescript-syntax](https://github.com/rescript-lang/syntax): The ReScript syntax
912

1013
## Setup
1114

1215
```sh
16+
# For first time clone / build
1317
yarn
18+
yarn run update-index
1419

1520
# Initial build
1621
yarn bs:build
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
author: hongbo
3+
date: "2020-09-25"
4+
previewImg:
5+
category: compiler
6+
title: What's new in ReScript 8.3 (Part 1)
7+
description: |
8+
---
9+
10+
## Introduction
11+
12+
ReScript is a soundly typed language with an optimizing compiler focused on the JS platform.
13+
It's focused on type safety, performance and JS interop. It used to be called BuckleScript.
14+
15+
[[email protected]](https://www.npmjs.com/package/bs-platform/v/8.3.0) is now available for testing, you can try it via
16+
17+
```
18+
19+
```
20+
21+
The changes are listed [here](https://github.com/rescript-lang/rescript-compiler/blob/master/Changes.md#83), this is a large release, and we will go through some highlighted changes.
22+
23+
24+
25+
## Lightweight FFI attributes without `bs.` prefix
26+
27+
In this release, we make the `bs.` prefix optional, this will make the FFI less verbose.
28+
29+
For example, the old externals for `readFileAsUtf8Sync` used to be written like this
30+
31+
32+
```ocaml
33+
external readFileAsUtf8Sync : string -> (_[@bs.as "utf8"]) -> string = "readFileSync" [@@bs.val] [@@bs.module "fs"]
34+
```
35+
36+
It can now be simplified as
37+
```ocaml
38+
external readFileAsUtf8Sync : string -> (_[@as "utf8"]) -> string = "readFileSync"
39+
[@@val] [@@module "fs"]
40+
```
41+
42+
Note almost all previous attributes with `bs.xx` can be simplified as `xx`
43+
with the exception of the following two that don't have abbreviations:
44+
45+
- `bs.send.pipe` : this attribute was deprecated in favor of `bs.send`; you can still use the existing one for backward compatibility.
46+
47+
- `bs.splice` : this attribute was deprecated in favor of `bs.variadic`; you can still use the existing one for
48+
backward compatibility.
49+
50+
51+
## default import in Es6 support
52+
53+
If you use es6 module output, the default bindings will be compiled properly now:
54+
55+
```ocaml
56+
external input : string -> string = "default" [@@module "hello"]
57+
58+
let a = input "hello"
59+
```
60+
61+
Will now be compiled properly under es6 format as below:
62+
63+
```js
64+
import Hello from "hello";
65+
var a = Hello("hello");
66+
```
67+
68+
69+
## Customized js file extension support
70+
71+
Now user can pick up their js file extension support per module format:
72+
73+
```json
74+
"package-specs": [{
75+
"module": "es6",
76+
"suffix": ".mjs"
77+
},{
78+
"module": "commonjs",
79+
"suffix": ".cjs"
80+
}],
81+
82+
```
83+
84+
## More flexible filename support
85+
86+
To have better integration with other [JS infrastructures](https://github.com/rescript-lang/rescript-compiler/issues/4624),
87+
for example, Next.js/React Native, we allow file names like `404.res`,
88+
`Button.Android.res` so that it can just be picked up by those tools
89+
90+
91+
92+
## Better type based inference for pattern `let {a,b,c} = value`
93+
94+
Previously, for code like this:
95+
96+
```ocaml
97+
module N = struct
98+
type t = {
99+
x : int
100+
}
101+
end
102+
103+
let f (u : N.t) =
104+
let {x } = u in x + 1 (* type error *)
105+
```
106+
107+
You will get a type error
108+
109+
```
110+
Error: Unbound record field x
111+
```
112+
113+
However, since the compiler already knows the type of `u`, it is capable of looking up the label `x` properly.
114+
In this release, we make the original code style work out of the box without a work-around such as adding a module prefix
115+
like `let {N.x} = ..`
116+
117+
## Build system enhancement
118+
119+
A lot of work is put in improving the build system, we will expand on this topic in the next post!
120+
121+
Happy Hacking!

_blogposts/2020-09-25-release-8-3.mdx

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
author: hongbo
3+
date: "2020-09-25"
4+
previewImg:
5+
category: compiler
6+
title: What's new in ReScript 8.3 (Part 1)
7+
description: |
8+
---
9+
10+
## Introduction
11+
12+
ReScript is a soundly typed language with an optimizing compiler focused on the JS platform.
13+
It's focused on type safety, performance and JS interop. It used to be called BuckleScript.
14+
15+
[[email protected]](https://www.npmjs.com/package/bs-platform/v/8.3.0) is now available for testing, you can try it via
16+
17+
```
18+
19+
```
20+
21+
The changes are listed [here](https://github.com/rescript-lang/rescript-compiler/blob/master/Changes.md#83), this is a large release, and we will go through some highlighted changes.
22+
23+
24+
25+
## Lightweight FFI attributes without `bs.` prefix
26+
27+
In this release, we make the `bs.` prefix optional, this will make the FFI less verbose.
28+
29+
For example, the old externals for `readFileAsUtf8Sync` used to be written like this
30+
31+
32+
<CodeTab labels={["ReScript", "Reason (Old Syntax)", "ML (Older Syntax)"]}>
33+
34+
```res
35+
@bs.val @bs.module("fs")
36+
external readFileAsUtf8Sync: (string, @bs.as("utf8") _) => string = "readFileSync"
37+
```
38+
```reason
39+
[@bs.val] [@bs.module "fs"]
40+
external readFileAsUtf8Sync: (string, [@bs.as "utf8"] _) => string =
41+
"readFileSync";
42+
```
43+
```ocaml
44+
external readFileAsUtf8Sync : string -> (_[@bs.as "utf8"]) -> string = "readFileSync" [@@bs.val] [@@bs.module "fs"]
45+
```
46+
47+
</CodeTab>
48+
49+
It can now be simplified as
50+
51+
<CodeTab labels={["ReScript", "Reason (Old Syntax)", "ML (Older Syntax)"]}>
52+
53+
```res
54+
@val @module("fs") external readFileAsUtf8Sync: (string, @as("utf8") _) => string = "readFileSync"
55+
```
56+
```reason
57+
[@val] [@module "fs"]
58+
external readFileAsUtf8Sync: (string, [@as "utf8"] _) => string =
59+
"readFileSync";
60+
```
61+
```ocaml
62+
external readFileAsUtf8Sync : string -> (_[@as "utf8"]) -> string = "readFileSync"
63+
[@@val] [@@module "fs"]
64+
```
65+
66+
</CodeTab>
67+
68+
Note almost all previous attributes with `bs.xx` can be simplified as `xx`
69+
with the exception of the following two that don't have abbreviations:
70+
71+
- `bs.send.pipe` : this attribute was deprecated in favor of `bs.send`; you can still use the existing one for backward compatibility.
72+
73+
- `bs.splice` : this attribute was deprecated in favor of `bs.variadic`; you can still use the existing one for
74+
backward compatibility.
75+
76+
77+
## default import in Es6 support
78+
79+
If you use es6 module output, the default bindings will be compiled properly now:
80+
81+
<CodeTab labels={["ReScript", "Reason (Old Syntax)", "ML (Older Syntax)"]}>
82+
83+
```res
84+
@module("hello") external input: string => string = "default"
85+
86+
let a = input("hello")
87+
```
88+
```reason
89+
[@module "hello"] external input: string => string = "default";
90+
91+
let a = input("hello");
92+
```
93+
```ocaml
94+
external input : string -> string = "default" [@@module "hello"]
95+
96+
let a = input "hello"
97+
```
98+
99+
</CodeTab>
100+
101+
Will now be compiled properly under es6 format as below:
102+
103+
```js
104+
import Hello from "hello";
105+
var a = Hello("hello");
106+
```
107+
108+
109+
## Customized js file extension support
110+
111+
Now user can pick up their js file extension support per module format:
112+
113+
```json
114+
"package-specs": [{
115+
"module": "es6",
116+
"suffix": ".mjs"
117+
},{
118+
"module": "commonjs",
119+
"suffix": ".cjs"
120+
}],
121+
122+
```
123+
124+
## More flexible filename support
125+
126+
To have better integration with other [JS infrastructures](https://github.com/rescript-lang/rescript-compiler/issues/4624),
127+
for example, Next.js/React Native, we allow file names like `404.res`,
128+
`Button.Android.res` so that it can just be picked up by those tools
129+
130+
131+
132+
## Better type based inference for pattern `let {a,b,c} = value`
133+
134+
Previously, for code like this:
135+
136+
<CodeTab labels={["ReScript", "Reason (Old Syntax)", "ML (Older Syntax)"]}>
137+
138+
```res
139+
module N = {
140+
type t = {x: int}
141+
}
142+
143+
let f = (u: N.t) => {
144+
let {x} = u
145+
x + 1
146+
} /* type error */
147+
```
148+
```reason
149+
module N = {
150+
type t = {x: int};
151+
};
152+
153+
let f = (u: N.t) => {
154+
let {x} = u;
155+
x + 1;
156+
}; /* type error */
157+
```
158+
```ocaml
159+
module N = struct
160+
type t = {
161+
x : int
162+
}
163+
end
164+
165+
let f (u : N.t) =
166+
let {x } = u in x + 1 (* type error *)
167+
```
168+
169+
</CodeTab>
170+
171+
You will get a type error
172+
173+
```
174+
Error: Unbound record field x
175+
```
176+
177+
However, since the compiler already knows the type of `u`, it is capable of looking up the label `x` properly.
178+
In this release, we make the original code style work out of the box without a work-around such as adding a module prefix
179+
like `let {N.x} = ..`
180+
181+
## Build system enhancement
182+
183+
A lot of work is put in improving the build system, we will expand on this topic in the next post!
184+
185+
Happy Hacking!

components/Navigation.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let linkOrActiveDocsSubroute = (~route) => {
3434
};
3535
};
3636

37-
let githubHref = "https://github.com/rescript-lang";
37+
let githubHref = "https://github.com/reason-association/rescript-lang.org#rescript-langorg";
3838
let twitterHref = "https://twitter.com/rescriptlang";
3939
let discourseHref = "https://forum.rescript-lang.org";
4040

index_data/blog_authors.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
{
33
"username": "hongbo",
44
"fullname": "Hongbo Zhang",
5-
"role": "Compiler Team",
5+
"role": "Compiler & Build System",
66
"img_url": "https://pbs.twimg.com/profile_images/3157941111/cf58e90adce60b796f589b2ae5a0394a_400x400.jpeg",
77
"twitter": "bobzhang1988"
88
},
99
{
1010
"username": "chenglou",
1111
"fullname": "Cheng Lou",
12-
"role": "Core Team Member",
12+
"role": "Syntax & Tools",
1313
"img_url": "https://pbs.twimg.com/profile_images/554199709909131265/Y5qUDaCB_400x400.jpeg",
1414
"twitter": "_chenglou"
1515
},
1616
{
1717
"username": "ryyppy",
1818
"fullname": "Patrick Stapfer",
19-
"role": "Reason Association",
19+
"role": "Documentation",
2020
"img_url": "https://pbs.twimg.com/profile_images/1185576475837304839/hvCe6M2r_400x400.jpg",
2121
"twitter": "ryyppy"
2222
},
@@ -36,7 +36,7 @@
3636
},
3737
{
3838
"username": "rescript-team",
39-
"fullname": "ReScript Team",
39+
"fullname": "ReScript",
4040
"role": "Core Team",
4141
"img_url": null,
4242
"twitter": null

index_data/blog_posts.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2+
"release-8-3-pt1": "2020-09-25-release-8-3.mdx",
23
"new-rescript-logo": "2020-08-28-new-rescript-logo.mdx",
3-
4-
"bucklescript-is-rebranding": "archive/bucklescript-is-rebranding",
4+
"bucklescript-is-rebranding": "archive/bucklescript-is-rebranding.mdx",
55
"a-note-on-bucklescripts-future-commitments": "archive/a-note-on-bucklescripts-future-commitments.mdx",
66
"a-small-step-for-bucklescript": "archive/a-small-step-for-bucklescript.mdx",
77
"a-story-of-exception-encoding": "archive/a-story-of-exception-encoding.mdx",

0 commit comments

Comments
 (0)