diff --git a/.github/workflows/get_artifact_dir_name.js b/.github/workflows/get_artifact_dir_name.js index 2245c9c65c..7f9071dbdf 100644 --- a/.github/workflows/get_artifact_dir_name.js +++ b/.github/workflows/get_artifact_dir_name.js @@ -1,7 +1,7 @@ const fs = require("fs"); const os = require("os"); -const artifactDirName = require("../../scripts/bin_path").dirName; +const { dirName: artifactDirName } = require("../../cli/bin_path.js"); // Pass artifactDirName to subsequent GitHub actions fs.appendFileSync( diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index e7d10203e5..f26a909146 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -1,7 +1,7 @@ const fs = require("fs"); const os = require("os"); -const packageSpec = JSON.parse(fs.readFileSync("./package.json", "utf8")); +const packageSpec = require("rescript/package.json"); const { version } = packageSpec; const commitHash = process.argv[2] || process.env.GITHUB_SHA; diff --git a/bsc b/bsc index 14c273b2ce..6f82c216c9 100755 --- a/bsc +++ b/bsc @@ -2,7 +2,7 @@ "use strict"; var child_process = require("child_process"); -var bsc_exe = require("./scripts/bin_path").bsc_exe; +var { bsc_exe } = require("./cli/bin_path"); var delegate_args = process.argv.slice(2); diff --git a/scripts/bin_path.js b/cli/bin_path.js similarity index 100% rename from scripts/bin_path.js rename to cli/bin_path.js diff --git a/scripts/rescript_arg.js b/cli/rescript_arg.js similarity index 100% rename from scripts/rescript_arg.js rename to cli/rescript_arg.js diff --git a/scripts/rescript_bsb.js b/cli/rescript_bsb.js similarity index 99% rename from scripts/rescript_bsb.js rename to cli/rescript_bsb.js index 7b79cb1ce4..f0e282ef96 100644 --- a/scripts/rescript_bsb.js +++ b/cli/rescript_bsb.js @@ -4,7 +4,7 @@ const fs = require("fs"); const path = require("path"); var os = require("os"); const child_process = require("child_process"); -const rescript_exe = require("./bin_path").rescript_exe; +const { rescript_exe } = require("./bin_path"); const cwd = process.cwd(); const lockFileName = path.join(cwd, ".bsb.lock"); diff --git a/scripts/rescript_convert.js b/cli/rescript_convert.js similarity index 100% rename from scripts/rescript_convert.js rename to cli/rescript_convert.js diff --git a/scripts/rescript_dump.js b/cli/rescript_dump.js similarity index 100% rename from scripts/rescript_dump.js rename to cli/rescript_dump.js diff --git a/scripts/rescript_format.js b/cli/rescript_format.js similarity index 100% rename from scripts/rescript_format.js rename to cli/rescript_format.js diff --git a/scripts/rescript_postinstall.js b/cli/rescript_postinstall.js similarity index 91% rename from scripts/rescript_postinstall.js rename to cli/rescript_postinstall.js index 16edb6541e..ac5332ac0f 100644 --- a/scripts/rescript_postinstall.js +++ b/cli/rescript_postinstall.js @@ -2,8 +2,7 @@ const child_process = require("child_process"); const fs = require("fs"); -const bsc_exe = require("./bin_path").bsc_exe; -const ninja_exe = require("./bin_path").ninja_exe; +const { bsc_exe, ninja_exe } = require("./bin_path"); function checkNinja() { if (!fs.existsSync(ninja_exe)) { diff --git a/scripts/rewatch b/cli/rewatch similarity index 81% rename from scripts/rewatch rename to cli/rewatch index 3084263e37..269daac37f 100755 --- a/scripts/rewatch +++ b/cli/rewatch @@ -5,7 +5,7 @@ const path = require("path"); const child_process = require("child_process"); -const binAbsolutePath = require("./bin_path").absolutePath; +const { absolutePath: binAbsolutePath } = require("./bin_path"); const rewatchExe = path.join(binAbsolutePath, "rewatch.exe"); const args = process.argv.slice(2); diff --git a/jscomp/build_tests/build_warn_as_error/input.js b/jscomp/build_tests/build_warn_as_error/input.js index 878647f9d9..a00405f010 100644 --- a/jscomp/build_tests/build_warn_as_error/input.js +++ b/jscomp/build_tests/build_warn_as_error/input.js @@ -1,6 +1,6 @@ var p = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var o = p.spawnSync(rescript_exe, ["build", "-warn-error", "+110"], { encoding: "utf8", diff --git a/jscomp/build_tests/case/input.js b/jscomp/build_tests/case/input.js index 0c1f9b6169..8e5cced399 100644 --- a/jscomp/build_tests/case/input.js +++ b/jscomp/build_tests/case/input.js @@ -1,6 +1,6 @@ var p = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname }); if ( diff --git a/jscomp/build_tests/case2/input.js b/jscomp/build_tests/case2/input.js index 998c2d8772..a4a3245189 100644 --- a/jscomp/build_tests/case2/input.js +++ b/jscomp/build_tests/case2/input.js @@ -1,6 +1,6 @@ var p = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var o = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname }); if ( diff --git a/jscomp/build_tests/case3/input.js b/jscomp/build_tests/case3/input.js index a6672a392c..c33330667b 100644 --- a/jscomp/build_tests/case3/input.js +++ b/jscomp/build_tests/case3/input.js @@ -4,7 +4,7 @@ var p = require("child_process"); var fs = require("fs"); var path = require("path"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.spawnSync(`${rescript_exe} clean && ${rescript_exe} build`, { encoding: "utf8", cwd: __dirname, diff --git a/jscomp/build_tests/cmd/input.js b/jscomp/build_tests/cmd/input.js index cbec80a60c..9f995dcc30 100644 --- a/jscomp/build_tests/cmd/input.js +++ b/jscomp/build_tests/cmd/input.js @@ -2,10 +2,10 @@ var p = require("child_process"); var assert = require("assert"); -var bsc_exe_path = require("../../../scripts/bin_path").bsc_exe; +var { bsc_exe: bsc_exe_path } = require("#cli/bin_path"); var react = ` -type u +type u external a : u = "react" [@@module] @@ -23,7 +23,7 @@ external foo : bla = "foo.react" [@@module] external bar : unit -> bla = "bar" [@@val] [@@module "foo.react"] -let c = foo +let c = foo let d = bar () `; diff --git a/jscomp/build_tests/custom_namespace/input.js b/jscomp/build_tests/custom_namespace/input.js index 9c00338056..e4502cb0c4 100644 --- a/jscomp/build_tests/custom_namespace/input.js +++ b/jscomp/build_tests/custom_namespace/input.js @@ -1,6 +1,6 @@ var child_process = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); child_process.execSync(`${rescript_exe} clean && ${rescript_exe} build`, { cwd: __dirname, diff --git a/jscomp/build_tests/cycle/input.js b/jscomp/build_tests/cycle/input.js index 956da90ee5..d94a234e49 100644 --- a/jscomp/build_tests/cycle/input.js +++ b/jscomp/build_tests/cycle/input.js @@ -3,7 +3,7 @@ const cp = require("child_process"); const assert = require("assert"); const fs = require("fs"); const path = require("path"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var output = cp.spawnSync(rescript_exe, { encoding: "utf8", shell: true }); diff --git a/jscomp/build_tests/cycle1/input.js b/jscomp/build_tests/cycle1/input.js index 3c5519e28c..1894a6c1a8 100644 --- a/jscomp/build_tests/cycle1/input.js +++ b/jscomp/build_tests/cycle1/input.js @@ -3,7 +3,7 @@ const cp = require("child_process"); const assert = require("assert"); const fs = require("fs"); const path = require("path"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +const { rescript_exe } = require("#cli/bin_path"); cp.execSync(`${rescript_exe} clean`, { cwd: __dirname }); diff --git a/jscomp/build_tests/deprecated-package-specs/input.js b/jscomp/build_tests/deprecated-package-specs/input.js index ed66ae02ec..bdf2247ecb 100644 --- a/jscomp/build_tests/deprecated-package-specs/input.js +++ b/jscomp/build_tests/deprecated-package-specs/input.js @@ -1,6 +1,6 @@ const child_process = require("child_process"); const assert = require("assert"); -const rescript_exe = require("../../../scripts/bin_path").rescript_exe; +const { rescript_exe } = require("#cli/bin_path"); const out = child_process.spawnSync(rescript_exe, { encoding: "utf8" }); assert.match( diff --git a/jscomp/build_tests/devonly/input.js b/jscomp/build_tests/devonly/input.js index c3a0d575c1..2aec9809b2 100644 --- a/jscomp/build_tests/devonly/input.js +++ b/jscomp/build_tests/devonly/input.js @@ -1,5 +1,5 @@ //@ts-check var cp = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); cp.execSync(rescript_exe, { cwd: __dirname, encoding: "utf8" }); diff --git a/jscomp/build_tests/duplicated_symlinked_packages/input.js b/jscomp/build_tests/duplicated_symlinked_packages/input.js index bb2c7e8c00..a9ee3188e5 100644 --- a/jscomp/build_tests/duplicated_symlinked_packages/input.js +++ b/jscomp/build_tests/duplicated_symlinked_packages/input.js @@ -1,7 +1,7 @@ const fs = require("fs"); const path = require("path"); const child_process = require("child_process"); -const rescript_exe = require("../../../scripts/bin_path").rescript_exe; +const { rescript_exe } = require("#cli/bin_path"); const expectedFilePath = path.join(__dirname, "out.expected"); diff --git a/jscomp/build_tests/exports/input.js b/jscomp/build_tests/exports/input.js index 73d016587b..76ead396b3 100644 --- a/jscomp/build_tests/exports/input.js +++ b/jscomp/build_tests/exports/input.js @@ -1,5 +1,5 @@ var child_process = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); child_process.execSync(rescript_exe, { cwd: __dirname, diff --git a/jscomp/build_tests/hyphen2/input.js b/jscomp/build_tests/hyphen2/input.js index f48b5a83dd..84c35bb893 100644 --- a/jscomp/build_tests/hyphen2/input.js +++ b/jscomp/build_tests/hyphen2/input.js @@ -1,4 +1,4 @@ var p = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.execSync(rescript_exe, { cwd: __dirname }); diff --git a/jscomp/build_tests/in_source/input.js b/jscomp/build_tests/in_source/input.js index f3bbb0a07b..cd04194c5f 100644 --- a/jscomp/build_tests/in_source/input.js +++ b/jscomp/build_tests/in_source/input.js @@ -2,7 +2,7 @@ var child_process = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); assert.throws( () => { diff --git a/jscomp/build_tests/install/input.js b/jscomp/build_tests/install/input.js index 91dda3041e..407e1f9558 100644 --- a/jscomp/build_tests/install/input.js +++ b/jscomp/build_tests/install/input.js @@ -2,7 +2,7 @@ var p = require("child_process"); var fs = require("fs"); var path = require("path"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.spawnSync(rescript_exe, [`clean`], { encoding: "utf8", diff --git a/jscomp/build_tests/nested/input.js b/jscomp/build_tests/nested/input.js index b5c4be920f..a56e24f14e 100644 --- a/jscomp/build_tests/nested/input.js +++ b/jscomp/build_tests/nested/input.js @@ -2,7 +2,7 @@ var p = require("child_process"); var assert = require("assert"); var fs = require("fs"); var path = require("path"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.execSync(rescript_exe, { cwd: __dirname }); var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8"); diff --git a/jscomp/build_tests/nnest/input.js b/jscomp/build_tests/nnest/input.js index b14c3a9b61..e3ad473862 100644 --- a/jscomp/build_tests/nnest/input.js +++ b/jscomp/build_tests/nnest/input.js @@ -4,7 +4,7 @@ var p = require("child_process"); var assert = require("assert"); var fs = require("fs"); var path = require("path"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.execSync(rescript_exe, { cwd: __dirname }); var content = fs.readFileSync(path.join(__dirname, "src", "demo.js"), "utf8"); diff --git a/jscomp/build_tests/ns/input.js b/jscomp/build_tests/ns/input.js index 2cb4c61d6a..55e41645da 100755 --- a/jscomp/build_tests/ns/input.js +++ b/jscomp/build_tests/ns/input.js @@ -1,4 +1,4 @@ var child_process = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); child_process.execSync(rescript_exe, { cwd: __dirname }); diff --git a/jscomp/build_tests/post-build/input.js b/jscomp/build_tests/post-build/input.js index a9bee83493..9cb97455d0 100644 --- a/jscomp/build_tests/post-build/input.js +++ b/jscomp/build_tests/post-build/input.js @@ -1,6 +1,6 @@ var child_process = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = child_process.spawnSync(rescript_exe, { encoding: "utf8" }); diff --git a/jscomp/build_tests/react_ppx/input.js b/jscomp/build_tests/react_ppx/input.js index 060dd913e2..96e9ab8353 100644 --- a/jscomp/build_tests/react_ppx/input.js +++ b/jscomp/build_tests/react_ppx/input.js @@ -1,5 +1,5 @@ //@ts-check var cp = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); cp.execSync(rescript_exe, { cwd: __dirname }); diff --git a/jscomp/build_tests/rerror/input.js b/jscomp/build_tests/rerror/input.js index 54c50c05eb..18276be1cc 100644 --- a/jscomp/build_tests/rerror/input.js +++ b/jscomp/build_tests/rerror/input.js @@ -1,6 +1,6 @@ var child_process = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); child_process.spawnSync(`${rescript_exe} clean`, { cwd: __dirname, encoding: "utf8", diff --git a/jscomp/build_tests/scoped_ppx/input.js b/jscomp/build_tests/scoped_ppx/input.js index 310fbfbad5..c2707b768e 100644 --- a/jscomp/build_tests/scoped_ppx/input.js +++ b/jscomp/build_tests/scoped_ppx/input.js @@ -1,6 +1,6 @@ var cp = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); cp.execSync(rescript_exe, { cwd: __dirname, encoding: "utf8" }); var output = cp.execSync(`${rescript_exe} build -- -t commands src/hello.ast`, { diff --git a/jscomp/build_tests/super_errors/input.js b/jscomp/build_tests/super_errors/input.js index 7af2824f34..55f3b53ecb 100644 --- a/jscomp/build_tests/super_errors/input.js +++ b/jscomp/build_tests/super_errors/input.js @@ -2,7 +2,7 @@ const fs = require("fs"); const path = require("path"); const child_process = require("child_process"); -var bsc = require("../../../scripts/bin_path").bsc_exe; +const { bsc_exe: bsc } = require("#cli/bin_path"); const expectedDir = path.join(__dirname, "expected"); diff --git a/jscomp/build_tests/transitive_pinned_dependency1/input.js b/jscomp/build_tests/transitive_pinned_dependency1/input.js index 080b222f5b..fb6943daee 100644 --- a/jscomp/build_tests/transitive_pinned_dependency1/input.js +++ b/jscomp/build_tests/transitive_pinned_dependency1/input.js @@ -2,7 +2,7 @@ var child_process = require("child_process"); var assert = require("assert"); var fs = require("fs"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); console.log( child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" }) diff --git a/jscomp/build_tests/transitive_pinned_dependency1/package.json b/jscomp/build_tests/transitive_pinned_dependency1/package.json deleted file mode 100644 index cc49c26df7..0000000000 --- a/jscomp/build_tests/transitive_pinned_dependency1/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "top", - "workspaces": [ - "a", - "b", - "c" - ] -} diff --git a/jscomp/build_tests/transitive_pinned_dependency2/input.js b/jscomp/build_tests/transitive_pinned_dependency2/input.js index 2ec048a047..6082cf44e7 100644 --- a/jscomp/build_tests/transitive_pinned_dependency2/input.js +++ b/jscomp/build_tests/transitive_pinned_dependency2/input.js @@ -2,7 +2,7 @@ var child_process = require("child_process"); var assert = require("assert"); var fs = require("fs"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); console.log( child_process.execSync(rescript_exe, { encoding: "utf8", cwd: "./a" }) diff --git a/jscomp/build_tests/transitive_pinned_dependency2/package.json b/jscomp/build_tests/transitive_pinned_dependency2/package.json deleted file mode 100644 index cc49c26df7..0000000000 --- a/jscomp/build_tests/transitive_pinned_dependency2/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "top", - "workspaces": [ - "a", - "b", - "c" - ] -} diff --git a/jscomp/build_tests/unboxed_bool_with_const/input.js b/jscomp/build_tests/unboxed_bool_with_const/input.js index 4591fdadac..45d1db6e7c 100644 --- a/jscomp/build_tests/unboxed_bool_with_const/input.js +++ b/jscomp/build_tests/unboxed_bool_with_const/input.js @@ -2,7 +2,7 @@ var cp = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = cp.spawnSync(rescript_exe, { cwd: __dirname, diff --git a/jscomp/build_tests/uncurried-always/input.js b/jscomp/build_tests/uncurried-always/input.js index 012c1f042b..a7370b0c2f 100644 --- a/jscomp/build_tests/uncurried-always/input.js +++ b/jscomp/build_tests/uncurried-always/input.js @@ -1,6 +1,6 @@ //@ts-check const cp = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); cp.execSync(`${rescript_exe} clean`, { cwd: __dirname }); cp.execSync(`${rescript_exe}`, { cwd: __dirname }); diff --git a/jscomp/build_tests/unicode/input.js b/jscomp/build_tests/unicode/input.js index 9a6b83a036..9208b96e34 100644 --- a/jscomp/build_tests/unicode/input.js +++ b/jscomp/build_tests/unicode/input.js @@ -1,6 +1,6 @@ //@ts-check var child_process = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); console.log(child_process.execSync(rescript_exe, { encoding: "utf8" })); diff --git a/jscomp/build_tests/warn_legacy_config/input.js b/jscomp/build_tests/warn_legacy_config/input.js index ad81e9ec49..2bf5dc8b12 100644 --- a/jscomp/build_tests/warn_legacy_config/input.js +++ b/jscomp/build_tests/warn_legacy_config/input.js @@ -1,6 +1,6 @@ const { spawnSync } = require("child_process"); const assert = require("assert"); -const rescript_exe = require("../../../scripts/bin_path").rescript_exe; +const { rescript_exe } = require("#cli/bin_path"); const output = spawnSync(rescript_exe, { encoding: "utf8" }); assert( diff --git a/jscomp/build_tests/weird_deps/input.js b/jscomp/build_tests/weird_deps/input.js index 6e2a156015..32c2b7e483 100644 --- a/jscomp/build_tests/weird_deps/input.js +++ b/jscomp/build_tests/weird_deps/input.js @@ -2,7 +2,7 @@ var cp = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = cp.spawnSync(rescript_exe, { cwd: __dirname, diff --git a/jscomp/build_tests/weird_devdeps/input.js b/jscomp/build_tests/weird_devdeps/input.js index 6e2a156015..091354500a 100644 --- a/jscomp/build_tests/weird_devdeps/input.js +++ b/jscomp/build_tests/weird_devdeps/input.js @@ -2,7 +2,7 @@ var cp = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var rescript_exe = require("#cli/bin_path").rescript_exe; var out = cp.spawnSync(rescript_exe, { cwd: __dirname, diff --git a/jscomp/build_tests/weird_names/input.js b/jscomp/build_tests/weird_names/input.js index f9643f723c..c8e27d5371 100644 --- a/jscomp/build_tests/weird_names/input.js +++ b/jscomp/build_tests/weird_names/input.js @@ -1,7 +1,7 @@ var cp = require("child_process"); var assert = require("assert"); var path = require("path"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = cp.spawnSync(rescript_exe, { encoding: "utf8" }); diff --git a/jscomp/build_tests/weird_names_not_found_bug/input.js b/jscomp/build_tests/weird_names_not_found_bug/input.js index 1442695959..3bb70620c5 100644 --- a/jscomp/build_tests/weird_names_not_found_bug/input.js +++ b/jscomp/build_tests/weird_names_not_found_bug/input.js @@ -1,6 +1,6 @@ var cp = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = cp.spawnSync(rescript_exe, { encoding: "utf8" }); if (out.stderr !== "") { diff --git a/jscomp/build_tests/x-y/input.js b/jscomp/build_tests/x-y/input.js index bb3fa844ff..1b2ea568cb 100644 --- a/jscomp/build_tests/x-y/input.js +++ b/jscomp/build_tests/x-y/input.js @@ -1,4 +1,4 @@ var p = require("child_process"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); p.execSync(rescript_exe); diff --git a/jscomp/build_tests/xpkg/input.js b/jscomp/build_tests/xpkg/input.js index 208a76a40b..d499746478 100644 --- a/jscomp/build_tests/xpkg/input.js +++ b/jscomp/build_tests/xpkg/input.js @@ -1,6 +1,6 @@ var p = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); try { var output = p.spawnSync(`${rescript_exe} build -regen`, { shell: true, diff --git a/jscomp/build_tests/zerocycle/input.js b/jscomp/build_tests/zerocycle/input.js index cf8c0a2932..aa23bdbc08 100644 --- a/jscomp/build_tests/zerocycle/input.js +++ b/jscomp/build_tests/zerocycle/input.js @@ -1,5 +1,5 @@ var p = require("child_process"); var assert = require("assert"); -var rescript_exe = require("../../../scripts/bin_path").rescript_exe; +var { rescript_exe } = require("#cli/bin_path"); var out = p.spawnSync(rescript_exe, { encoding: "utf8", cwd: __dirname }); assert(out.status == 0); diff --git a/jscomp/others/release.ninja b/jscomp/others/release.ninja index 462cfaaeee..19a9be3321 100644 --- a/jscomp/others/release.ninja +++ b/jscomp/others/release.ninja @@ -7,7 +7,7 @@ rule cc description = $in -> $out rule cc_cmi command = $bsc -bs-read-cmi -bs-cmi -bs-cmj $bsc_flags -I others $in - description = $in -> $out + description = $in -> $out o others/belt.cmj others/belt.cmi : cc others/belt.res | $bsc bsc_flags = $bsc_primitive_flags diff --git a/jscomp/runtime/release.ninja b/jscomp/runtime/release.ninja index d9214de2c3..0945248a60 100644 --- a/jscomp/runtime/release.ninja +++ b/jscomp/runtime/release.ninja @@ -7,7 +7,7 @@ rule cc description = $in -> $out rule cc_cmi command = $bsc -bs-read-cmi -bs-cmi -bs-cmj $bsc_flags -I runtime $in - description = $in -> $out + description = $in -> $out o runtime/bs_stdlib_mini.cmi : cc runtime/bs_stdlib_mini.resi bsc_flags = -nopervasives diff --git a/jscomp/stdlib-406/release.ninja b/jscomp/stdlib-406/release.ninja index ccd377821a..abd094ed14 100644 --- a/jscomp/stdlib-406/release.ninja +++ b/jscomp/stdlib-406/release.ninja @@ -6,7 +6,7 @@ rule cc description = $in -> $out rule cc_cmi command = $bsc -bs-read-cmi -bs-cmi -bs-cmj $bsc_flags -I stdlib-406 $in - description = $in -> $out + description = $in -> $out o stdlib-406/pervasives.cmj : cc_cmi stdlib-406/pervasives.res | stdlib-406/pervasives.cmi $bsc others bsc_flags = $bsc_flags -nopervasives diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index 9512b16976..58d243c417 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -6,7 +6,7 @@ rule cc description = $in -> $out rule cc_cmi command = $bsc -bs-read-cmi -bs-cmi -bs-cmj $bsc_flags -I test $in - description = $in -> $out + description = $in -> $out diff --git a/scripts/jsconfig.json b/jsconfig.json similarity index 80% rename from scripts/jsconfig.json rename to jsconfig.json index 805e9a64d7..5ac7dffc06 100644 --- a/scripts/jsconfig.json +++ b/jsconfig.json @@ -6,7 +6,9 @@ "target": "es2018", // target need be set up // otherwise some method is missing - "module": "commonjs" + "module": "nodenext", // setup to understand commonjs module + + "moduleResolution": "nodenext" } } diff --git a/package.json b/package.json index 5dc40c55b5..6470774fd5 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,10 @@ "rewatch": "scripts/rewatch" }, "scripts": { + "postinstall": "node cli/rescript_postinstall.js", "test": "node scripts/ciTest.js -all", "test-bsb": "node scripts/ciTest.js -bsb", "test-ocaml": "node scripts/ciTest.js -ounit", - "postinstall": "node scripts/rescript_postinstall.js", "format": "prettier --write .", "checkFormat": "prettier --check .", "coverage": "nyc --timeout=3000 --reporter=html mocha jscomp/test/*test.js && open ./coverage/index.html" @@ -38,8 +38,14 @@ "win32", "docs/docson/build-schema.json", "lib", - "scripts" + "cli" ], + "exports": { + "./package.json": "./package.json" + }, + "imports": { + "#cli/bin_path": "./cli/bin_path.js" + }, "repository": { "type": "git", "url": "git+https://github.com/rescript-lang/rescript-compiler.git" diff --git a/packages/artifacts.txt b/packages/artifacts.txt index 7552d667f9..2bfabdebdd 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -5,6 +5,14 @@ CREDITS.md LICENSE README.md bsc +cli/bin_path.js +cli/rescript_arg.js +cli/rescript_bsb.js +cli/rescript_convert.js +cli/rescript_dump.js +cli/rescript_format.js +cli/rescript_postinstall.js +cli/rewatch darwin/bsb_helper.exe darwin/bsc.exe darwin/ninja.exe @@ -1067,14 +1075,6 @@ linuxarm64/rewatch.exe ninja.COPYING package.json rescript -scripts/bin_path.js -scripts/rescript_arg.js -scripts/rescript_bsb.js -scripts/rescript_convert.js -scripts/rescript_dump.js -scripts/rescript_format.js -scripts/rescript_postinstall.js -scripts/rewatch win32/bsb_helper.exe win32/bsc.exe win32/ninja.exe diff --git a/rescript b/rescript index 20c3557ff5..bfd4c93a58 100755 --- a/rescript +++ b/rescript @@ -8,9 +8,8 @@ * and its content are file/directories with regard to project root */ -var bsc_exe = require("./scripts/bin_path").bsc_exe; -var rescript_exe = require("./scripts/bin_path").rescript_exe; -var bsb = require("./scripts/rescript_bsb"); +var { bsc_exe, rescript_exe } = require("./cli/bin_path.js"); +var bsb = require("./cli/rescript_bsb.js"); var cwd = process.cwd(); process.env.BSB_PROJECT_ROOT = cwd; @@ -100,7 +99,7 @@ if (helpArgIndex !== -1 && (firstPositionalArgIndex === -1 || helpArgIndex <= fi break; } case "format": { - require("./scripts/rescript_format.js").main( + require("./cli/rescript_format.js").main( subcmdArgs, rescript_exe, bsc_exe @@ -108,7 +107,7 @@ if (helpArgIndex !== -1 && (firstPositionalArgIndex === -1 || helpArgIndex <= fi break; } case "dump": { - require("./scripts/rescript_dump.js").main( + require("./cli/rescript_dump.js").main( subcmdArgs, rescript_exe, bsc_exe @@ -116,7 +115,7 @@ if (helpArgIndex !== -1 && (firstPositionalArgIndex === -1 || helpArgIndex <= fi break; } case "convert": { - require("./scripts/rescript_convert.js").main( + require("./cli/rescript_convert.js").main( subcmdArgs, rescript_exe, bsc_exe diff --git a/scripts/.npmignore b/scripts/.npmignore deleted file mode 100644 index a0ff4a6690..0000000000 --- a/scripts/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -# Ignore all scripts used in dev time only, -# keep only those actually needed in the npm package. -* -!bin_path.js -!rescript_*.js -!rewatch \ No newline at end of file diff --git a/scripts/copyExes.js b/scripts/copyExes.js index 26268749b1..a6f24e530b 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -5,7 +5,7 @@ const path = require("path"); const fs = require("fs"); const child_process = require("child_process"); const { duneBinDir } = require("./dune"); -const { absolutePath: platformBinDir } = require("./bin_path"); +const { absolutePath: platformBinDir } = require("#cli/bin_path"); const ninjaDir = path.join(__dirname, "..", "ninja"); const rewatchDir = path.join(__dirname, "..", "rewatch"); diff --git a/scripts/ninja.js b/scripts/ninja.js index 1dda2c3a17..b2dc6bf1bd 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -35,10 +35,11 @@ var js_package = pseudoTarget("js_pkg"); var runtimeTarget = pseudoTarget("runtime"); var othersTarget = pseudoTarget("others"); var stdlibTarget = pseudoTarget("$stdlib"); -var my_target = require("./bin_path").absolutePath; -var bsc_exe = require("./bin_path").bsc_exe; - -var vendorNinjaPath = require("./bin_path").ninja_exe; +var { + absolutePath: my_target, + bsc_exe, + ninja_exe: vendorNinjaPath, +} = require("#cli/bin_path"); // Let's enforce a Node version >= 16 to make sure M1 users don't trip up on // cryptic issues caused by mismatching assembly architectures Node 16 ships @@ -126,7 +127,7 @@ rule cc description = $in -> $out rule cc_cmi command = $bsc -bs-read-cmi -bs-cmi -bs-cmj $bsc_flags -I ${ninjaCwd} $in - description = $in -> $out + description = $in -> $out `; } /** @@ -1298,10 +1299,10 @@ o all: phony runtime others $stdlib test writeFileAscii( path.join(jscompDir, "..", "lib", "build.ninja"), ` -ocamlopt = ocamlopt.opt +ocamlopt = ocamlopt.opt ext = exe INCL= "4.06.1+BS" -include body.ninja +include body.ninja ` ); @@ -1359,7 +1360,7 @@ ${cppoList("others", [ rule copy command = cp $in $out - description = $in -> $out + description = $in -> $out `; var cppoNinjaFile = "cppoVendor.ninja"; writeFileSync(path.join(jscompDir, cppoNinjaFile), cppoNative); @@ -1431,7 +1432,7 @@ function main() { break; case "help": console.log(`supported subcommands: -[exe] config +[exe] config [exe] build [exe] cleanbuild [exe] help