Skip to content

Commit 728398f

Browse files
fhammerschmidtcristianoc
authored andcommitted
Add example workspace-project
1 parent d9e03ed commit 728398f

16 files changed

+214
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.exe
2+
*.obj
3+
*.out
4+
*.compile
5+
*.native
6+
*.byte
7+
*.cmo
8+
*.annot
9+
*.cmi
10+
*.cmx
11+
*.cmt
12+
*.cmti
13+
*.cma
14+
*.a
15+
*.cmxa
16+
*.obj
17+
*~
18+
*.annot
19+
*.cmj
20+
*.bak
21+
lib
22+
*.mlast
23+
*.mliast
24+
.vscode
25+
.merlin
26+
.bsb.lock
27+
/node_modules/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# ReScript workspaces example (monorepo)
2+
3+
```
4+
npm install
5+
npm run build
6+
npm run start
7+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "app",
3+
"bsc-flags": ["-open Common"],
4+
"bs-dependencies": ["common", "myplugin"],
5+
"sources": [
6+
{
7+
"dir": "src",
8+
"subdirs": true
9+
}
10+
]
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "app",
3+
"version": "0.1.0"
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let _ = Myplugin.Promise.resolve(Utils.printError("Oh no!"))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "workspace-project",
3+
"version": "0.1.0",
4+
"sources": [],
5+
"package-specs": {
6+
"module": "es6",
7+
"in-source": true
8+
},
9+
"suffix": ".mjs",
10+
"pinned-dependencies": ["common", "myplugin", "app"],
11+
"bs-dependencies": ["common", "myplugin", "app"]
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "common",
3+
"namespace": true,
4+
"sources": [
5+
{
6+
"dir": "src",
7+
"subdirs": true
8+
}
9+
]
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "common",
3+
"version": "0.1.0"
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
function printError(error) {
5+
var errorMessage = "\u001b[31m" + error;
6+
console.log(errorMessage);
7+
8+
}
9+
10+
export {
11+
printError ,
12+
13+
}
14+
/* No side effect */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let printError = error => {
2+
let errorMessage = `\u001b[31m${error}`
3+
Js.log(errorMessage)
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "myplugin",
3+
"namespace": true,
4+
"sources": [
5+
{
6+
"dir": "src",
7+
"subdirs": true
8+
}
9+
]
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "myplugin",
3+
"version": "0.1.0"
4+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
import * as Curry from "rescript/lib/es6/curry.js";
4+
import * as Js_exn from "rescript/lib/es6/js_exn.js";
5+
import * as Caml_exceptions from "rescript/lib/es6/caml_exceptions.js";
6+
7+
var JsError = /* @__PURE__ */Caml_exceptions.create("Promise-Myplugin.JsError");
8+
9+
function $$catch(promise, callback) {
10+
return promise.catch(function (err) {
11+
return Curry._1(callback, Js_exn.anyToExnInternal(err));
12+
});
13+
}
14+
15+
export {
16+
JsError ,
17+
$$catch ,
18+
19+
}
20+
/* No side effect */
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
type t<+'a> = Js.Promise.t<'a>
2+
3+
exception JsError(Js.Exn.t)
4+
external unsafeToJsExn: exn => Js.Exn.t = "%identity"
5+
6+
@new
7+
external make: ((@uncurry (. 'a) => unit, (. 'e) => unit) => unit) => t<'a> = "Promise"
8+
9+
@val @scope("Promise")
10+
external resolve: 'a => t<'a> = "resolve"
11+
12+
@send external then: (t<'a>, @uncurry ('a => t<'b>)) => t<'b> = "then"
13+
14+
@send
15+
external thenResolve: (t<'a>, @uncurry ('a => 'b)) => t<'b> = "then"
16+
17+
@send external finally: (t<'a>, unit => unit) => t<'a> = "finally"
18+
19+
@scope("Promise") @val
20+
external reject: exn => t<_> = "reject"
21+
22+
@scope("Promise") @val
23+
external all: array<t<'a>> => t<array<'a>> = "all"
24+
25+
@scope("Promise") @val
26+
external all2: ((t<'a>, t<'b>)) => t<('a, 'b)> = "all"
27+
28+
@scope("Promise") @val
29+
external all3: ((t<'a>, t<'b>, t<'c>)) => t<('a, 'b, 'c)> = "all"
30+
31+
@scope("Promise") @val
32+
external all4: ((t<'a>, t<'b>, t<'c>, t<'d>)) => t<('a, 'b, 'c, 'd)> = "all"
33+
34+
@scope("Promise") @val
35+
external all5: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>)) => t<('a, 'b, 'c, 'd, 'e)> = "all"
36+
37+
@scope("Promise") @val
38+
external all6: ((t<'a>, t<'b>, t<'c>, t<'d>, t<'e>, t<'f>)) => t<('a, 'b, 'c, 'd, 'e, 'f)> = "all"
39+
40+
@send
41+
external _catch: (t<'a>, @uncurry (exn => t<'a>)) => t<'a> = "catch"
42+
43+
let catch = (promise, callback) => _catch(promise, err => callback(Js.Exn.anyToExnInternal(err)))
44+
45+
@scope("Promise") @val
46+
external race: array<t<'a>> => t<'a> = "race"

analysis/examples/workspace-project/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "workspace-project",
3+
"private": true,
4+
"version": "0.1.0",
5+
"scripts": {
6+
"clean": "rescript clean",
7+
"build": "rescript build -with-deps",
8+
"start": "node app/src/App.mjs",
9+
"watch": "rescript build -w"
10+
},
11+
"keywords": [
12+
"ReScript"
13+
],
14+
"author": "",
15+
"license": "MIT",
16+
"devDependencies": {
17+
"rescript": "^10.0.0-beta.3"
18+
},
19+
"workspaces": {
20+
"packages": [
21+
"app",
22+
"common",
23+
"myplugin"
24+
]
25+
}
26+
}

0 commit comments

Comments
 (0)