From e5d349d259b75fc1ba72b9397bbf44152802a6e7 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 5 Apr 2025 13:33:34 +0200 Subject: [PATCH 1/2] Do not use experimental JSON import feature --- .github/workflows/prepare_package_upload.js | 4 +++- cli/rescript.js | 8 ++++++-- scripts/prebuilt.js | 7 +++++-- scripts/setVersion.js | 4 +++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/prepare_package_upload.js b/.github/workflows/prepare_package_upload.js index 680b58b7ae..95caa889b0 100644 --- a/.github/workflows/prepare_package_upload.js +++ b/.github/workflows/prepare_package_upload.js @@ -1,7 +1,9 @@ import * as fs from "node:fs"; import * as os from "node:os"; -import packageSpec from "rescript/package.json" with { type: "json" }; +const packageSpec = JSON.parse( + fs.readFileSync(new URL("../../package.json", import.meta.url), "utf-8") +); const { version } = packageSpec; diff --git a/cli/rescript.js b/cli/rescript.js index 83bcfef05d..98d8900ab2 100755 --- a/cli/rescript.js +++ b/cli/rescript.js @@ -7,7 +7,7 @@ // and its content are file/directories with regard to project root import * as tty from "node:tty"; -import packageJson from "rescript/package.json" with { type: "json" }; +import * as fs from "node:fs"; import { bsc_exe, rescript_exe } from "./common/bins.js"; import * as bsb from "./common/bsb.js"; @@ -93,7 +93,11 @@ if ( ) { console.log(helpMessage); } else if (argPatterns.version.includes(args[0])) { - console.log(packageJson.version); + const packageSpec = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8") + ); + + console.log(packageSpec.version); } else if (firstPositionalArgIndex !== -1) { const subcmd = args[firstPositionalArgIndex]; const subcmdArgs = args.slice(firstPositionalArgIndex + 1); diff --git a/scripts/prebuilt.js b/scripts/prebuilt.js index 6f3f2c43fd..c9bcd9482f 100755 --- a/scripts/prebuilt.js +++ b/scripts/prebuilt.js @@ -4,7 +4,6 @@ import assert from "node:assert"; import fs from "node:fs"; -import packageJson from "rescript/package.json" with { type: "json" }; import semver from "semver"; import { compilerVersionFile } from "#dev/paths"; @@ -29,7 +28,11 @@ assert.ok(bsVersionMatch, "Failed to parse the compiler version file"); const bsVersion = semver.parse(bsVersionMatch.version); assert.ok(bsVersion, "Failed to parse the compiler version file"); -const packageVersion = semver.parse(packageJson.version); +const packageSpec = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"), +); + +const packageVersion = semver.parse(packageSpec.version); assert.ok(packageVersion, "Failed to parse the version of the package.json"); assert.ok( diff --git a/scripts/setVersion.js b/scripts/setVersion.js index 24d39f7ccd..794807d626 100644 --- a/scripts/setVersion.js +++ b/scripts/setVersion.js @@ -3,8 +3,10 @@ // @ts-check import fs from "node:fs"; -import packageSpec from "rescript/package.json" with { type: "json" }; +const packageSpec = JSON.parse( + fs.readFileSync(new URL("../package.json", import.meta.url), "utf-8"), +); const { name, version } = packageSpec; const stdlibPackageSpec = JSON.parse( From 8dad54be09bd42f21092b455eb0f092eec39cc39 Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sat, 5 Apr 2025 16:05:45 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41383dfe4d..7bc9af029f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,13 @@ # 12.0.0-alpha.12 (Unreleased) +#### :bug: Bug fix + +- Fix node.js ExperimentalWarning. https://github.com/rescript-lang/rescript/pull/7379 + #### :house: Internal -- Better representation of JSX in AST . https://github.com/rescript-lang/rescript/pull/7286 + +- Better representation of JSX in AST. https://github.com/rescript-lang/rescript/pull/7286 # 12.0.0-alpha.11