Skip to content

Commit 7feea0e

Browse files
committed
Add Deno sample
1 parent d67e773 commit 7feea0e

File tree

8 files changed

+118
-3
lines changed

8 files changed

+118
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,3 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
3838

3939
# ReScript
4040
lib/
41-
42-
hackwaly-test/
43-
repos/deno/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
lib
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"nodeModulesDir": "auto",
3+
"lock": false,
4+
"tasks": {
5+
"build": "rescript",
6+
"clean": "rescript clean"
7+
},
8+
"imports": {
9+
"@rescript/webapi": "npm:@rescript/webapi@^0.1.0-experimental-535a674",
10+
"rescript": "npm:[email protected]"
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "install-test",
3+
"sources": {
4+
"dir": "src",
5+
"subdirs": true
6+
},
7+
"package-specs": {
8+
"module": "esmodule",
9+
"in-source": true,
10+
"suffix": ".res.js"
11+
},
12+
"compiler-flags": [],
13+
"dependencies": ["@rescript/webapi"]
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Console.log(Some(43))
2+
open WebAPI.Global
3+
4+
let location = window.location
5+
Console.log(location)

repos/deno/single-project/src/Index.res.js

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

tests/DenoSingleRepo.test.js

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

tests/DenoSingleRepo.test.res

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
open RescriptBun.Test
2+
3+
/*
4+
5+
deno will install the ReScript compiler into a `node_modules/.deno/@[email protected]` directory.
6+
A direct dependency will be installed into `node_modules/@rescript/webapi`.
7+
And the runtime (Pervasis) will be installed into `node_modules/.deno/@[email protected]`.
8+
9+
If a package has a namespace (like `@rescript/webapi` has `WebAPI`) it needs to have the `-runtime` argument when creating the `.mlmap` file.
10+
Because deno installs all these packages in different directories, we need to ensure this still works.
11+
12+
The original sample is based on https://github.com/jderochervlk/rescript-12-beta-deno
13+
See https://github.com/rescript-lang/rescript/issues/7828
14+
15+
*/
16+
17+
let repo = Path.resolve([import.meta.dir, "../repos/deno/single-project"])
18+
19+
describe("A single ReScript project using deno as package manager", () => {
20+
let orginalCwd: string = Process.cwd(Process.process)
21+
22+
beforeAllAsync(async () => {
23+
await changeCwdToRepository(
24+
repo,
25+
async () => {
26+
let _ = await sh`deno install`
27+
},
28+
)
29+
})
30+
31+
afterAllAsync(async () => {
32+
Process.chdir(Process.process, orginalCwd)
33+
})
34+
35+
testAsync("should clean", async () => {
36+
let _ = await sh`deno task clean`
37+
})
38+
39+
testAsync("should build", async () => {
40+
let _ = await sh`deno task build`
41+
})
42+
})

0 commit comments

Comments
 (0)