diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8a0d4f3e0..a4beafce16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,14 +27,19 @@ jobs: include: - os: macos-13 # x64 rust-target: x86_64-apple-darwin + node-target: darwin-x64 - os: macos-14 # ARM rust-target: aarch64-apple-darwin + node-target: darwin-arm64 - os: ubuntu-24.04 # x64 rust-target: x86_64-unknown-linux-musl + node-target: linux-x64 - os: ubuntu-24.04-arm # ARM rust-target: aarch64-unknown-linux-musl + node-target: linux-arm64 - os: windows-latest rust-target: x86_64-pc-windows-gnu + node-target: win32-x64 runs-on: ${{matrix.os}} @@ -66,25 +71,24 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: stable - targets: ${{matrix.rust-target}} + targets: ${{ matrix.rust-target }} - name: Build rewatch if: steps.build-cache.outputs.cache-hit != 'true' - run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release - - - name: Copy rewatch exe to platform bin dir run: | - cp rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch - node ./scripts/copyExes.js -rewatch + cargo build --manifest-path rewatch/Cargo.toml --target ${{ matrix.rust-target }} --release - - name: Get artifact dir name - run: node .github/workflows/get_artifact_dir_name.js + - name: Copy rewatch binary + run: | + cp rewatch/target/${{ matrix.rust-target }}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch.exe + shell: bash - name: "Upload artifact: rewatch binary" uses: actions/upload-artifact@v4 with: - name: rewatch-${{env.artifact_dir_name}} - path: ${{ env.artifact_dir_name }} + name: rewatch-${{ matrix.node-target }} + path: rewatch.exe + if-no-files-found: error build-compiler: strategy: @@ -95,21 +99,26 @@ jobs: ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static upload_binaries: true upload_libs: true + node-target: linux-x64 - os: ubuntu-24.04-arm # ARM ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static upload_binaries: true # Build the playground compiler and run the benchmarks on the fastest runner build_playground: true benchmarks: true + node-target: linux-arm64 - os: macos-13 # x64 ocaml_compiler: 5.3.0 upload_binaries: true + node-target: darwin-x64 - os: macos-14 # ARM ocaml_compiler: 5.3.0 upload_binaries: true + node-target: darwin-arm64 - os: windows-latest ocaml_compiler: 5.3.0 upload_binaries: true + node-target: win32-x64 # Verify that the compiler still builds with older OCaml versions - os: ubuntu-24.04 @@ -144,9 +153,6 @@ jobs: cache: yarn node-version-file: .nvmrc - - name: Get artifact dir name - run: node .github/workflows/get_artifact_dir_name.js - - name: Install dependencies (Linux) if: runner.os == 'Linux' uses: awalsh128/cache-apt-pkgs-action@v1.4.3 @@ -303,13 +309,13 @@ jobs: run: yarn install - name: Copy compiler exes to platform bin dir - run: node ./scripts/copyExes.js -compiler + run: node scripts/copyExes.js --compiler - name: Restore ninja build cache id: ninja-build-cache uses: actions/cache@v4 with: - path: ${{ env.artifact_dir_name }}/ninja.exe + path: packages/@rescript/${{ matrix.node-target }}/bin/ninja.exe key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }} - name: Setup Python for ninja build @@ -336,7 +342,7 @@ jobs: - name: Copy ninja exe to platform bin dir if: steps.ninja-build-cache.outputs.cache-hit != 'true' - run: node ./scripts/copyExes.js -ninja + run: node scripts/copyExes.js --ninja - name: "Syntax: Run roundtrip tests" if: ${{ runner.os != 'Windows' }} @@ -423,8 +429,8 @@ jobs: if: matrix.upload_binaries uses: actions/upload-artifact@v4 with: - name: binaries-${{ env.artifact_dir_name }} - path: ${{ env.artifact_dir_name }} + name: binaries-${{ matrix.node-target }} + path: packages/@rescript/${{ matrix.node-target }}/bin - name: "Upload artifacts: lib/ocaml" if: matrix.upload_libs @@ -438,7 +444,7 @@ jobs: - build-compiler - build-rewatch - runs-on: ubuntu-24.04 + runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -447,29 +453,22 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: - cache: yarn node-version-file: .nvmrc - - name: NPM install - run: yarn install - - name: Download artifacts uses: actions/download-artifact@v4 with: pattern: "@(binaries-*|rewatch-*|lib-ocaml)" - - name: Move artifacts - run: ./scripts/moveArtifacts.sh + - name: Move artifacts into packages + run: .github/workflows/moveArtifacts.sh + shell: bash - - name: npm pack (rescript) + check artifact list + - name: Check artifact list run: node ./scripts/npmPack.js - - name: Copy JS files to stdlib package - run: mkdir -p packages/std/lib && cp -R lib/es6 lib/js packages/std/lib - - - name: npm pack (@rescript/std) - run: npm pack - working-directory: packages/std + - name: yarn pack @rescript/* subpackages + run: yarn workspaces foreach -W --no-private --exclude rescript pack - name: Prepare package upload # For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit. @@ -482,6 +481,11 @@ jobs: path: | rescript-${{ env.rescript_version }}.tgz rescript-std-${{ env.rescript_version }}.tgz + rescript-linux-x64-${{ env.rescript_version }}.tgz + rescript-linux-arm64-${{ env.rescript_version }}.tgz + rescript-darwin-x64-${{ env.rescript_version }}.tgz + rescript-darwin-arm64-${{ env.rescript_version }}.tgz + rescript-win32-x64-${{ env.rescript_version }}.tgz outputs: rescript_version: ${{ env.rescript_version }} @@ -491,15 +495,19 @@ jobs: strategy: fail-fast: false matrix: - os: [ - macos-13, # x64 - macos-14, # ARM - ubuntu-24.04, - ubuntu-24.04-arm, - windows-latest, - ] + include: + - os: macos-13 + node-target: darwin-x64 + - os: macos-14 + node-target: darwin-arm64 + - os: ubuntu-24.04 + node-target: linux-x64 + - os: ubuntu-24.04-arm + node-target: linux-arm64 + - os: windows-latest + node-target: win32-x64 - runs-on: ${{matrix.os}} + runs-on: ${{ matrix.os }} steps: - name: Checkout @@ -532,7 +540,8 @@ jobs: - name: Install ReScript package run: | npm i --ignore-scripts --no-audit \ - rescript-${{ needs.package.outputs.rescript_version }}.tgz + rescript-${{ needs.package.outputs.rescript_version }}.tgz \ + rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} @@ -546,7 +555,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') - runs-on: ubuntu-24.04 + runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -568,8 +577,13 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} run: | - npm publish rescript-${{ needs.package.outputs.rescript_version }}.tgz --tag ci - npm publish rescript-std-${{ needs.package.outputs.rescript_version }}.tgz --tag ci + npm publish --tag ci rescript-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-std-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-linux-x64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-linux-arm64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-darwin-x64-${{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-darwin-arm64-{{ needs.package.outputs.rescript_version }}.tgz + npm publish --tag ci rescript-win32-x64-${{ needs.package.outputs.rescript_version }}.tgz - name: Update Website Playground env: diff --git a/.github/workflows/get_artifact_dir_name.js b/.github/workflows/get_artifact_dir_name.js deleted file mode 100644 index 9ad465b6a4..0000000000 --- a/.github/workflows/get_artifact_dir_name.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as fs from "node:fs"; -import * as os from "node:os"; - -import { platformName } from "#cli/bins"; - -// Pass artifactDirName to subsequent GitHub actions -fs.appendFileSync( - process.env.GITHUB_ENV, - `artifact_dir_name=${platformName}${os.EOL}`, -); diff --git a/scripts/moveArtifacts.sh b/.github/workflows/moveArtifacts.sh similarity index 51% rename from scripts/moveArtifacts.sh rename to .github/workflows/moveArtifacts.sh index 54de7aaf76..4d29ca4a3b 100755 --- a/scripts/moveArtifacts.sh +++ b/.github/workflows/moveArtifacts.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + set -e check_statically_linked() { @@ -24,18 +25,19 @@ check_statically_linked() { fi } -chmod +x binaries-*/*.exe rewatch-*/*.exe - -mkdir darwin darwinarm64 linux linuxarm64 win32 - -mv binaries-darwin/* rewatch-darwin/* darwin -mv binaries-darwinarm64/* rewatch-darwinarm64/* darwinarm64 -mv binaries-linux/* rewatch-linux/* linux -mv binaries-linuxarm64/* rewatch-linuxarm64/* linuxarm64 -mv binaries-win32/* rewatch-win32/* win32 - +# rescript mv lib-ocaml lib/ocaml -mv ninja/COPYING ninja.COPYING -check_statically_linked "linux" -check_statically_linked "linuxarm64" +# @rescript/{target} +chmod +x binaries-*/*.exe rewatch-*/*.exe +mv -f binaries-darwin-x64/* rewatch-darwin-x64/* "packages/@rescript/darwin-x64/bin" +mv -f binaries-darwin-arm64/* rewatch-darwin-arm64/* "packages/@rescript/darwin-arm64/bin" +mv -f binaries-linux-x64/* rewatch-linux-x64/* "packages/@rescript/linux-x64/bin" +mv -f binaries-linux-arm64/* rewatch-linux-arm64/* "packages/@rescript/linux-arm64/bin" +mv -f binaries-win32-x64/* rewatch-win32-x64/* "packages/@rescript/win32-x64/bin" +check_statically_linked "packages/@rescript/linux-x64/bin" +check_statically_linked "packages/@rescript/linux-arm64/bin" + +# @rescript/std +mkdir -p packages/std/lib +cp -R lib/es6 lib/js packages/std/lib diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index 95caa889b0..bf4f567b62 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -2,7 +2,7 @@ import * as fs from "node:fs"; import * as os from "node:os"; const packageSpec = JSON.parse( - fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8") + fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8"), ); const { version } = packageSpec; @@ -10,13 +10,35 @@ const { version } = packageSpec; const commitHash = process.argv[2] || process.env.GITHUB_SHA; const commitHashShort = commitHash.substring(0, 7); +// rescript +fs.renameSync("package.tgz", `rescript-${version}-${commitHashShort}.tgz`); + +// @rescript/std +fs.renameSync( + "packages/std/package.tgz", + `rescript-std-${version}-${commitHashShort}.tgz`, +); + +// @rescript/{target} fs.renameSync( - `rescript-${version}.tgz`, - `rescript-${version}-${commitHashShort}.tgz`, + "packages/@rescript/linux-x64/package.tgz", + `rescript-linux-x64-${version}-${commitHashShort}.tgz`, ); fs.renameSync( - `packages/std/rescript-std-${version}.tgz`, - `rescript-std-${version}-${commitHashShort}.tgz`, + "packages/@rescript/linux-arm64/package.tgz", + `rescript-linux-arm64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/darwin-x64/package.tgz", + `rescript-darwin-x64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/darwin-arm64/package.tgz", + `rescript-darwin-arm64-${version}-${commitHashShort}.tgz`, +); +fs.renameSync( + "packages/@rescript/win32-x64/package.tgz", + `rescript-win32-x64-${version}-${commitHashShort}.tgz`, ); // Pass information to subsequent GitHub actions diff --git a/.gitignore b/.gitignore index f672ecca61..ec3c47063c 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,6 @@ _build node_modules *.dump coverage -*.exe .ninja_log .bsdeps @@ -82,6 +81,12 @@ tests/tools_tests/lib tests/analysis_tests*/lib tests/analysis_tests/**/*.bs.js +/linux/*.exe +/linuxarm64/*.exe +/darwin/*.exe +/darwinarm64/*.exe +/win32/*.exe + .yarn/* !.yarn/patches !.yarn/plugins @@ -90,3 +95,7 @@ tests/analysis_tests/**/*.bs.js !.yarn/versions *.tsbuildinfo + +# package tarballs +package.tgz +*.exe diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2c497ce1..00f0ae3295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :rocket: New Feature - Add shift (`<<`, `>>`, `>>>`) operators for `int` and `bigint`. https://github.com/rescript-lang/rescript/pull/7183 +- Significantly reduced the download size by splitting binaries into optional platform-specific dependencies (e.g, `@rescript/linux-x64`). https://github.com/rescript-lang/rescript/pull/7395 #### :bug: Bug fix diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b72a486baa..960f78d4ef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -404,7 +404,21 @@ To reproduce issues, it can be helpful to the team to install a specific version 1. In your repository run: ```console -npm i npm-packages/rescript-*.tgz +npm i /npm-packages/rescript-*.tgz +``` + +If you use Yarn or pnpm, you should override platform package resolutions by [`resolutions`](https://yarnpkg.com/configuration/manifest#resolutions) in Yarn or [`overrides`](https://pnpm.io/settings#overrides) in Pnpm. + +``` +{ + "resolutions": { + "@rescript/linux-x64": "/npm-packages/rescript-linux-x64.tgz", + "@rescript/linux-arm64": "/npm-packages/rescript-linux-arm64.tgz", + "@rescript/darwin-x64": "/npm-packages/rescript-darwin-x64.tgz", + "@rescript/darwin-arm64": "/npm-packages/rescript-darwin-arm64.tgz", + "@rescript/win32-x64": "/npm-packages/rescript-win32-x64.tgz" + } +} ``` 1. Then attempt to rebuild your project as you would normally. diff --git a/Makefile b/Makefile index 33c0293568..3f37c782e0 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ DUNE_BIN_DIR = ./_build/install/default/bin build: ninja rewatch dune build - ./scripts/copyExes.js -compiler + ./scripts/copyExes.js --compiler watch: dune build -w @@ -18,13 +18,13 @@ dce: rewatch: cargo build --manifest-path rewatch/Cargo.toml cp rewatch/target/debug/rewatch rewatch - ./scripts/copyExes.js -rewatch + ./scripts/copyExes.js --rewatch ninja/ninja: ./scripts/buildNinjaBinary.js - ./scripts/copyExes.js -ninja ninja: ninja/ninja + ./scripts/copyExes.js --ninja test: build lib node scripts/test.js -all @@ -56,7 +56,7 @@ lib: ./scripts/prebuilt.js artifacts: lib - ./scripts/npmPack.js -updateArtifactList + ./scripts/npmPack.js --updateArtifactList # Builds the core playground bundle (without the relevant cmijs files for the runtime) playground: diff --git a/biome.json b/biome.json index aef80be170..190824e65b 100644 --- a/biome.json +++ b/biome.json @@ -65,12 +65,13 @@ "lib/es6/**", "lib/js/**", "ninja/**", - "packages/**", "playground/**", "*.bs.js", "*.res.js", "*.res.mjs", "*.gen.ts*", + "*.d.ts", + "*.exe", "package.json" ] } diff --git a/cli/bstracing.js b/cli/bstracing.js index ad45f72c11..7eb661dbce 100755 --- a/cli/bstracing.js +++ b/cli/bstracing.js @@ -3,8 +3,8 @@ // @ts-check import * as fs from "node:fs"; -import * as readline from "node:readline"; import * as path from "node:path"; +import * as readline from "node:readline"; /** * @@ -14,10 +14,10 @@ import * as path from "node:path"; */ function processEntry(file, lineCb, finish) { const input = fs.createReadStream(file); - input.on("error", (error) => { + input.on("error", error => { console.error(error.message); console.error( - "make sure you are running after bsb building and in the top directory" + "make sure you are running after bsb building and in the top directory", ); process.exit(2); }); @@ -156,7 +156,7 @@ function category(target, obj) { } else { getColorName(obj, "cmj"); } - obj.name = target.targets.map((x) => path.parse(x).base).join(","); + obj.name = target.targets.map(x => path.parse(x).base).join(","); return obj; } /** @@ -173,7 +173,7 @@ function readIntervals(file, showAll, outputFile) { let offset = 0; processEntry( file, - (line) => { + line => { const lineTrim = line.trim(); if (lineTrim.startsWith("#")) { return; @@ -195,7 +195,7 @@ function readIntervals(file, showAll, outputFile) { setDefault( targets, cmdHash, - new Interval(Number(start) + offset, Number(end) + offset) + new Interval(Number(start) + offset, Number(end) + offset), ).targets.push(name); }, () => { @@ -213,12 +213,12 @@ function readIntervals(file, showAll, outputFile) { ts: target.start * 1000, tid: threads.alloc(target), args: {}, - }) + }), ); } console.log(` ${outputFile} is produced, loade it via chrome://tracing/`); fs.writeFileSync(outputFile, JSON.stringify(jsonArray), "utf8"); - } + }, ); } const logName = ".ninja_log"; @@ -240,7 +240,7 @@ function tryLocation(ps) { } } console.error( - "no .ninja_log found in specified paths, make sure you set bstracing to the proper directory" + "no .ninja_log found in specified paths, make sure you set bstracing to the proper directory", ); process.exit(2); } diff --git a/cli/common/bins.js b/cli/common/bins.js index 7472466062..91a699771e 100644 --- a/cli/common/bins.js +++ b/cli/common/bins.js @@ -1,37 +1,28 @@ // @ts-check -import * as path from "node:path"; - /** - * For compatibility reasons, if the architecture is x64, omit it from the bin directory name. - * So we'll have "darwin", "linux" and "win32" for x64 arch, - * but "darwinarm64" and "linuxarm64" for arm64 arch. - * Also, we do not have Windows ARM binaries yet. But the x64 binaries do work on Windows 11 ARM. - * So omit the architecture for Windows, too. + * @typedef {import("@rescript/linux-x64")} BinaryModuleExports */ -export const platformName = - process.arch === "x64" || process.platform === "win32" - ? process.platform - : process.platform + process.arch; - -export const platformDir = path.resolve( - import.meta.dirname, - "..", - "..", - platformName, -); - -export const bsc_exe = path.join(platformDir, "bsc.exe"); - -export const ninja_exe = path.join(platformDir, "ninja.exe"); - -export const rescript_exe = path.join(platformDir, "rescript.exe"); - -export const rescript_tools_exe = path.join(platformDir, "rescript-tools.exe"); - -export const rescript_editor_analysis_exe = path.join( - platformDir, - "rescript-editor-analysis.exe", -); -export const rewatch_exe = path.join(platformDir, "rewatch.exe"); +const target = `${process.platform}-${process.arch}`; + +/** @type {BinaryModuleExports} */ +let mod; +try { + mod = await import(`@rescript/${target}`); +} catch { + throw new Error(`Platform ${target} is not supported!`); +} + +export const { + binDir, + binPaths: { + bsb_helper_exe, + bsc_exe, + ninja_exe, + rescript_editor_analysis_exe, + rescript_tools_exe, + rescript_exe, + rewatch_exe, + }, +} = mod; diff --git a/compiler/bsc/rescript_compiler_main.ml b/compiler/bsc/rescript_compiler_main.ml index 84c0a3f898..a5950f198e 100644 --- a/compiler/bsc/rescript_compiler_main.ml +++ b/compiler/bsc/rescript_compiler_main.ml @@ -185,11 +185,7 @@ let define_variable s = | _ -> Bsc_args.bad_arg ("illegal definition: " ^ s) let print_standard_library () = - let ( // ) = Filename.concat in - let standard_library = - Filename.dirname Sys.executable_name - // Filename.parent_dir_name // "lib" // "ocaml" - in + let standard_library = Config.standard_library in print_string standard_library; print_newline (); exit 0 diff --git a/compiler/ext/config.ml b/compiler/ext/config.ml index 4f75158c25..61edbcfde7 100644 --- a/compiler/ext/config.ml +++ b/compiler/ext/config.ml @@ -1,9 +1,23 @@ let version = "4.06.1+BS" +(* FIXME: Unreliable resolution *) let standard_library = let ( // ) = Filename.concat in - Filename.dirname Sys.executable_name - // Filename.parent_dir_name // "lib" // "ocaml" + let exe_path = Sys.executable_name in + if Ext_string.contain_substring exe_path ("node_modules" // "@rescript") then + (* node_modules/@rescript/{platform}/bin *) + Filename.dirname exe_path // Filename.parent_dir_name + // Filename.parent_dir_name // Filename.parent_dir_name // "rescript" + // "lib" // "ocaml" + else if Ext_string.contain_substring exe_path ("node_modules" // "rescript") + then + (* node_modules/rescript/{platform} *) + Filename.dirname exe_path // Filename.parent_dir_name // "lib" // "ocaml" + else + (* git repo: rescript/packages/@rescript/{platform}/bin *) + Filename.dirname exe_path // Filename.parent_dir_name + // Filename.parent_dir_name // Filename.parent_dir_name + // Filename.parent_dir_name // "lib" // "ocaml" let standard_library_default = standard_library diff --git a/lib/.npmignore b/lib/.npmignore deleted file mode 100644 index e5a0bac212..0000000000 --- a/lib/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*.o -*.log -*.ninja -.ninja_log -bs/.project-files-cache \ No newline at end of file diff --git a/lib_dev/paths.js b/lib_dev/paths.js index 35da5c5593..563b922d64 100644 --- a/lib_dev/paths.js +++ b/lib_dev/paths.js @@ -66,6 +66,15 @@ export const compilerVersionFile = path.resolve( "bs_version.ml", ); +/** + * path: `/packages/artifacts.txt` + */ +export const artifactListFile = path.resolve( + projectDir, + "packages", + "artifacts.txt", +); + /** * path: `/_build/install/default/bin/` */ diff --git a/lib_dev/process.js b/lib_dev/process.js index 444d28019a..c2d506b08b 100644 --- a/lib_dev/process.js +++ b/lib_dev/process.js @@ -1,4 +1,5 @@ import * as child_process from "node:child_process"; +import * as fs from "node:fs/promises"; import * as path from "node:path"; import { bsc_exe, rescript_exe } from "#cli/bins"; @@ -203,8 +204,9 @@ export function setup(cwd = process.cwd()) { * @param {ExecOptions} [options] * @return {Promise} */ - execBin(bin, args = [], options = {}) { - return exec(bin, args, options); + async execBin(bin, args = [], options = {}) { + const realPath = await fs.realpath(bin); + return exec(realPath, args, options); }, }; } diff --git a/package.json b/package.json index 70fc33473e..ba4759e9f3 100644 --- a/package.json +++ b/package.json @@ -56,13 +56,10 @@ }, "files": [ "CHANGELOG.md", + "COPYING", + "COPYING.LESSER", "CREDITS.md", "ninja.COPYING", - "darwin", - "darwinarm64", - "linux", - "linuxarm64", - "win32", "docs/docson/build-schema.json", "lib", "cli" @@ -77,6 +74,13 @@ "#dev/*": "./lib_dev/*.js", "#lib/minisocket": "./lib/minisocket.js" }, + "optionalDependencies": { + "@rescript/darwin-arm64": "workspace:packages/@rescript/darwin-arm64", + "@rescript/darwin-x64": "workspace:packages/@rescript/darwin-x64", + "@rescript/linux-arm64": "workspace:packages/@rescript/linux-arm64", + "@rescript/linux-x64": "workspace:packages/@rescript/linux-x64", + "@rescript/win32-x64": "workspace:packages/@rescript/win32-x64" + }, "devDependencies": { "@biomejs/biome": "1.9.4", "@types/node": "^20.14.9", @@ -88,6 +92,7 @@ }, "workspaces": [ "packages/*", + "packages/@rescript/*", "tests/dependencies/**", "tests/analysis_tests/**", "tests/gentype_tests/**", diff --git a/packages/@rescript/darwin-arm64/bin.d.ts b/packages/@rescript/darwin-arm64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/darwin-arm64/bin.js b/packages/@rescript/darwin-arm64/bin.js new file mode 100644 index 0000000000..0bae072013 --- /dev/null +++ b/packages/@rescript/darwin-arm64/bin.js @@ -0,0 +1,18 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/darwin-arm64/bin/.gitkeep b/packages/@rescript/darwin-arm64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/darwin-arm64/package.json b/packages/@rescript/darwin-arm64/package.json new file mode 100644 index 0000000000..ffb1d924ea --- /dev/null +++ b/packages/@rescript/darwin-arm64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/darwin-arm64", + "version": "12.0.0-alpha.13", + "description": "ReScript binaries for MacOS ARM64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "darwin" + ], + "cpu": [ + "arm64" + ], + "files": [ + "bin.js", + "bin.d.ts", + "bin/" + ], + "exports": "./bin.js", + "preferUnplugged": true +} diff --git a/packages/@rescript/darwin-x64/bin.d.ts b/packages/@rescript/darwin-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/darwin-x64/bin.js b/packages/@rescript/darwin-x64/bin.js new file mode 100644 index 0000000000..0bae072013 --- /dev/null +++ b/packages/@rescript/darwin-x64/bin.js @@ -0,0 +1,18 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/darwin-x64/bin/.gitkeep b/packages/@rescript/darwin-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/darwin-x64/package.json b/packages/@rescript/darwin-x64/package.json new file mode 100644 index 0000000000..a1d75808cd --- /dev/null +++ b/packages/@rescript/darwin-x64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/darwin-x64", + "version": "12.0.0-alpha.13", + "description": "ReScript binaries for MacOS x86_64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "darwin" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin.js", + "bin.d.ts", + "bin/" + ], + "exports": "./bin.js", + "preferUnplugged": true +} diff --git a/packages/@rescript/linux-arm64/bin.d.ts b/packages/@rescript/linux-arm64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/linux-arm64/bin.js b/packages/@rescript/linux-arm64/bin.js new file mode 100644 index 0000000000..0bae072013 --- /dev/null +++ b/packages/@rescript/linux-arm64/bin.js @@ -0,0 +1,18 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/linux-arm64/bin/.gitkeep b/packages/@rescript/linux-arm64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/linux-arm64/package.json b/packages/@rescript/linux-arm64/package.json new file mode 100644 index 0000000000..56015370ae --- /dev/null +++ b/packages/@rescript/linux-arm64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/linux-arm64", + "version": "12.0.0-alpha.13", + "description": "ReScript binaries for Linux ARM64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "linux" + ], + "cpu": [ + "arm64" + ], + "files": [ + "bin.js", + "bin.d.ts", + "bin/" + ], + "exports": "./bin.js", + "preferUnplugged": true +} diff --git a/packages/@rescript/linux-x64/bin.d.ts b/packages/@rescript/linux-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/linux-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/linux-x64/bin.js b/packages/@rescript/linux-x64/bin.js new file mode 100644 index 0000000000..0bae072013 --- /dev/null +++ b/packages/@rescript/linux-x64/bin.js @@ -0,0 +1,18 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/linux-x64/bin/.gitkeep b/packages/@rescript/linux-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/linux-x64/package.json b/packages/@rescript/linux-x64/package.json new file mode 100644 index 0000000000..8b2aa70429 --- /dev/null +++ b/packages/@rescript/linux-x64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/linux-x64", + "version": "12.0.0-alpha.13", + "description": "ReScript binaries for Linux x86_64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin.js", + "bin.d.ts", + "bin/" + ], + "exports": "./bin.js", + "preferUnplugged": true +} diff --git a/packages/@rescript/win32-x64/bin.d.ts b/packages/@rescript/win32-x64/bin.d.ts new file mode 100644 index 0000000000..1a78d275d7 --- /dev/null +++ b/packages/@rescript/win32-x64/bin.d.ts @@ -0,0 +1,13 @@ +export const binDir: string; + +export const binPaths: BinaryPaths; + +export type BinaryPaths = { + bsb_helper_exe: string, + bsc_exe: string, + ninja_exe: string, + rescript_exe: string, + rescript_tools_exe: string, + rescript_editor_analysis_exe: string, + rewatch_exe: string, +}; diff --git a/packages/@rescript/win32-x64/bin.js b/packages/@rescript/win32-x64/bin.js new file mode 100644 index 0000000000..0bae072013 --- /dev/null +++ b/packages/@rescript/win32-x64/bin.js @@ -0,0 +1,18 @@ +// @ts-check + +import * as path from "node:path"; + +export const binDir = path.join(import.meta.dirname, "bin"); + +export const binPaths = { + bsb_helper_exe: path.join(binDir, "bsb_helper.exe"), + bsc_exe: path.join(binDir, "bsc.exe"), + ninja_exe: path.join(binDir, "ninja.exe"), + rescript_exe: path.join(binDir, "rescript.exe"), + rescript_tools_exe: path.join(binDir, "rescript-tools.exe"), + rescript_editor_analysis_exe: path.join( + binDir, + "rescript-editor-analysis.exe", + ), + rewatch_exe: path.join(binDir, "rewatch.exe"), +}; diff --git a/packages/@rescript/win32-x64/bin/.gitkeep b/packages/@rescript/win32-x64/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/@rescript/win32-x64/package.json b/packages/@rescript/win32-x64/package.json new file mode 100644 index 0000000000..1e689ca110 --- /dev/null +++ b/packages/@rescript/win32-x64/package.json @@ -0,0 +1,38 @@ +{ + "name": "@rescript/win32-x64", + "version": "12.0.0-alpha.13", + "description": "ReScript binaries for Windows x86_64", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/rescript-lang/rescript-compiler.git" + }, + "publishConfig": { + "access": "public", + "executableFiles": [ + "./bin/bsb_helper.exe", + "./bin/bsc.exe", + "./bin/ninja.exe", + "./bin/rescript.exe", + "./bin/rescript-editor-analysis.exe", + "./bin/rescript-tools.exe", + "./bin/rewatch.exe" + ] + }, + "engines": { + "node": ">=20.11.0" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ], + "files": [ + "bin.js", + "bin.d.ts", + "bin/" + ], + "exports": "./bin.js", + "preferUnplugged": true +} diff --git a/packages/artifacts.txt b/packages/artifacts.txt index adfa893f3b..0f2acf1aee 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -14,20 +14,6 @@ cli/rescript.js cli/rescript/dump.js cli/rescript/format.js cli/rewatch.js -darwin/bsb_helper.exe -darwin/bsc.exe -darwin/ninja.exe -darwin/rescript-editor-analysis.exe -darwin/rescript-tools.exe -darwin/rescript.exe -darwin/rewatch.exe -darwinarm64/bsb_helper.exe -darwinarm64/bsc.exe -darwinarm64/ninja.exe -darwinarm64/rescript-editor-analysis.exe -darwinarm64/rescript-tools.exe -darwinarm64/rescript.exe -darwinarm64/rewatch.exe docs/docson/build-schema.json lib/es6/Belt.js lib/es6/Belt_Array.js @@ -1227,26 +1213,5 @@ lib/ocaml/Stdlib_WeakSet.cmi lib/ocaml/Stdlib_WeakSet.cmj lib/ocaml/Stdlib_WeakSet.cmt lib/ocaml/Stdlib_WeakSet.res -linux/bsb_helper.exe -linux/bsc.exe -linux/ninja.exe -linux/rescript-editor-analysis.exe -linux/rescript-tools.exe -linux/rescript.exe -linux/rewatch.exe -linuxarm64/bsb_helper.exe -linuxarm64/bsc.exe -linuxarm64/ninja.exe -linuxarm64/rescript-editor-analysis.exe -linuxarm64/rescript-tools.exe -linuxarm64/rescript.exe -linuxarm64/rewatch.exe -ninja.COPYING +ninja/COPYING package.json -win32/bsb_helper.exe -win32/bsc.exe -win32/ninja.exe -win32/rescript-editor-analysis.exe -win32/rescript-tools.exe -win32/rescript.exe -win32/rewatch.exe \ No newline at end of file diff --git a/scripts/copyExes.js b/scripts/copyExes.js index e7c443fd19..3e54761753 100755 --- a/scripts/copyExes.js +++ b/scripts/copyExes.js @@ -7,10 +7,47 @@ import * as child_process from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; -import { platformDir } from "#cli/bins"; +import { parseArgs } from "node:util"; +import { binDir } from "#cli/bins"; import { compilerBinDir, ninjaDir, rewatchDir } from "#dev/paths"; -fs.mkdirSync(platformDir, { recursive: true }); +const args = parseArgs({ + args: process.argv.slice(2), + options: { + all: { + type: "boolean", + }, + compiler: { + type: "boolean", + }, + ninja: { + type: "boolean", + }, + rewatch: { + type: "boolean", + }, + }, +}); + +const shouldCopyCompiler = args.values.all || args.values.compiler; +const shouldCopyNinja = args.values.all || args.values.ninja; +const shouldCopyRewatch = args.values.all || args.values.rewatch; + +if (shouldCopyCompiler) { + copyExe(compilerBinDir, "rescript"); + copyExe(compilerBinDir, "rescript-editor-analysis"); + copyExe(compilerBinDir, "rescript-tools"); + copyExe(compilerBinDir, "bsc"); + copyExe(compilerBinDir, "bsb_helper"); +} + +if (shouldCopyNinja) { + copyExe(ninjaDir, "ninja"); +} + +if (shouldCopyRewatch) { + copyExe(rewatchDir, "rewatch"); +} /** * @param {string} dir @@ -19,7 +56,7 @@ fs.mkdirSync(platformDir, { recursive: true }); function copyExe(dir, exe) { const ext = process.platform === "win32" ? ".exe" : ""; const src = path.join(dir, exe + ext); - const dest = path.join(platformDir, `${exe}.exe`); + const dest = path.join(binDir, `${exe}.exe`); // For some reason, the copy operation fails in Windows CI if the file already exists. if (process.platform === "win32" && fs.existsSync(dest)) { @@ -41,19 +78,3 @@ function copyExe(dir, exe) { fs.chmodSync(dest, mode); } } - -if (process.argv.includes("-all") || process.argv.includes("-compiler")) { - copyExe(compilerBinDir, "rescript"); - copyExe(compilerBinDir, "rescript-editor-analysis"); - copyExe(compilerBinDir, "rescript-tools"); - copyExe(compilerBinDir, "bsc"); - copyExe(compilerBinDir, "bsb_helper"); -} - -if (process.argv.includes("-all") || process.argv.includes("-ninja")) { - copyExe(ninjaDir, "ninja"); -} - -if (process.argv.includes("-all") || process.argv.includes("-rewatch")) { - copyExe(rewatchDir, "rewatch"); -} diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 5d620bdddc..c542bb131a 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -2,89 +2,75 @@ // @ts-check -// NOTE: -// We cannot use `yarn pack` since we need to set our OCaml binaries executable. -// Yarn (Berry) only allow `bin` to be executable, wouldn't preserve permission bits. - -// This performs `npm pack` and retrieves the list of artifact files from the output. +// This performs `yarn pack` and retrieves the list of artifact files from the output. // -// In local dev, invoke it with `-updateArtifactList` to perform a dry run of `npm pack` +// In local dev, invoke it with `--updateArtifactList` to perform a dry run of `yarn pack` // and recreate `packages/artifacts.txt`. -// The exes for all platforms will then be included in the list, even if not present locally. // -// In CI, the scripts is invoked without options. It then performs `npm pack` for real, +// In CI, the scripts is invoked without options. It then performs `yarn pack` for real, // recreates the artifact list and verifies that it has no changes compared to the committed state. +import { execSync, spawn } from "node:child_process"; +import * as fs from "node:fs/promises"; +import * as readline from "node:readline/promises"; +import { parseArgs } from "node:util"; +import { artifactListFile } from "#dev/paths"; + /** - * @typedef {{ - * path: string, - * size: number, - * mode: number, - * }} PackOutputFile - * - * @typedef {{ - * files: PackOutputFile[], - * entryCount: number, - * bundled: unknown[], - * }} PackOutputEntry - * - * @typedef {[PackOutputEntry]} PackOutput + * @typedef {( + * | { "base": string } + * | { "location": string } + * | { "output": string } + * )} YarnPackOutputLine */ -import { execSync, spawnSync } from "node:child_process"; -import fs from "node:fs"; -import path from "node:path"; -import { projectDir } from "#dev/paths"; - -const mode = process.argv.includes("-updateArtifactList") - ? "updateArtifactList" - : "package"; - -const fileListPath = path.join(projectDir, "packages", "artifacts.txt"); - -const output = spawnSync( - `npm pack --json${mode === "updateArtifactList" ? " --dry-run" : ""}`, - { - cwd: projectDir, - encoding: "utf8", - shell: true, +const { values } = parseArgs({ + args: process.argv.slice(2), + options: { + updateArtifactList: { + type: "boolean", + short: "u", + }, }, -).stdout; - -/** @type {PackOutput} */ -const parsedOutput = JSON.parse(output); -let filePaths = parsedOutput[0].files.map(file => file.path); - -if (mode === "updateArtifactList") { - filePaths = Array.from(new Set(filePaths.concat(getFilesAddedByCI()))); +}); + +const mode = values.updateArtifactList ? "updateArtifactList" : "package"; + +const child = spawn( + "yarn", + [ + "workspace", + "rescript", + "pack", + "--json", + mode === "updateArtifactList" ? "--dry-run" : "", + ].filter(Boolean), +); +const exitCode = new Promise((resolve, reject) => { + child.once("error", reject); + child.once("close", code => resolve(code)); +}); + +await fs.unlink(artifactListFile); + +for await (const line of readline.createInterface({ + input: child.stdout.setEncoding("utf8"), + crlfDelay: Number.POSITIVE_INFINITY, +})) { + /** @type {YarnPackOutputLine} */ + const json = JSON.parse(line); + if ("location" in json) { + // Workaround for false positive reports + // See https://github.com/yarnpkg/berry/issues/6766 + if (json.location.startsWith("_build")) { + continue; + } + await fs.appendFile(artifactListFile, json.location + "\n", "utf8"); + } } -filePaths.sort(); -fs.writeFileSync(fileListPath, filePaths.join("\n")); +await exitCode; if (mode === "package") { - execSync(`git diff --exit-code ${fileListPath}`, { stdio: "inherit" }); -} - -function getFilesAddedByCI() { - const platforms = ["darwin", "darwinarm64", "linux", "linuxarm64", "win32"]; - const exes = [ - "bsb_helper.exe", - "bsc.exe", - "ninja.exe", - "rescript.exe", - "rescript-editor-analysis.exe", - "rescript-tools.exe", - "rewatch.exe", - ]; - - const files = ["ninja.COPYING"]; - - for (const platform of platforms) { - for (const exe of exes) { - files.push(`${platform}/${exe}`); - } - } - - return files; + execSync(`git diff --exit-code ${artifactListFile}`, { stdio: "inherit" }); } diff --git a/scripts/setVersion.js b/scripts/setVersion.js old mode 100644 new mode 100755 index 794807d626..e983657cdf --- a/scripts/setVersion.js +++ b/scripts/setVersion.js @@ -2,6 +2,8 @@ // @ts-check +// TODO: Use Yarn's constraints instead. + import fs from "node:fs"; const packageSpec = JSON.parse( @@ -9,14 +11,22 @@ const packageSpec = JSON.parse( ); const { name, version } = packageSpec; -const stdlibPackageSpec = JSON.parse( - fs.readFileSync("./packages/std/package.json", "utf8"), -); -stdlibPackageSpec.version = version; -fs.writeFileSync( - "./packages/std/package.json", - JSON.stringify(stdlibPackageSpec, null, 2), -); +/** + * @param {string} specPath + * @param {string} version + */ +function setVersion(specPath, version) { + const spec = JSON.parse(fs.readFileSync(specPath, "utf8")); + spec.version = version; + fs.writeFileSync(specPath, JSON.stringify(spec, null, 2) + "\n", "utf8"); +} + +setVersion("./packages/std/package.json", version); +setVersion("./packages/@rescript/linux-x64/package.json", version); +setVersion("./packages/@rescript/linux-arm64/package.json", version); +setVersion("./packages/@rescript/darwin-x64/package.json", version); +setVersion("./packages/@rescript/darwin-arm64/package.json", version); +setVersion("./packages/@rescript/win32-x64/package.json", version); fs.writeFileSync( "./compiler/common/bs_version.ml", diff --git a/tests/gentype_tests/typescript-react-example/Makefile b/tests/gentype_tests/typescript-react-example/Makefile index 5062da0431..a38ce95510 100644 --- a/tests/gentype_tests/typescript-react-example/Makefile +++ b/tests/gentype_tests/typescript-react-example/Makefile @@ -1,9 +1,9 @@ SHELL = /bin/bash test: - npm run check - npm run build - npm run typecheck + yarn check + yarn build + yarn typecheck @git diff --quiet src/ \ || { echo; echo "Please review the Gentype outputs too!"; echo; false; } \ || exit 1 diff --git a/tools/CHANGELOG.md b/tools/CHANGELOG.md deleted file mode 100644 index 401adf5f6a..0000000000 --- a/tools/CHANGELOG.md +++ /dev/null @@ -1,86 +0,0 @@ -# Changelog - -> **Tags:** -> -> - :boom: [Breaking Change] -> - :eyeglasses: [Spec Compliance] -> - :rocket: [New Feature] -> - :bug: [Bug Fix] -> - :memo: [Documentation] -> - :house: [Internal] -> - :nail_care: [Polish] - -## master - -## 0.6.4 - -#### :rocket: New Feature - -- Add `moduletypeid` field for explicitly annotated module type. https://github.com/rescript-lang/rescript-vscode/pull/1019 - -### :bug: Bug Fix - -- Print module structure with signature to module path. https://github.com/rescript-lang/rescript-vscode/pull/1018 - -## 0.6.3 - -#### :bug: Bug Fix - -- Make sure Linux binaries are statically linked. - -#### :nail_care: Polish - -- Reverse order of extracted embeds, so they're in the correct order. - -## 0.6.2 - -#### :rocket: New Feature - -- Ship Linux ARM64 binaries. - -## 0.6.1 - -#### :rocket: New Feature - -- Expose `getBinaryPath` JS function that you can import to get the binary to call for the current platform. - -## 0.6.0 - -#### :rocket: New Feature - -- _internal_ Add experimental command for extracting (string) contents from extension points. - -## 0.5.0 - -#### :rocket: New Feature - -- Add `source` property to type, value, module and module alias. https://github.com/rescript-lang/rescript-vscode/pull/900. - -#### :bug: Bug Fix - -- Print docstrings for nested submodules. https://github.com/rescript-lang/rescript-vscode/pull/897 -- Print `deprecated` field for module. https://github.com/rescript-lang/rescript-vscode/pull/897 - -## 0.4.0 - -#### :bug: Bug Fix - -- Support inline record fields in constructors. https://github.com/rescript-lang/rescript-vscode/pull/889 -- Fix docstrings for module alias. Get internal docstrings of module file. https://github.com/rescript-lang/rescript-vscode/pull/878 -- Fix extracted docs of types include escaped linebreaks in signature. https://github.com/rescript-lang/rescript-vscode/pull/891 - -## 0.3.0 - -#### :rocket: New Feature - -- Expose more `decode` functions. https://github.com/rescript-lang/rescript-vscode/pull/866 - -#### :house: [Internal] - -- Add env var `FROM_COMPILER` to extract docstrings from compiler repo. https://github.com/rescript-lang/rescript-vscode/pull/868 - -#### :bug: Bug Fix - -- Fix tagged variant for `Module` and add attr to interface files. https://github.com/rescript-lang/rescript-vscode/pull/866 -- Fix `rescript-tools --version` command. https://github.com/rescript-lang/rescript-vscode/pull/873 -- Fix output truncate when run `rescript-tools doc path/to/file.res` in a separate process. https://github.com/rescript-lang/rescript-vscode/pull/868 diff --git a/tsconfig.json b/tsconfig.json index 3778657f66..a085cc4138 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "lib/*", "lib_dev/*", "scripts/*", + "packages/**", "tests/**/input.js", ".github/workflows/*.js", "package.json" diff --git a/yarn.lock b/yarn.lock index 5cbbbe4462..de112f2ba7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -388,6 +388,30 @@ __metadata: languageName: node linkType: hard +"@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64": + version: 0.0.0-use.local + resolution: "@rescript/darwin-arm64@workspace:packages/@rescript/darwin-arm64" + languageName: unknown + linkType: soft + +"@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64": + version: 0.0.0-use.local + resolution: "@rescript/darwin-x64@workspace:packages/@rescript/darwin-x64" + languageName: unknown + linkType: soft + +"@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64": + version: 0.0.0-use.local + resolution: "@rescript/linux-arm64@workspace:packages/@rescript/linux-arm64" + languageName: unknown + linkType: soft + +"@rescript/linux-x64@workspace:packages/@rescript/linux-x64": + version: 0.0.0-use.local + resolution: "@rescript/linux-x64@workspace:packages/@rescript/linux-x64" + languageName: unknown + linkType: soft + "@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode": version: 0.0.0-use.local resolution: "@rescript/react@link:../../../dependencies/rescript-react::locator=%40tests%2Freanalyze-deadcode%40workspace%3Atests%2Fanalysis_tests%2Ftests-reanalyze%2Fdeadcode" @@ -428,6 +452,12 @@ __metadata: languageName: unknown linkType: soft +"@rescript/win32-x64@workspace:packages/@rescript/win32-x64": + version: 0.0.0-use.local + resolution: "@rescript/win32-x64@workspace:packages/@rescript/win32-x64" + languageName: unknown + linkType: soft + "@rollup/plugin-node-resolve@npm:^16.0.0": version: 16.0.1 resolution: "@rollup/plugin-node-resolve@npm:16.0.1" @@ -2445,12 +2475,28 @@ __metadata: resolution: "rescript@workspace:." dependencies: "@biomejs/biome": "npm:1.9.4" + "@rescript/darwin-arm64": "workspace:packages/@rescript/darwin-arm64" + "@rescript/darwin-x64": "workspace:packages/@rescript/darwin-x64" + "@rescript/linux-arm64": "workspace:packages/@rescript/linux-arm64" + "@rescript/linux-x64": "workspace:packages/@rescript/linux-x64" + "@rescript/win32-x64": "workspace:packages/@rescript/win32-x64" "@types/node": "npm:^20.14.9" "@types/semver": "npm:^7.5.8" mocha: "npm:10.8.2" nyc: "npm:15.0.0" semver: "npm:7.6.2" typescript: "npm:5.8.2" + dependenciesMeta: + "@rescript/darwin-arm64": + optional: true + "@rescript/darwin-x64": + optional: true + "@rescript/linux-arm64": + optional: true + "@rescript/linux-x64": + optional: true + "@rescript/win32-x64": + optional: true bin: bsc: cli/bsc.js bstracing: cli/bstracing.js