Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
const fs = require("node:fs/promises");
const { defineConfig } = require("@yarnpkg/types");

const { compilerVersionFile } = require("#dev/paths");

/**
* @param {Yarn.Constraints.Context} ctx
*/
Expand Down Expand Up @@ -46,23 +44,21 @@ async function enforceCompilerMeta({ Yarn }) {
}
}

const { compilerVersionFile } = await import("#dev/paths");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes

Internal Error: require() of ES Module /Users/christoph/projects/cca/rescript/lib_dev/paths.js from /Users/christoph/projects/cca/rescript/yarn.config.cjs not supported.
Instead change the require of paths.js in /Users/christoph/projects/cca/rescript/yarn.config.cjs to a dynamic import() which is available in all CommonJS modules.
Instead change the require of paths.js in /Users/christoph/projects/cca/rescript/yarn.config.cjs to a dynamic import() which is available in all CommonJS modules.

Cannot be at the top level

const versionFile = await fs.readFile(compilerVersionFile, "utf8");
const versionPattern = /^let version = "(?<version>[^"]+)"$/m;

if (process.argv.includes("--fix")) {
await fs.writeFile(
compilerVersionFile,
versionFile.replace(
versionPattern,
`let version = "${EXPECTED_VERSION}"`,
),
versionFile.replace(versionPattern, `let version = "${EXPECTED_VERSION}"`)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformatted by biome

);
} else {
const versionMatch = versionFile.match(versionPattern);
const foundVersion = versionMatch?.groups?.version;
if (foundVersion !== EXPECTED_VERSION) {
Yarn.workspace().error(
`compiler/common/bs_version.ml file need to be fixed; expected ${EXPECTED_VERSION}, found ${foundVersion}.`,
`compiler/common/bs_version.ml file need to be fixed; expected ${EXPECTED_VERSION}, found ${foundVersion}.`
);
}
}
Expand Down