Skip to content

Conversation

@nojaf
Copy link
Member

@nojaf nojaf commented Jan 19, 2026

Problem

The js-post-build command's working directory was unpredictable in monorepo setups. The command would run in whatever directory the build process was invoked from, which could vary depending on whether you're building a specific package or the entire monorepo from the root.

This made it difficult to write reliable post-build scripts that depend on relative paths or need to access files relative to the package.

Solution

The js-post-build command now always runs in the directory containing the rescript.json where it is defined. This provides predictable, consistent behavior:

  • If a package defines js-post-build in its own rescript.json, the command runs in that package's directory
  • If defined in the root rescript.json, it runs in the root directory

The absolute path to the compiled JS file is still passed as an argument, so scripts can reference the output file unambiguously.

Example

monorepo/
├── rescript.json          # root config
└── packages/
    └── my-app/
        ├── rescript.json  # defines js-post-build: { "cmd": "./scripts/process.sh" }
        └── scripts/
            └── process.sh

Previously, ./scripts/process.sh would fail if the build was run from monorepo/. Now it reliably resolves relative to packages/my-app/.

Breaking Change

This is a breaking change for users who relied on the previous behavior where the working directory matched the build invocation directory. However, the new behavior is more predictable and aligns with how other per-package configuration options work.

@nojaf nojaf requested a review from cknitt January 19, 2026 08:28
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 19, 2026

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@8195

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@8195

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@8195

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@8195

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@8195

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@8195

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@8195

commit: 1eb1c9d

@nojaf nojaf merged commit 893ab5d into rescript-lang:master Jan 19, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants