Skip to content

Commit deced79

Browse files
committed
Extend generate_cmijs.js to also bundle the compilerCmij.js file for core functionality
1 parent 960b8d9 commit deced79

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/playground-bundling/scripts/generate_cmijs.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ function e(cmd) {
4545

4646
const packages = bsconfig["bs-dependencies"];
4747

48+
// We need to build the compiler's builtin modules as a separate cmij.
49+
// Otherwise we can't use them for compilation within the playground.
50+
function buildCompilerCmij() {
51+
const rescriptLibOcamlFolder = path.join(
52+
PROJECT_ROOT_DIR,
53+
"node_modules",
54+
"rescript",
55+
"lib",
56+
"ocaml"
57+
);
58+
59+
const rescriptCompilerCmijFile = path.join(PACKAGES_DIR, "compilerCmij.js");
60+
61+
e(
62+
`find ${rescriptLibOcamlFolder} -name "*.cmi" -or -name "*.cmj" | xargs -n1 basename | xargs js_of_ocaml build-fs -o ${rescriptCompilerCmijFile} -I ${rescriptLibOcamlFolder}`
63+
);
64+
}
65+
4866
packages.forEach(function installLib(package) {
4967
const libOcamlFolder = path.join(
5068
PROJECT_ROOT_DIR,

0 commit comments

Comments
 (0)