diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d6c95c92b..4a1241e7db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ #### :nail_care: Polish - Configuration fields `bs-dependencies`, `bs-dev-dependencies` and `bsc-flags` are now deprecated in favor of `dependencies`, `dev-dependencies` and `compiler-flags`. https://github.com/rescript-lang/rescript/pull/7658 +- Better error message if platform binaries package is not found. https://github.com/rescript-lang/rescript/pull/7698 #### :house: Internal diff --git a/cli/common/bins.js b/cli/common/bins.js index 1844607281..77f3e2be48 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -6,11 +6,28 @@ const target = `${process.platform}-${process.arch}`; +const supportedPlatforms = [ + "darwin-arm64", + "darwin-x64", + "linux-arm64", + "linux-x64", + "win32-x64", +]; + /** @type {BinaryModuleExports} */ let mod; -try { - mod = await import(`@rescript/${target}`); -} catch { + +if (supportedPlatforms.includes(target)) { + const binPackageName = `@rescript/${target}`; + + try { + mod = await import(binPackageName); + } catch { + throw new Error( + `Package ${binPackageName} not found. Make sure the rescript package is installed correctly.`, + ); + } +} else { throw new Error(`Platform ${target} is not supported!`); }