Skip to content

Commit cbd365e

Browse files
committed
Merge branch 'master' of github.com:jderochervlk/rescript-lang.org into core
2 parents 43a3394 + 67ecba3 commit cbd365e

File tree

86 files changed

+2941
-1292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2941
-1292
lines changed

.github/workflows/pull-request.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ jobs:
44
build:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v2
8-
- uses: actions/setup-node@v2
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-node@v4
99
with:
10-
node-version: 14.x
10+
node-version: 20
11+
cache: npm
1112
- run: npm ci
1213
- run: npx rescript
1314
- run: npm test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ This is the official documentation platform for the [ReScript](https://rescript-
1616

1717
## System Requirements
1818

19-
- `node@16.x` or higher (for ES6 module compat)
20-
- `npm@7` or higher (package-lock v2)
19+
- `node@18` or higher
20+
- `npm@10` or higher
2121

2222
## Setup
2323

_blogposts/2023-06-05-first-class-dynamic-import-support.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module LazyTitle = {
9191
let titleJsx = <LazyTitle text="Hello!" />
9292
```
9393

94-
That's all the code we need! The new `<LazyTitle />` component behaves exactly the same as the wrapped `<Title />` component, but will be lazy loaded via React's built in lazy mechanism.
94+
That's all the code we need! The new `<LazyTitle />` component behaves exactly the same as the wrapped `<Title />` component, but will be lazy loaded via React's built-in lazy mechanism.
9595

9696
Needless to say, all the code examples you've seen so far are fully type-safe.
9797

@@ -132,7 +132,6 @@ Feel free to try out our new dynamic import feature with the latest beta release
132132

133133
Please note that this release is only intended for experiments and feedback purposes.
134134

135-
136135
## Conclusion
137136

138137
The most important take away of the new dynamic imports functionality in ReScript is that you'll never need to care about _where_ what you're importing is located on the file system - the compiler already does it for you.

_blogposts/2024-01-11-release-11-0-0.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: |
1010

1111
Almost a year after the last release, ReScript is available in version 11! It marks the second major community-driven release and we are very thankful that there are so many willing contributors who invested their spare time into improving the compiler and its ecosystem.
1212

13-
Use your favorite package manager to install the new compiler release, e.g:
13+
Use your favorite package manager to install the new compiler release, e.g.:
1414

1515
```sh
1616
npm install rescript@11
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
---
2+
author: rescript-team
3+
date: "2024-04-19"
4+
previewImg: /static/blog/compiler_release_11_1.jpg
5+
title: ReScript 11.1
6+
badge: release
7+
description: |
8+
Unleashing ReScript from React
9+
---
10+
11+
At the beginning of the year, the ReScript team [released ReScript 11.0](/blog/release-11-0-0), which laid ground work for a lot of possible improvements to make it easier to interact with the JavaScript ecosystem.
12+
13+
This next minor has some wonderful additions to the ReScript toolbelt for you today.
14+
15+
Use your favorite package manager to install the new compiler release, e.g.:
16+
17+
```sh
18+
npm install rescript@11.1
19+
```
20+
21+
Find a list of all the new features below:
22+
23+
## JSX for more than React
24+
25+
Historically, ReScript has focused mainly on React for its frontend support. This has led to ReScript having a great JSX transform built into the language itself. However, that JSX transform has been quite difficult to use with anything but React.
26+
27+
With v11.1, that changes! The JSX transform can now be configured to work with any framework. First class React support is of course still the same, and remains a priority. This makes it possible to integrate any other framework's JSX idiomatically in ReScript. And, all the tooling like autocompletion of prop names and types just works.
28+
29+
Many popular frameworks like [Vue](https://vuejs.org/) and [Preact](https://preactjs.com/) use JSX. But, JSX is also becoming more and more ubiquitous, and these days JSX can also be used for everything from building CLI apps to responsive e-mail templating. We're happy that ReScript users will now be able to leverage all of these innovations in a more idiomatic way than before.
30+
31+
Here's an example of what a Preact integration could look like:
32+
33+
```rescript
34+
// Greet.res
35+
36+
// @jsx.component works the same as @react.component does in React
37+
@jsx.component
38+
let make = (~name) => {
39+
<div>
40+
{Preact.string("Hello " ++ name)}
41+
</div>
42+
}
43+
```
44+
45+
Read more in the [new documentation on the generic JSX transform](/docs/manual/latest/jsx#generic-jsx-transform-jsx-beyond-react-experimental).
46+
47+
## Tagged template literals
48+
49+
This release comes with support for [tagged templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates).
50+
51+
A tag function in JavaScript is a function that expects an array of strings and variadic parameters as input. Now it's possibe to bind to such functions with the new [`@taggedTemplate`](/syntax-lookup#taggedTemplate-decorator) decorator:
52+
53+
<CodeTab labels={["ReScript", "JS Output"]}>
54+
55+
```rescript
56+
// see https://bun.sh/docs/runtime/shell
57+
type result = {exitCode: int}
58+
@module("bun") @taggedTemplate
59+
external sh: (array<string>, array<string>) => promise<result> = "$"
60+
61+
let filename = "index.res"
62+
let result = await sh`ls ${filename}`
63+
```
64+
```js
65+
var $$Bun = require("bun");
66+
67+
var filename = "index.res";
68+
69+
var result = await $$Bun.$`ls ${filename}`;
70+
```
71+
72+
</CodeTab>
73+
74+
75+
Of course you can also create your own tag function in ReScript now as well, it is just a function with the following signature.
76+
77+
```rescript
78+
let myTagFunction : (array<string>, array<'param>) => 'output
79+
```
80+
81+
Refer to the docs to find a [detailed example](/docs/manual/latest/tagged-templates).
82+
83+
## Import attributes
84+
85+
Import attributes is a JS feature that is [currently in standardization](https://github.com/tc39/proposal-import-attributes), but is already implemented by many JS tools. Now, ReScript supports it too, as long as the compiler is configured to output ES6.
86+
87+
<CodeTab labels={["ReScript", "JS Output"]}>
88+
89+
```res
90+
@module({from: "./myJson.json", with: {type_: "json", \"some-identifier": "yep"}})
91+
external myJson: Js.Json.t = "default"
92+
Console.log(myJson)
93+
94+
@module({from: "./myCss.css", with: {type_: "css", \"some-identifier": "yep"}})
95+
external buttonCss: string = "button"
96+
Console.log(buttonCss)
97+
```
98+
```js
99+
import * as MyCssCss from "./myCss.css" with {"type": "css", "some-identifier": "yep"};
100+
import MyJsonJson from "./myJson.json" with {"type": "json", "some-identifier": "yep"};
101+
102+
var myJson = MyJsonJson;
103+
console.log(myJson);
104+
105+
var buttonCss = MyCssCss.button;
106+
console.log(buttonCss);
107+
```
108+
</CodeTab>
109+
110+
## BigInt support
111+
112+
ReScript now natively supports [JavaScript's `bigint` type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt).
113+
114+
<CodeTab labels={["ReScript", "JS Output"]}>
115+
116+
```res example
117+
open! Js.BigInt
118+
119+
let a = 9007199254740991n + 9007199254740991n
120+
let b = 2n ** 2n
121+
```
122+
```js
123+
var a = 9007199254740991n + 9007199254740991n;
124+
125+
var p = 2n ** 2n;
126+
```
127+
128+
</CodeTab>
129+
130+
See [big integer docs](https://rescript-lang.org/docs/manual/latest/primitive-types#big-integers-experimental) for more.
131+
132+
## Array spread syntax
133+
134+
The spread syntax, which was already supported for records and lists for a long time, now also supports arrays!
135+
136+
```rescript
137+
let animals = ["🐶", "🐱", "🐷"]
138+
let moreAnimals = [...animals, "🐔", "🐴", "🐮"]
139+
```
140+
141+
## Hyphens in JSX tag names
142+
143+
We lifted restrictions on JSX tag names. This means you no longer need to escape tag names that contain hyphens:
144+
145+
Previously:
146+
147+
```rescript
148+
let x = <\"custom-tag" />
149+
```
150+
151+
Now:
152+
153+
```rescript
154+
let x = <custom-tag />
155+
```
156+
157+
This is particularly useful when dealing with [web components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components), where element names tend to use hyphens.
158+
159+
## Omit trailing undefined in external function calls
160+
161+
ReScript 11's uncurried mode allows for much more ergonomic external function bindings, because trailing units are not needed anymore. But, this comes with a potential problem. All arguments, whether they're actually supplied or not, were printed as `undefined` in the resulting JS. This is handled better now, as trailing `undefined`s are automatically omitted.
162+
163+
<CodeTab labels={["ReScript", "JS Output (ReScript 11.0)", "JS Output (ReScript 11.1)"]}>
164+
165+
```res
166+
@val
167+
external stringify: (
168+
'a,
169+
~replacer: (string, JSON.t) => JSON.t=?,
170+
~space: int=?,
171+
) => string = "JSON.stringify"
172+
173+
let obj = {"test": 1}
174+
175+
let result = stringify(obj)
176+
177+
let result2 = stringify(obj, ~space=2)
178+
```
179+
```js
180+
var obj = {
181+
test: 1
182+
};
183+
184+
var result = JSON.stringify(obj, undefined, undefined);
185+
186+
var result2 = JSON.stringify(obj, undefined, 2);
187+
```
188+
```js
189+
var obj = {
190+
test: 1
191+
};
192+
193+
var result = JSON.stringify(obj);
194+
195+
var result2 = JSON.stringify(obj, undefined, 2);
196+
```
197+
</CodeTab>
198+
199+
## %todo and warn-error
200+
201+
Inspired by languages like [Elm](https://package.elm-lang.org/packages/elm/core/latest/Debug#todo) or [Gleam](https://tour.gleam.run/advanced-features/todo/), we introduced a new extension point: [`%todo`](/syntax-lookup#todo).
202+
203+
It is used to tell the compiler that some code still needs to be implemented and it will crash when executed.
204+
205+
<CodeTab labels={["ReScript", "JS Output"]}>
206+
207+
```res
208+
let implementMeLater = (): string => %todo("This should return a string eventually.")
209+
210+
let x = implementMeLater()
211+
212+
Console.log(x->String.includes("x"))
213+
```
214+
215+
```js
216+
var Js_exn = require("./stdlib/js_exn.js");
217+
218+
function implementMeLater() {
219+
return Js_exn.raiseError("playground.res:1:37-42 - Todo: This should return a string eventually.");
220+
}
221+
222+
var x = Js_exn.raiseError("playground.res:1:37-42 - Todo: This should return a string eventually.");
223+
224+
console.log(x.includes("x"));
225+
```
226+
227+
</CodeTab>
228+
229+
We also made the compiler's `-warn-error` flag accessible by the build system, so that `%todo`s and other warnings can be turned into errors in production builds.
230+
231+
```sh
232+
rescript -warn-error +110
233+
```
234+
235+
See ["Compile with stricter errors in CI"](/docs/manual/latest/build-overview#compile-with-stricter-errors-in-ci).
236+
237+
## Other changes
238+
239+
Of course we also got a bunch of other changes and bug fixes in this release. Check out the [compiler changelog](https://github.com/rescript-lang/rescript-compiler/blob/11.0_release/CHANGELOG.md#1110-rc1) if you are interested.
240+
241+
242+
## v12 is next
243+
v11.1 marks the completion of the v11 versions feature wise. We will of course continue to support the v11 release series with bug fixes and other important updates. However, our focus for new feature development will move to v12. You'll hear more about v12 and the plans for that version soon.
244+
245+
## Acknowledgements
246+
247+
Once again we want to thank everyone from the community who volunteered their precious time to support this project with contributions of any kind, from documentation, to PRs, to discussions in the forum. But especially we want to thank the following people, who helped landing this release:
248+
249+
[@aspeddro](https://github.com/aspeddro), [@cknitt](https://github.com/cknitt), [@cometkim](https://github.com/cometkim), [@cristianoc](https://github.com/cristianoc), [@diogomqbm](https://github.com/diogomqbm), [@enzo-pellegrini](https://github.com/enzo-pellegrini), [@fhammerschmidt](https://github.com/fhammerschmidt), [@glennsl](https://github.com/glennsl), [@JonoPrest](https://github.com/JonoPrest), [@mununki](https://github.com/mununki), [@kevinbarabash](https://github.com/kevinbarabash), [@shulhi](https://github.com/shulhi), [@tsnobip](https://github.com/tsnobip), [@zth](https://github.com/zth).
250+
251+
## That's it
252+
253+
We hope you enjoy the newest improvements as much as we do.
254+
255+
If you find any problems with this new release, make sure to report them here:
256+
257+
- [rescript-lang/rescript-compiler](https://github.com/rescript-lang/rescript-compiler/issues/new/choose)

compilers/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compilers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"rescript-1000": "npm:rescript@10.0.0",
1111
"rescript-1010": "npm:rescript@10.1.0",
1212
"rescript-1100": "npm:rescript@11.0.0",
13-
"rescript-1110": "npm:rescript@11.1.0-rc.2",
13+
"rescript-1110": "npm:rescript@11.1.0-rc.8",
1414
"rescript-820": "npm:bs-platform@8.2.0",
1515
"rescript-902": "npm:bs-platform@9.0.2",
1616
"rescript-912": "npm:rescript@9.1.2"

0 commit comments

Comments
 (0)