forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.js
executable file
·140 lines (127 loc) · 3.05 KB
/
repl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/env node
var p = require("child_process");
var fs = require("fs");
var path = require("path");
process.env.BS_RELEASE_BUILD = 1;
var jscompDir = path.join(__dirname, "..", "jscomp");
var config = {
cwd: jscompDir,
encoding: "utf8",
stdio: [0, 1, 2],
shell: true
};
function e(cmd) {
console.log(`>>>>>> running command: ${cmd}`);
p.execSync(cmd, config);
console.log(`<<<<<<`);
}
if (!process.env.BS_PLAYGROUND) {
var defaultPlayground = `../../bucklescript-playground`;
console.warn(
`BS_PLAYGROUND env var unset, defaulting to ${defaultPlayground}`
);
process.env.BS_PLAYGROUND = defaultPlayground;
}
var playground = process.env.BS_PLAYGROUND;
function prepare() {
e(`hash hash js_of_ocaml 2>/dev/null || { echo >&2 "js_of_ocaml not found on path. Please install version 2.8.4 (although not with the buckelscript switch) and put it on your path."; exit 1; }
`);
e(`./bin/cmjbrowser.exe`);
var js_compiler_path = `../lib/4.06.1/unstable`;
e(
`ocamlc.opt -w -30-40 -no-check-prims -I ${js_compiler_path} ${js_compiler_path}/js_compiler.mli ${js_compiler_path}/js_compiler.ml -o jsc.byte`
);
e(`cp ../lib/js/*.js ${playground}/stdlib`);
}
// needs js_cmj_datasets, preload.js and amdjs to be update
prepare();
console.log(`playground : ${playground}`);
var includes = [`stdlib-406`, `runtime`, `others`]
.map(x => path.join(jscompDir, x))
.map(x => `-I ${x}`)
.join(` `);
var cmi_files = [
// `lazy`,
`js`,
`js_re`,
`js_array`,
`js_array2`,
`js_null`,
`js_undefined`,
`js_types`,
`js_null_undefined`,
`js_dict`,
`js_exn`,
`js_string`,
`js_string2`,
`js_vector`,
`js_date`,
`js_console`,
`js_global`,
`js_math`,
`js_obj`,
`js_int`,
`js_result`,
`js_list`,
`js_typed_array`,
`js_typed_array2`,
`js_mapperRt`,
`js_promise`,
`js_option`,
`js_float`,
`js_json`,
/*
These files cause troubles when compiled with JSOO (v3.4.0)
Be aware, if those are included you will get an error stating something like "/static/cmis/scanf.cmi : file already exists"
*/
// `arrayLabels`,
// `bytesLabels`,
// `complex`,
// `gc`,
// `genlex`,
// `listLabels`,
// `moreLabels`,
// `queue`,
// `scanf`,
// `sort`,
// `stack`,
// `stdLabels`,
// `stream`,
// `stringLabels`,
`dom`,
`belt`,
`belt_Id`,
`belt_Array`,
`belt_SortArray`,
`belt_SortArrayInt`,
`belt_SortArrayString`,
`belt_MutableQueue`,
`belt_MutableStack`,
`belt_List`,
`belt_Range`,
`belt_Set`,
`belt_SetInt`,
`belt_SetString`,
`belt_Map`,
`belt_MapInt`,
`belt_Option`,
`belt_MapString`,
`belt_MutableSet`,
`belt_MutableSetInt`,
`belt_MutableSetString`,
`belt_MutableMap`,
`belt_MutableMapInt`,
`belt_MutableMapString`,
`belt_HashSet`,
`belt_HashSetInt`,
`belt_HashSetString`,
`belt_HashMap`,
`belt_HashMapInt`,
`belt_HashMapString`
]
.map(x => `${x}.cmi:/static/cmis/${x}.cmi`)
.map(x => `--file ${x}`)
.join(` `);
e(
`js_of_ocaml --disable share --toplevel +weak.js ./polyfill.js jsc.byte ${includes} ${cmi_files} -o ${playground}/exports.js`
);