Skip to content

Commit 5c86226

Browse files
committed
Upgrade ReScript to v11 beta
1 parent 1cc321a commit 5c86226

23 files changed

+49
-53
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
env:
5858
REPO: self
5959
BRANCH: jsoo-stdlib
60-
FOLDER: dist_jsoo
60+
FOLDER: dist/jsoo
6161
TAG: jsoo-stdlib-${{ github.event.release.tag_name }}
6262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6363
MESSAGE: "Build ({sha}) {msg}"

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,5 @@ test/jsoo/src/*.mli
307307
test/jsoo/src/stub.js
308308

309309
# Dist artifacts
310-
dist
311-
dist_jsoo/src/ts2ocaml_*.ml*
310+
dist/js/
311+
dist/jsoo/src/ts2ocaml_*.ml*

build/build.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let setup () =
4646
Target.create "Clean" <| fun _ ->
4747
!! "src/bin"
4848
++ "src/obj"
49-
++ distDir
49+
++ (distDir </> "js") // clean ts2ocaml.js
5050
++ "src/.fable"
5151
|> Seq.iter Shell.cleanDir
5252

@@ -122,7 +122,7 @@ module Test =
122122

123123
let packages = [
124124
// "full" package involving a lot of inheritance
125-
"full", !! "node_modules/typescript/lib/typescript.d.ts", ["--safe-arity=off"];
125+
"full", !! "node_modules/typescript/lib/typescript.d.ts", [];
126126

127127
// "full" packages involving a lot of dependencies (which includes some "safe" packages)
128128
"safe", !! "node_modules/@types/scheduler/tracing.d.ts", [];
@@ -239,7 +239,7 @@ module Publish =
239239
Yarn.exec $"version --new-version {newVersion} --no-git-tag-version" id
240240

241241
module Jsoo =
242-
let targetDir = "./dist_jsoo"
242+
let targetDir = distDir </> "jsoo"
243243
let duneProject = targetDir </> "dune-project"
244244

245245
let copyArtifacts () =
@@ -262,10 +262,10 @@ module Publish =
262262
if result.Success then
263263
let oldVersion = result.Groups.[1].Value
264264
if oldVersion <> newVersion then
265-
printfn $"* updating version in dist_jsoo/dune-project from '{oldVersion}' to '{newVersion}'."
265+
printfn $"* updating version in dist/jsoo/dune-project from '{oldVersion}' to '{newVersion}'."
266266
content |> String.replace result.Value $"(version {newVersion})"
267267
else
268-
printfn $"* version in dist_jsoo/dune-project not updated ('{newVersion}')."
268+
printfn $"* version in dist/jsoo/dune-project not updated ('{newVersion}')."
269269
content
270270
else content
271271
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

dist_rescript/package.json renamed to dist/res/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"author": "",
1313
"license": "Apache-2.0",
1414
"dependencies": {
15-
"rescript": "*"
15+
"rescript": "^11.0.0-beta.3"
1616
}
1717
}
File renamed without changes.

dist/res/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
rescript@^11.0.0-beta.3:
6+
version "11.0.0-beta.3"
7+
resolved "https://registry.yarnpkg.com/rescript/-/rescript-11.0.0-beta.3.tgz#f883a19aa8cb2ab162fd2c9f3d46d2c05cc5710b"
8+
integrity sha512-j3YT3VdWMoHgwL4RydKJm9O/VIpN3NTI6keP18rZVJ8ansRKgkHYGLaIwoG6iVqSYYwBjb6d8l8oZ1Jz0fmTeQ==

dist_rescript/package-lock.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/development.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ Modules with **\[\<AutoOpen\>\]** does not require `open` to use.
3434
- `Main.fs` ... entry point
3535
- `test/`
3636
- `jsoo/` ... test for `js_of_ocaml` target
37-
- `dist/` ... output directory for NPM packaging
38-
- `dist_jsoo/` ... output directory for OPAM packaging
37+
- `dist/`
38+
- `js/ `... output directory for NPM packaging
39+
- `jsoo/` ... output directory for OPAM packaging
3940
- `output/` ... temporary output directory for automated testing, etc
4041

4142
## Requirements
@@ -54,7 +55,7 @@ Modules with **\[\<AutoOpen\>\]** does not require `open` to use.
5455

5556
## Debugging
5657

57-
`./fake watch` to live update `dist/ts2ocaml.js`.
58+
`./fake watch` to live update `dist/js/ts2ocaml.js`.
5859

5960
It will be bundled by Webpack with the `development` mode.
6061

@@ -64,9 +65,9 @@ It will be bundled by Webpack with the `development` mode.
6465
- `yarn install` to populate `node_modules`
6566
- `dotnet restore ts2ocaml.sln` to install required F# libraries
6667
- Compile F# source files into JS source files (through Fable)
67-
- Bundle the JS files into `dist/ts2ocaml.js` (through Webpack)
68+
- Bundle the JS files into `dist/js/ts2ocaml.js` (through Webpack)
6869

69-
The resulting `dist/ts2ocaml.js` is then ready to run through `node`.
70+
The resulting `dist/js/ts2ocaml.js` is then ready to run through `node`.
7071

7172
## Testing
7273

@@ -96,12 +97,12 @@ The resulting `dist/ts2ocaml.js` is then ready to run through `node`.
9697

9798
### Prepare for publishing the standard library for [`js_of_ocaml` target](js_of_ocaml.md) to the `jsoo-stdlib` branch
9899

99-
- Copy `ts2ocaml_*.mli` from `output/test_jsoo/` to `dist_jsoo/src/`
100-
- Copy `ts2ocaml_*.ml` from `test/jsoo/_build/default/src/` to `dist_jsoo/src/`
101-
- Set the correct `version` in `dist_jsoo/dune-project`
102-
- Perform `dune build` in `dist_jsoo/` to generate `.opam` file and check if it compiles
100+
- Copy `ts2ocaml_*.mli` from `output/test_jsoo/` to `dist/jsoo/src/`
101+
- Copy `ts2ocaml_*.ml` from `test/jsoo/_build/default/src/` to `dist/jsoo/src/`
102+
- Set the correct `version` in `dist/jsoo/dune-project`
103+
- Perform `dune build` in `dist/jsoo/` to generate `.opam` file and check if it compiles
103104

104-
GitHub Action `publish.yml` is configured to push the `dist_jsoo` directory to the `jsoo-stdlib` branch.
105+
GitHub Action `publish.yml` is configured to push the `dist/jsoo` directory to the `jsoo-stdlib` branch.
105106

106107
### Prepare for publishing the tool to NPM
107108

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
},
1818
"homepage": "https://github.com/ocsigen/ts2ocaml",
1919
"scripts": {
20-
"ts2ocaml": "node ./dist/ts2ocaml.js"
20+
"ts2ocaml": "node ./dist/js/ts2ocaml.js"
2121
},
2222
"files": [
23-
"dist/"
23+
"dist/js/"
2424
],
25-
"main": "./dist/ts2ocaml.js",
26-
"bin": "./dist/ts2ocaml.js",
25+
"main": "./dist/js/ts2ocaml.js",
26+
"bin": "./dist/js/ts2ocaml.js",
2727
"dependencies": {
2828
"@babel/code-frame": "^7.18.6",
2929
"browser-or-node": "^2.0.0",
@@ -43,7 +43,7 @@
4343
"cdk8s": "^2.2.41",
4444
"monaco-editor": "0.40.0",
4545
"react-player": "2.12.0",
46-
"rescript": "^10.0.0",
46+
"rescript": "^11.0.0-beta.3",
4747
"ts2fable": "0.8.0-build.723",
4848
"webpack": "5.88.0",
4949
"webpack-cli": "5.1.0",

src/Targets/ReScript/Common.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,4 @@ type Output = {
240240
res: text
241241
}
242242

243-
let [<ImportDefault("../../../dist_rescript/src/ts2ocaml.res?raw")>] stdlib: string = jsNative
243+
let [<ImportDefault("../../../dist/res/src/ts2ocaml.res?raw")>] stdlib: string = jsNative

src/Targets/ReScript/ReScriptHelper.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open DataTypes.Text
99

1010
module Source =
1111
open Fable.Core
12-
let [<ImportDefault("rescript/lib/ocaml/dom.ml?raw")>] dom: string = jsNative
12+
let [<ImportDefault("rescript/lib/ocaml/dom.res?raw")>] dom: string = jsNative
1313

1414
let comment text =
1515
if text = empty then empty
@@ -240,7 +240,7 @@ module Type =
240240
Source.dom
241241
|> String.splitManyThenRemoveEmptyEntries ["\n"; "\r"]
242242
|> Array.filter (fun s -> s.StartsWith("type "))
243-
|> Array.choose (fun s -> s |> String.replace "type " "" |> String.splitMany [" = "; " (*"] |> Array.tryHead)
243+
|> Array.choose (fun s -> s |> String.replace "type " "" |> String.splitMany [" = "; " /*"] |> Array.tryHead)
244244
|> Array.filter (fun s -> s.Length > 0 && s.ToCharArray() |> Array.forall Char.isAlphabet)
245245
|> Array.map (fun s -> Naming.upperFirst s, "Dom." + s)
246246
let ignoreCase =

src/Targets/ReScript/Writer.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,10 @@ let rec emitMembers flags overrideFunc ctx (selfTy: Type) (isExportDefaultClass:
750750
| Choice2Of2 _ :: rest ->
751751
let name = sprintf "arg%d" index |> rename
752752
go (index+1) false ({| ml = str name; js = name; used = true |} :: acc) rest
753-
| Choice1Of2 { name = name; isOptional = isOptional } :: rest ->
754-
let ml = if isOptional then sprintf "~%s=?" name else "~" + name
753+
| Choice1Of2 { name = name; isOptional = isOptional' } :: rest ->
754+
let ml = if isOptional' then sprintf "~%s=?" name else "~" + name
755755
let js = name |> String.replace "'" "$p"
756-
go (index+1) isOptional ({| ml = str ml; js = js; used = true |} :: acc) rest
756+
go (index+1) (isOptional || isOptional') ({| ml = str ml; js = js; used = true |} :: acc) rest
757757
go 1 false [] args
758758
let body =
759759
let args =

test/res/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"@ocsigen/ts2ocaml": "link:../../"
1616
},
1717
"dependencies": {
18-
"rescript": "^10.0.0"
18+
"rescript": "^11.0.0-beta.3"
1919
}
2020
}

test/res/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ require-directory@^2.1.1:
138138
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
139139
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
140140

141-
rescript@^10.0.0:
142-
version "10.0.0"
143-
resolved "https://registry.yarnpkg.com/rescript/-/rescript-10.0.0.tgz#8460bc6f7d94bc580eac02d7c7efdf0a470916b8"
144-
integrity sha512-LhNg/4+0j8NvoFeslgAeYLlzUwkq6kR6l6v8BnZ61VDTxopK2l96uT1lq5lv1aMxzMDynvE2qnX0zalre+6XxA==
141+
rescript@^11.0.0-beta.3:
142+
version "11.0.0-beta.3"
143+
resolved "https://registry.yarnpkg.com/rescript/-/rescript-11.0.0-beta.3.tgz#f883a19aa8cb2ab162fd2c9f3d46d2c05cc5710b"
144+
integrity sha512-j3YT3VdWMoHgwL4RydKJm9O/VIpN3NTI6keP18rZVJ8ansRKgkHYGLaIwoG6iVqSYYwBjb6d8l8oZ1Jz0fmTeQ==
145145

146146
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
147147
version "4.2.3"

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const webpack = require('webpack');
66

77
var CONFIG = {
88
fsharpEntry: './src/Main.fs.js',
9-
outputDir: './dist',
9+
outputDir: './dist/js',
1010
}
1111

1212
var path = require("path");

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,10 +2732,10 @@ requires-port@^1.0.0:
27322732
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
27332733
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
27342734

2735-
rescript@^10.0.0:
2736-
version "10.0.0"
2737-
resolved "https://registry.yarnpkg.com/rescript/-/rescript-10.0.0.tgz#8460bc6f7d94bc580eac02d7c7efdf0a470916b8"
2738-
integrity sha512-LhNg/4+0j8NvoFeslgAeYLlzUwkq6kR6l6v8BnZ61VDTxopK2l96uT1lq5lv1aMxzMDynvE2qnX0zalre+6XxA==
2735+
rescript@^11.0.0-beta.3:
2736+
version "11.0.0-beta.3"
2737+
resolved "https://registry.yarnpkg.com/rescript/-/rescript-11.0.0-beta.3.tgz#f883a19aa8cb2ab162fd2c9f3d46d2c05cc5710b"
2738+
integrity sha512-j3YT3VdWMoHgwL4RydKJm9O/VIpN3NTI6keP18rZVJ8ansRKgkHYGLaIwoG6iVqSYYwBjb6d8l8oZ1Jz0fmTeQ==
27392739

27402740
resolve-cwd@^3.0.0:
27412741
version "3.0.0"

0 commit comments

Comments
 (0)