diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81657ff016..f8a0d4f3e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -406,21 +406,18 @@ jobs: - name: Build playground compiler if: matrix.build_playground - run: | - opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js - opam exec -- dune build --profile browser - cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.cjs + run: opam exec -- make playground playground-cmijs - name: Test playground compiler if: matrix.build_playground - run: node playground/playground_test.cjs + run: yarn workspace playground test - name: Upload playground compiler to CDN if: ${{ matrix.build_playground && startsWith(github.ref, 'refs/tags/v') }} env: KEYCDN_USER: ${{ secrets.KEYCDN_USER }} KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }} - run: bash playground/upload_bundle.sh + run: yarn workspace playground upload-bundle - name: "Upload artifacts: binaries" if: matrix.upload_binaries @@ -513,23 +510,36 @@ jobs: with: node-version-file: .nvmrc + - name: Make test directory + id: tmp-dir + shell: bash + run: | + if [[ "$RUNNER_OS" == "Windows" ]]; then + dir=$(powershell -Command "[System.IO.Path]::GetTempPath() + [System.Guid]::NewGuid().ToString()" | tr -d '\r') + mkdir -p "$dir" + else + dir=$(mktemp -d) + fi + echo "path=$dir" >> "$GITHUB_OUTPUT" + cp -r tests/package_tests/installation_test/* "$dir" + - name: Download artifacts uses: actions/download-artifact@v4 with: name: npm-packages - path: packages/test + path: ${{ steps.tmp-dir.outputs.path }} - name: Install ReScript package run: | npm i --ignore-scripts --no-audit \ rescript-${{ needs.package.outputs.rescript_version }}.tgz shell: bash - working-directory: packages/test + working-directory: ${{ steps.tmp-dir.outputs.path }} - name: Test installation - run: npx rescript -h && npx rescript build && cat src/Test.bs.js + run: npx rescript -h && npx rescript build && cat src/Test.res.js shell: bash - working-directory: packages/test + working-directory: ${{ steps.tmp-dir.outputs.path }} publish: needs: [package, installationTest] @@ -564,5 +574,5 @@ jobs: - name: Update Website Playground env: NEXT_REVALIDATE_SECRET_TOKEN: ${{ secrets.NEXT_REVALIDATE_SECRET_TOKEN }} - run: ./playground/website_update_playground.sh + run: yarn workspace playground revalidate shell: bash diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0e7b135867..b72a486baa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -241,29 +241,28 @@ make playground make playground-cmijs ``` -Note that building the cmijs is based on the dependencies defined in `packages/playground-bundling/package.json`. In case you want to build some different version of e.g. `@rescript/react` or just want to add a new package, change the definition within the `package.json` file and run `make playground-cmijs` again. +Note that building the cmijs is based on the dependencies defined in `packages/playground/package.json`. In case you want to build some different version of e.g. `@rescript/react` or just want to add a new package, change the definition within the `package.json` file and run `yarn workspace playground build` again. After a successful compilation, you will find following files in your project: - `playground/compiler.js` -> This is the ReScript compiler, which binds the ReScript API to the `window` object. -- `playground/packages` -> Contains third party deps with cmij.js files (as defined in `packages/playground-bundling/bsconfig.json`) -- `playground/compilerCmij.js` -> The compiler base cmij containing all the relevant core modules (`Js`, `Belt`, `Pervasives`, etc.) +- `playground/packages/compiler-builtins` -> The compiler base cmij containing all the relevant core modules (`Js`, `Belt`, `Pervasives`, etc.) +- `playground/packages/*` -> Contains third party deps with cmij.js files (as defined in `packages/playground/rescript.json`) You can now use the `compiler.js` file either directly by using a `` and `` inside a html file, use a browser bundler infrastructure to optimize it, or use `nodejs` to run it on a command line: ``` $ node -> require("./compiler.js"); -> require("./packages/compilerCmij.js") -> let compiler = rescript_compiler.make() -> let result = compiler.rescript.compile(`Js.log(Sys.ocaml_version)`); +> let { rescript_compiler } = require("./compiler.js"); +> require("./packages/compiler-builtins/cmij.js") +> let { rescript } = rescript_compiler.make() +> let result = rescript.compile(`Console.log(${rescript.version})`); > eval(result.js_code); -4.06.2+BS ``` ### Testing the Playground bundle -Run `node playground/playground_test.cjs` for a quick sanity check to see if all the build artifacts are working together correctly. When releasing the playground bundle, the test will always be executed before publishing to catch regressions. +Run `yarn workspace playground test` for a quick sanity check to see if all the build artifacts are working together correctly. When releasing the playground bundle, the test will always be executed before publishing to catch regressions. ### Working on the Playground JS API @@ -271,9 +270,10 @@ Whenever you are modifying any files in the ReScript compiler, or in the `jsoo_p ``` make playground +yarn workspace playground build # optionally run your test / arbitrary node script to verify your changes -node playground/playground_test.cjs +yarn workspace playground test ``` ### Publishing the Playground Bundle on our KeyCDN diff --git a/Makefile b/Makefile index 6978e4097a..ab648339ea 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ test-all: test test-gentype test-analysis test-tools reanalyze: reanalyze.exe -set-exit-code -all-cmt _build/default/compiler _build/default/tests -exclude-paths compiler/outcome_printer,compiler/ml,compiler/frontend,compiler/ext,compiler/depends,compiler/core,compiler/common,compiler/cmij,compiler/bsb_helper,compiler/bsb -lib: build +lib: ./scripts/buildRuntime.sh ./scripts/prebuilt.js @@ -61,17 +61,17 @@ artifacts: lib # Builds the core playground bundle (without the relevant cmijs files for the runtime) playground: dune build --profile browser - cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js playground/compiler.cjs + cp ./_build/default/compiler/jsoo/jsoo_playground_main.bc.js packages/playground/compiler.js # Creates all the relevant core and third party cmij files to side-load together with the playground bundle playground-cmijs: artifacts - node packages/playground-bundling/scripts/generate_cmijs.js + yarn workspace playground build # Builds the playground, runs some e2e tests and releases the playground to the # CDN (requires KEYCDN_USER and KEYCDN_PASSWORD set in the env variables) playground-release: playground playground-cmijs - node playground/playground_test.cjs - sh playground/upload_bundle.sh + yarn workspace playground test + yarn workspace playground upload-bundle format: bash scripts/format.sh diff --git a/package.json b/package.json index e7d73e8de4..be5d0c6d6c 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "typescript": "5.8.2" }, "workspaces": [ + "packages/*", "tests/dependencies/**", "tests/analysis_tests/**", "tests/gentype_tests/**", diff --git a/packages/playground-bundling/package.json b/packages/playground-bundling/package.json deleted file mode 100644 index 2f7b0ca1ce..0000000000 --- a/packages/playground-bundling/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "proj", - "version": "1.0.0", - "description": "", - "type": "module", - "main": "index.js", - "scripts": { - "build": "rescript clean && rescript build && node ./scripts/generate_cmijs.js", - "bundle": "rollup -c", - "clean": "rescript clean" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@rescript/react": "^0.13.0" - }, - "devDependencies": { - "@rollup/plugin-node-resolve": "^16.0.0", - "glob": "^11.0.1", - "rollup": "^4.32.0" - } -} diff --git a/packages/playground-bundling/.gitignore b/packages/playground/.gitignore similarity index 88% rename from packages/playground-bundling/.gitignore rename to packages/playground/.gitignore index 9a1eb666ce..f20e8d25e1 100644 --- a/packages/playground-bundling/.gitignore +++ b/packages/playground/.gitignore @@ -25,8 +25,10 @@ lib/bs .merlin .bsb.lock /node_modules/ -lib/ -packages/ +/lib/ .DS_Store package-lock.json yarn.lock + +/packages/ +/compiler.js diff --git a/packages/playground-bundling/README.md b/packages/playground/README.md similarity index 57% rename from packages/playground-bundling/README.md rename to packages/playground/README.md index 96f8c633a2..bd8a8d706f 100644 --- a/packages/playground-bundling/README.md +++ b/packages/playground/README.md @@ -1,31 +1,17 @@ -# rescript-compiler-js +# ReScript Playground bundle -This repo is useful to generate a bunch of cmij.js files for a list of dependencies ready to be used in the ReScript playground. +This repo is useful to generate a bunch of `cmij.js` files for a list of dependencies ready to be used in the ReScript playground. ## Setup -Check the `bsconfig.json` and `package.json` files for the respective versions used for the compiler & packages. - -It's useful to `npm link` the compiler locally to prevent mismatching compiler versions and therefore "stale artifact" warnings. - -``` -# Go to the root of the rescript-compiler project -cd ../.. - -npm link - -# Link the local build in this project as well -cd packages/playground-bundling -npm link rescript -``` +Check the `rescript.json` and `package.json` files for the respective versions used for the compiler & packages. ## Building -Run the following commands: +Run the following command: ``` -npm run build -node scripts/generate_cmijs.js +yarn workspace playground build ``` All the cmij files will now be available in the `packages/` directory with a structure like this: @@ -55,12 +41,13 @@ packages Let's assume our `compiler.js` file represents our playground bundle, you'd first load the compiler, and then load any cmij file: ``` -require("playground/compiler.js") -require("packages/@rescript/react/cmij.js") +const { rescript_compiler } = require("./compiler.js"); -let comp = rescript_compiler.make() -comp.rescript.compile("let a =
") +require("./packages/compiler-builtins/cmij.js"); +require("./packages/@rescript/react/cmij.js"); + +let comp = rescript_compiler.make(); +comp.rescript.compile("let a = "); ``` The script above will be able to successfully compile this React code, since all the `React` module functionality required by JSX was injected in the compiler's state. - diff --git a/packages/playground/package.json b/packages/playground/package.json new file mode 100644 index 0000000000..0e43a5a4d3 --- /dev/null +++ b/packages/playground/package.json @@ -0,0 +1,21 @@ +{ + "private": true, + "name": "playground", + "type": "commonjs", + "scripts": { + "clean": "rescript clean", + "test": "node ./playground_test.cjs", + "build": "rescript clean && rescript build && node ./scripts/generate_cmijs.mjs && rollup -c", + "upload-bundle": "./scripts/upload_bundle.sh", + "revalidate": "./scripts/website_update_playground.sh" + }, + "dependencies": { + "@rescript/react": "^0.13.1", + "rescript": "workspace:^" + }, + "devDependencies": { + "@rollup/plugin-node-resolve": "^16.0.0", + "glob": "^11.0.1", + "rollup": "^4.32.0" + } +} diff --git a/playground/playground_test.cjs b/packages/playground/playground_test.cjs similarity index 90% rename from playground/playground_test.cjs rename to packages/playground/playground_test.cjs index 3e7a40e022..43b25ee4e3 100644 --- a/playground/playground_test.cjs +++ b/packages/playground/playground_test.cjs @@ -1,9 +1,9 @@ // Playground bundle is UMD module // It uses `module.exports` in current context, or fallback to `globalThis` -const { rescript_compiler } = require("./compiler.cjs"); +const { rescript_compiler } = require("./compiler.js"); -require("./packages/compiler-builtins/cmij.cjs"); -require("./packages/@rescript/react/cmij.cjs"); +require("./packages/compiler-builtins/cmij.js"); +require("./packages/@rescript/react/cmij.js"); const compiler = rescript_compiler.make(); diff --git a/packages/playground-bundling/rescript.json b/packages/playground/rescript.json similarity index 62% rename from packages/playground-bundling/rescript.json rename to packages/playground/rescript.json index 5f53495101..2b3566fd74 100644 --- a/packages/playground-bundling/rescript.json +++ b/packages/playground/rescript.json @@ -1,14 +1,16 @@ { "name": "playground", "version": "0.1.0", - "bs-dependencies": ["@rescript/react"], - "package-specs": { - "module": "esmodule", - "in-source": false - }, "sources": { "dir": "src", "subdirs": true }, - "uncurried": true + "package-specs": { + "module": "esmodule", + "in-source": false, + "suffix": ".res.js" + }, + "bs-dependencies": [ + "@rescript/react" + ] } diff --git a/packages/playground-bundling/rollup.config.mjs b/packages/playground/rollup.config.mjs similarity index 81% rename from packages/playground-bundling/rollup.config.mjs rename to packages/playground/rollup.config.mjs index 21f6260b44..322c1054f9 100644 --- a/packages/playground-bundling/rollup.config.mjs +++ b/packages/playground/rollup.config.mjs @@ -4,9 +4,9 @@ import { glob } from "glob"; const RESCRIPT_COMPILER_ROOT_DIR = path.join(import.meta.dirname, "..", ".."); const LIB_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "lib"); -const PLAYGROUND_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "playground"); + // Final target output directory where all the cmijs will be stored -const PACKAGES_DIR = path.join(PLAYGROUND_DIR, "packages"); +const PACKAGES_DIR = path.join(import.meta.dirname, "packages"); const outputFolder = path.join(PACKAGES_DIR, "compiler-builtins", "stdlib"); const entryPoint = await glob(`${LIB_DIR}/es6/*.js`); diff --git a/packages/playground-bundling/scripts/generate_cmijs.js b/packages/playground/scripts/generate_cmijs.mjs similarity index 70% rename from packages/playground-bundling/scripts/generate_cmijs.js rename to packages/playground/scripts/generate_cmijs.mjs index 7d0df1e877..2fb44d8f05 100644 --- a/packages/playground-bundling/scripts/generate_cmijs.js +++ b/packages/playground/scripts/generate_cmijs.mjs @@ -3,9 +3,7 @@ // @ts-check /* - * Requires the version matching `rescript` binary to be `npm link`ed in this - * project. Or in other words: You need to build cmij files with the same - * rescript version as the compiler bundle. + * You need to build cmij files with the same rescript version as the compiler bundle. * * This script extracts all cmi / cmj files of the rescript/lib/ocaml and all * dependencies listed in the project root's rescript.json, creates cmij.js @@ -27,18 +25,15 @@ const RESCRIPT_COMPILER_ROOT_DIR = path.join( "..", "..", ); -const PLAYGROUND_DIR = path.join(RESCRIPT_COMPILER_ROOT_DIR, "playground"); // The playground-bundling root dir -const PROJECT_ROOT_DIR = path.join(import.meta.dirname, ".."); +const PLAYGROUND_DIR = path.join(import.meta.dirname, ".."); // Final target output directory where all the cmijs will be stored const PACKAGES_DIR = path.join(PLAYGROUND_DIR, "packages"); // Making sure this directory exists, since it's not checked in to git -if (!fs.existsSync(PACKAGES_DIR)) { - fs.mkdirSync(PACKAGES_DIR, { recursive: true }); -} +fs.mkdirSync(PACKAGES_DIR, { recursive: true }); /** * @param {string} cmd @@ -46,17 +41,15 @@ if (!fs.existsSync(PACKAGES_DIR)) { function e(cmd) { console.log(`>>>>>> running command: ${cmd}`); child_process.execSync(cmd, { - cwd: PROJECT_ROOT_DIR, + cwd: PLAYGROUND_DIR, encoding: "utf8", stdio: [0, 1, 2], }); console.log("<<<<<<"); } -e("npm install"); -e(`npm link ${RESCRIPT_COMPILER_ROOT_DIR}`); -e("npx rescript clean"); -e("npx rescript"); +e("yarn rescript clean"); +e("yarn rescript"); const packages = resConfig["bs-dependencies"]; @@ -64,20 +57,15 @@ const packages = resConfig["bs-dependencies"]; // Otherwise we can't use them for compilation within the playground. function buildCompilerCmij() { const rescriptLibOcamlFolder = path.join( - PROJECT_ROOT_DIR, - "node_modules", - "rescript", + RESCRIPT_COMPILER_ROOT_DIR, "lib", "ocaml", ); const outputFolder = path.join(PACKAGES_DIR, "compiler-builtins"); + fs.mkdirSync(outputFolder, { recursive: true }); - const cmijFile = path.join(outputFolder, "cmij.cjs"); - - if (!fs.existsSync(outputFolder)) { - fs.mkdirSync(outputFolder, { recursive: true }); - } + const cmijFile = path.join(outputFolder, "cmij.js"); e( `find ${rescriptLibOcamlFolder} -name "*.cmi" -or -name "*.cmj" | xargs -n1 basename | xargs js_of_ocaml build-fs -o ${cmijFile} -I ${rescriptLibOcamlFolder}`, @@ -87,26 +75,23 @@ function buildCompilerCmij() { function buildThirdPartyCmijs() { for (const pkg of packages) { const libOcamlFolder = path.join( - PROJECT_ROOT_DIR, + RESCRIPT_COMPILER_ROOT_DIR, "node_modules", pkg, "lib", "ocaml", ); const libEs6Folder = path.join( - PROJECT_ROOT_DIR, + RESCRIPT_COMPILER_ROOT_DIR, "node_modules", pkg, "lib", "es6", ); const outputFolder = path.join(PACKAGES_DIR, pkg); + fs.mkdirSync(outputFolder, { recursive: true }); - const cmijFile = path.join(outputFolder, "cmij.cjs"); - - if (!fs.existsSync(outputFolder)) { - fs.mkdirSync(outputFolder, { recursive: true }); - } + const cmijFile = path.join(outputFolder, "cmij.js"); e(`find ${libEs6Folder} -name '*.js' -exec cp {} ${outputFolder} \\;`); e( @@ -115,10 +100,5 @@ function buildThirdPartyCmijs() { } } -function bundleStdlibJs() { - e("npm run bundle"); -} - buildCompilerCmij(); buildThirdPartyCmijs(); -bundleStdlibJs(); diff --git a/playground/upload_bundle.sh b/packages/playground/scripts/upload_bundle.sh similarity index 78% rename from playground/upload_bundle.sh rename to packages/playground/scripts/upload_bundle.sh index 33635d2ed6..28c61ab55e 100755 --- a/playground/upload_bundle.sh +++ b/packages/playground/scripts/upload_bundle.sh @@ -1,13 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash # This script will publish the compiler.js bundle / packages cmij.js files to our KeyCDN server. # The target folder on KeyCDN will be the compiler.js' version number. # This script requires `curl` / `openssl` to be installed. -SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P) +SCRIPT_PATH="${BASH_SOURCE[0]}" +PLAYGROUND_DIR="$(dirname "$(dirname "$SCRIPT_PATH")")" # Get the actual version from the compiled playground bundle -VERSION=$(cd $SCRIPT_DIR; node -e 'require("./compiler.js"); console.log(rescript_compiler.make().rescript.version)') +VERSION="$(node -e "console.log(require('$PLAYGROUND_DIR/compiler.js').rescript_compiler.make().rescript.version)")" if [ -z "${KEYCDN_USER}" ]; then echo "KEYCDN_USER environment variable not set. Make sure to set the environment accordingly." @@ -20,7 +21,7 @@ if [ -z "${KEYCDN_PASSWORD}" ]; then fi KEYCDN_SRV="ftp.keycdn.com" -NETRC_FILE="${SCRIPT_DIR}/.netrc" +NETRC_FILE="${PLAYGROUND_DIR}/.netrc" # To make sure to not leak any secrets in the bash history, we create a NETRC_FILE # with the credentials provided via ENV variables. @@ -32,13 +33,13 @@ fi PACKAGES=("compiler-builtins" "@rescript/react") echo "Uploading compiler.js file..." -curl --ftp-create-dirs -T "${SCRIPT_DIR}/compiler.js" --ssl --tls-max 1.2 --netrc-file $NETRC_FILE ftp://${KEYCDN_SRV}/v${VERSION}/compiler.js +curl --ftp-create-dirs -T "${PLAYGROUND_DIR}/compiler.js" --ssl --tls-max 1.2 --netrc-file $NETRC_FILE ftp://${KEYCDN_SRV}/v${VERSION}/compiler.js echo "---" echo "Uploading packages cmij files..." for dir in ${PACKAGES[@]}; do - SOURCE="${SCRIPT_DIR}/packages/${dir}" + SOURCE="${PLAYGROUND_DIR}/packages/${dir}" TARGET="ftp://${KEYCDN_SRV}/v${VERSION}/${dir}" echo "Uploading '$SOURCE/cmij.js' to '$TARGET/cmij.js'..." @@ -49,7 +50,7 @@ done # we now upload the bundled stdlib runtime files DIR="compiler-builtins/stdlib" -SOURCE="${SCRIPT_DIR}/packages/${DIR}" +SOURCE="${PLAYGROUND_DIR}/packages/${DIR}" TARGET="ftp://${KEYCDN_SRV}/v${VERSION}/${DIR}" echo "Uploading '$SOURCE/*.js' to '$TARGET/*.js'..." diff --git a/playground/website_update_playground.sh b/packages/playground/scripts/website_update_playground.sh similarity index 95% rename from playground/website_update_playground.sh rename to packages/playground/scripts/website_update_playground.sh index aca64d06c4..c781a75d80 100755 --- a/playground/website_update_playground.sh +++ b/packages/playground/scripts/website_update_playground.sh @@ -1,4 +1,4 @@ -#/usr/bin/sh +#!/usr/bin/env bash if [ -z "${NEXT_REVALIDATE_SECRET_TOKEN}" ]; then echo "NEXT_REVALIDATE_SECRET_TOKEN environment variable not set." diff --git a/packages/playground-bundling/src/App.res b/packages/playground/src/App.res similarity index 100% rename from packages/playground-bundling/src/App.res rename to packages/playground/src/App.res diff --git a/packages/playground-bundling/tsconfig.json b/packages/playground/tsconfig.json similarity index 100% rename from packages/playground-bundling/tsconfig.json rename to packages/playground/tsconfig.json diff --git a/packages/test/.gitignore b/packages/test/.gitignore deleted file mode 100644 index 23d31d5825..0000000000 --- a/packages/test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -package-lock.json -yarn.lock diff --git a/packages/test/package.json b/packages/test/package.json deleted file mode 100644 index 31130847f5..0000000000 --- a/packages/test/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "rescript-test", - "version": "0.0.0" -} diff --git a/packages/test/rescript.json b/packages/test/rescript.json deleted file mode 100644 index 5923440e94..0000000000 --- a/packages/test/rescript.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "rescript-test", - "sources": [ - { - "dir": "src", - "subdirs": true - } - ], - "package-specs": [ - { - "module": "esmodule", - "in-source": true - } - ], - "suffix": ".bs.js" -} diff --git a/packages/test/test_freebsd.sh b/packages/test/test_freebsd.sh deleted file mode 100755 index b84fe63a5c..0000000000 --- a/packages/test/test_freebsd.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Node 16 doesn't work, see https://forums.freebsd.org/threads/nodejs-and-libcrypto-so-wrong-version-after-upgrade.82471/ -sudo pkg install -y npm-node14 python gcc - -npm i rescript*.tgz - -npx rescript -h -npx rescript build -cat src/Test.bs.js - -# Cleanup -rm -rf node_modules diff --git a/scripts/moveArtifacts.sh b/scripts/moveArtifacts.sh index 23bd1a083d..54de7aaf76 100755 --- a/scripts/moveArtifacts.sh +++ b/scripts/moveArtifacts.sh @@ -39,4 +39,3 @@ mv ninja/COPYING ninja.COPYING check_statically_linked "linux" check_statically_linked "linuxarm64" - diff --git a/scripts/npmPack.js b/scripts/npmPack.js index 967803c827..5d620bdddc 100755 --- a/scripts/npmPack.js +++ b/scripts/npmPack.js @@ -2,7 +2,9 @@ // @ts-check -// TODO: Use `yarn pack --json` instead. +// 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. // diff --git a/tests/package_tests/installation_test/rescript.json b/tests/package_tests/installation_test/rescript.json new file mode 100644 index 0000000000..fd6dfe79cd --- /dev/null +++ b/tests/package_tests/installation_test/rescript.json @@ -0,0 +1,12 @@ +{ + "name": "install-test", + "sources": { + "dir": "src", + "subdirs": true + }, + "package-specs": { + "module": "esmodule", + "in-source": true, + "suffix": ".res.js" + } +} diff --git a/packages/test/src/Test.res b/tests/package_tests/installation_test/src/Test.res similarity index 100% rename from packages/test/src/Test.res rename to tests/package_tests/installation_test/src/Test.res diff --git a/yarn.lock b/yarn.lock index 521187df7b..2cf7fb385a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -422,6 +422,186 @@ __metadata: languageName: unknown linkType: soft +"@rescript/std@workspace:packages/std": + version: 0.0.0-use.local + resolution: "@rescript/std@workspace:packages/std" + 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" + dependencies: + "@rollup/pluginutils": "npm:^5.0.1" + "@types/resolve": "npm:1.20.2" + deepmerge: "npm:^4.2.2" + is-module: "npm:^1.0.0" + resolve: "npm:^1.22.1" + peerDependencies: + rollup: ^2.78.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + checksum: 10c0/54d33282321492fafec29b49c66dd1efd90c72a24f9d1569dcb57a72ab8de8a782810f39fdb917b96ec6a598c18f3416588b419bf7af331793a010de1fe28c60 + languageName: node + linkType: hard + +"@rollup/pluginutils@npm:^5.0.1": + version: 5.1.4 + resolution: "@rollup/pluginutils@npm:5.1.4" + dependencies: + "@types/estree": "npm:^1.0.0" + estree-walker: "npm:^2.0.2" + picomatch: "npm:^4.0.2" + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + checksum: 10c0/6d58fbc6f1024eb4b087bc9bf59a1d655a8056a60c0b4021d3beaeec3f0743503f52467fd89d2cf0e7eccf2831feb40a05ad541a17637ea21ba10b21c2004deb + languageName: node + linkType: hard + +"@rollup/rollup-android-arm-eabi@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.39.0" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@rollup/rollup-android-arm64@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-android-arm64@npm:4.39.0" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-arm64@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.39.0" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-darwin-x64@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.39.0" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@rollup/rollup-freebsd-arm64@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-freebsd-arm64@npm:4.39.0" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-freebsd-x64@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-freebsd-x64@npm:4.39.0" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-gnueabihf@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.39.0" + conditions: os=linux & cpu=arm & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm-musleabihf@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.39.0" + conditions: os=linux & cpu=arm & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.39.0" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-arm64-musl@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.39.0" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-loongarch64-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.39.0" + conditions: os=linux & cpu=loong64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.39.0" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-riscv64-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.39.0" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-riscv64-musl@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-riscv64-musl@npm:4.39.0" + conditions: os=linux & cpu=riscv64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-linux-s390x-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.39.0" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-gnu@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.39.0" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@rollup/rollup-linux-x64-musl@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.39.0" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@rollup/rollup-win32-arm64-msvc@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.39.0" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@rollup/rollup-win32-ia32-msvc@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.39.0" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@rollup/rollup-win32-x64-msvc@npm:4.39.0": + version: 4.39.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.39.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@tests/analysis@workspace:tests/analysis_tests/tests": version: 0.0.0-use.local resolution: "@tests/analysis@workspace:tests/analysis_tests/tests" @@ -488,6 +668,13 @@ __metadata: languageName: unknown linkType: soft +"@types/estree@npm:1.0.7, @types/estree@npm:^1.0.0": + version: 1.0.7 + resolution: "@types/estree@npm:1.0.7" + checksum: 10c0/be815254316882f7c40847336cd484c3bc1c3e34f710d197160d455dc9d6d050ffbf4c3bc76585dba86f737f020ab20bdb137ebe0e9116b0c86c7c0342221b8c + languageName: node + linkType: hard + "@types/node@npm:^20.14.9": version: 20.17.27 resolution: "@types/node@npm:20.17.27" @@ -523,6 +710,13 @@ __metadata: languageName: node linkType: hard +"@types/resolve@npm:1.20.2": + version: 1.20.2 + resolution: "@types/resolve@npm:1.20.2" + checksum: 10c0/c5b7e1770feb5ccfb6802f6ad82a7b0d50874c99331e0c9b259e415e55a38d7a86ad0901c57665d93f75938be2a6a0bc9aa06c9749192cadb2e4512800bbc6e6 + languageName: node + linkType: hard + "@types/semver@npm:^7.5.8": version: 7.5.8 resolution: "@types/semver@npm:7.5.8" @@ -902,6 +1096,13 @@ __metadata: languageName: node linkType: hard +"deepmerge@npm:^4.2.2": + version: 4.3.1 + resolution: "deepmerge@npm:4.3.1" + checksum: 10c0/e53481aaf1aa2c4082b5342be6b6d8ad9dfe387bc92ce197a66dea08bd4265904a087e75e464f14d1347cf2ac8afe1e4c16b266e0561cc5df29382d3c5f80044 + languageName: node + linkType: hard + "default-require-extensions@npm:^3.0.0": version: 3.0.1 resolution: "default-require-extensions@npm:3.0.1" @@ -1000,6 +1201,13 @@ __metadata: languageName: node linkType: hard +"estree-walker@npm:^2.0.2": + version: 2.0.2 + resolution: "estree-walker@npm:2.0.2" + checksum: 10c0/53a6c54e2019b8c914dc395890153ffdc2322781acf4bd7d1a32d7aedc1710807bdcd866ac133903d5629ec601fbb50abe8c2e5553c7f5a0afdd9b6af6c945af + languageName: node + linkType: hard + "exponential-backoff@npm:^3.1.1": version: 3.1.2 resolution: "exponential-backoff@npm:3.1.2" @@ -1118,6 +1326,13 @@ __metadata: languageName: node linkType: hard +"function-bind@npm:^1.1.2": + version: 1.1.2 + resolution: "function-bind@npm:1.1.2" + checksum: 10c0/d8680ee1e5fcd4c197e4ac33b2b4dce03c71f4d91717292785703db200f5c21f977c568d28061226f9b5900cbcd2c84463646134fd5337e7925e0942bc3f46d5 + languageName: node + linkType: hard + "gensync@npm:^1.0.0-beta.2": version: 1.0.0-beta.2 resolution: "gensync@npm:1.0.0-beta.2" @@ -1164,6 +1379,22 @@ __metadata: languageName: node linkType: hard +"glob@npm:^11.0.1": + version: 11.0.1 + resolution: "glob@npm:11.0.1" + dependencies: + foreground-child: "npm:^3.1.0" + jackspeak: "npm:^4.0.1" + minimatch: "npm:^10.0.0" + minipass: "npm:^7.1.2" + package-json-from-dist: "npm:^1.0.0" + path-scurry: "npm:^2.0.0" + bin: + glob: dist/esm/bin.mjs + checksum: 10c0/2b32588be52e9e90f914c7d8dec32f3144b81b84054b0f70e9adfebf37cd7014570489f2a79d21f7801b9a4bd4cca94f426966bfd00fb64a5b705cfe10da3a03 + languageName: node + linkType: hard + "glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.1.6": version: 7.2.3 resolution: "glob@npm:7.2.3" @@ -1222,6 +1453,15 @@ __metadata: languageName: node linkType: hard +"hasown@npm:^2.0.2": + version: 2.0.2 + resolution: "hasown@npm:2.0.2" + dependencies: + function-bind: "npm:^1.1.2" + checksum: 10c0/3769d434703b8ac66b209a4cca0737519925bbdb61dd887f93a16372b14694c63ff4e797686d87c90f08168e81082248b9b028bad60d4da9e0d1148766f56eb9 + languageName: node + linkType: hard + "he@npm:^1.2.0": version: 1.2.0 resolution: "he@npm:1.2.0" @@ -1324,6 +1564,15 @@ __metadata: languageName: node linkType: hard +"is-core-module@npm:^2.16.0": + version: 2.16.1 + resolution: "is-core-module@npm:2.16.1" + dependencies: + hasown: "npm:^2.0.2" + checksum: 10c0/898443c14780a577e807618aaae2b6f745c8538eca5c7bc11388a3f2dc6de82b9902bcc7eb74f07be672b11bbe82dd6a6edded44a00cb3d8f933d0459905eedd + languageName: node + linkType: hard + "is-extglob@npm:^2.1.1": version: 2.1.1 resolution: "is-extglob@npm:2.1.1" @@ -1347,6 +1596,13 @@ __metadata: languageName: node linkType: hard +"is-module@npm:^1.0.0": + version: 1.0.0 + resolution: "is-module@npm:1.0.0" + checksum: 10c0/795a3914bcae7c26a1c23a1e5574c42eac13429625045737bf3e324ce865c0601d61aee7a5afbca1bee8cb300c7d9647e7dc98860c9bdbc3b7fdc51d8ac0bffc + languageName: node + linkType: hard + "is-number@npm:^7.0.0": version: 7.0.0 resolution: "is-number@npm:7.0.0" @@ -1490,6 +1746,15 @@ __metadata: languageName: node linkType: hard +"jackspeak@npm:^4.0.1": + version: 4.1.0 + resolution: "jackspeak@npm:4.1.0" + dependencies: + "@isaacs/cliui": "npm:^8.0.2" + checksum: 10c0/08a6a24a366c90b83aef3ad6ec41dcaaa65428ffab8d80bc7172add0fbb8b134a34f415ad288b2a6fbd406526e9a62abdb40ed4f399fbe00cb45c44056d4dce0 + languageName: node + linkType: hard + "js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0": version: 4.0.0 resolution: "js-tokens@npm:4.0.0" @@ -1598,6 +1863,13 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^11.0.0": + version: 11.1.0 + resolution: "lru-cache@npm:11.1.0" + checksum: 10c0/85c312f7113f65fae6a62de7985348649937eb34fb3d212811acbf6704dc322a421788aca253b62838f1f07049a84cc513d88f494e373d3756514ad263670a64 + languageName: node + linkType: hard + "lru-cache@npm:^5.1.1": version: 5.1.1 resolution: "lru-cache@npm:5.1.1" @@ -1644,6 +1916,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^10.0.0": + version: 10.0.1 + resolution: "minimatch@npm:10.0.1" + dependencies: + brace-expansion: "npm:^2.0.1" + checksum: 10c0/e6c29a81fe83e1877ad51348306be2e8aeca18c88fdee7a99df44322314279e15799e41d7cb274e4e8bb0b451a3bc622d6182e157dfa1717d6cda75e9cd8cd5d + languageName: node + linkType: hard + "minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": version: 3.1.2 resolution: "minimatch@npm:3.1.2" @@ -2002,6 +2283,13 @@ __metadata: languageName: node linkType: hard +"path-parse@npm:^1.0.7": + version: 1.0.7 + resolution: "path-parse@npm:1.0.7" + checksum: 10c0/11ce261f9d294cc7a58d6a574b7f1b935842355ec66fba3c3fd79e0f036462eaf07d0aa95bb74ff432f9afef97ce1926c720988c6a7451d8a584930ae7de86e1 + languageName: node + linkType: hard + "path-scurry@npm:^1.11.1": version: 1.11.1 resolution: "path-scurry@npm:1.11.1" @@ -2012,6 +2300,16 @@ __metadata: languageName: node linkType: hard +"path-scurry@npm:^2.0.0": + version: 2.0.0 + resolution: "path-scurry@npm:2.0.0" + dependencies: + lru-cache: "npm:^11.0.0" + minipass: "npm:^7.1.2" + checksum: 10c0/3da4adedaa8e7ef8d6dc4f35a0ff8f05a9b4d8365f2b28047752b62d4c1ad73eec21e37b1579ef2d075920157856a3b52ae8309c480a6f1a8bbe06ff8e52b33c + languageName: node + linkType: hard + "picocolors@npm:^1.0.0, picocolors@npm:^1.1.1": version: 1.1.1 resolution: "picocolors@npm:1.1.1" @@ -2026,6 +2324,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.2": + version: 4.0.2 + resolution: "picomatch@npm:4.0.2" + checksum: 10c0/7c51f3ad2bb42c776f49ebf964c644958158be30d0a510efd5a395e8d49cb5acfed5b82c0c5b365523ce18e6ab85013c9ebe574f60305892ec3fa8eee8304ccc + languageName: node + linkType: hard + "pkg-dir@npm:^4.1.0": version: 4.2.0 resolution: "pkg-dir@npm:4.2.0" @@ -2035,6 +2340,18 @@ __metadata: languageName: node linkType: hard +"playground@workspace:packages/playground": + version: 0.0.0-use.local + resolution: "playground@workspace:packages/playground" + dependencies: + "@rescript/react": "npm:^0.13.1" + "@rollup/plugin-node-resolve": "npm:^16.0.0" + glob: "npm:^11.0.1" + rescript: "workspace:^" + rollup: "npm:^4.32.0" + languageName: unknown + linkType: soft + "proc-log@npm:^5.0.0": version: 5.0.0 resolution: "proc-log@npm:5.0.0" @@ -2150,6 +2467,32 @@ __metadata: languageName: node linkType: hard +"resolve@npm:^1.22.1": + version: 1.22.10 + resolution: "resolve@npm:1.22.10" + dependencies: + is-core-module: "npm:^2.16.0" + path-parse: "npm:^1.0.7" + supports-preserve-symlinks-flag: "npm:^1.0.0" + bin: + resolve: bin/resolve + checksum: 10c0/8967e1f4e2cc40f79b7e080b4582b9a8c5ee36ffb46041dccb20e6461161adf69f843b43067b4a375de926a2cd669157e29a29578191def399dd5ef89a1b5203 + languageName: node + linkType: hard + +"resolve@patch:resolve@npm%3A^1.22.1#optional!builtin