Multi-language support
Turborepo is built on the conventions of the JavaScript ecosystem to find scripts and tasks to execute - but it doesn't care what those scripts do. Following the guidance for specifying a package in a JavaScript workspace, you can add any other language or toolchain to Turborepo.
As an example, you may have a Rust project in the ./cli
directory in your repository. To add this directory as a package to your JavaScript package manager's workspace, add the directory to the workspace definition:
Then, add a package.json
to the directory:
Now, when you use turbo build
, the "build"
script in ./cli/package.json
will be included into the tasks that turbo
runs.
Caching build artifacts
Ensure that the outputs for your builds are being cached with the outputs key in turbo.json
. In the case of a Rust CLI being compiled with cargo, a release build would be created in the target/release
directory and we can cache it using:
Creating dependency relationships
Because the directory is now a part of the package manager's workspace, you can create dependencies exactly the same as you do for your JavaScript packages.
For instance, if you wanted to make sure that the rust-cli
"package" from above is built before your web
application, install it into the dependencies for the web
application:
Given a turbo.json
with a build
task like:
turbo build
will first create the artifacts for the Rust CLI and then build the web
application.
Was this helpful?