Turborepo 1.4
Turborepo 1.4 brings:
- Automatic environment variable inclusion: We'll automatically infer popular framework environment variables for you. No need to declare them yourself in
turbo.json
. eslint-config-turbo
: Enhanced feedback with a new ESLint plugin.- New framework and library examples: New starters and examples requested by the community.
Update today by running npm install turbo@latest
.
Automatic environment variable inclusion
To help ensure correct caching across environments Turborepo will now automatically infer and include public environment variables when calculating cache keys for apps built with Astro, Create React App, Gatsby, Next.js, Nuxt, SvelteKit, Vite, Vue, and more. You can safely remove framework-specific public environment variables from turbo.json
if you manually declared them.
Note that this automatic detection and inclusion only works if Turborepo successfully infers the framework your apps are built with. Additionally, the environment variables will only be included in the cache key for tasks in workspaces where that framework is used. In other words, environment variables inferred for Next.js apps, will only be included in the cache key for workspaces detected as Next.js apps. Tasks in other workspaces in the monorepo will not be impacted.
For example, consider a monorepo with three workspaces: a Next.js project, a Create React App project, and a TypeScript package. Each has a build
script, and both apps depend on the TypeScript project. Let's say that this Turborepo has a standard turbo.json
pipeline that builds them all in order:
As of 1.4, when you run turbo run build
, Turborepo will not consider any build time environment variables relevant when building the TypeScript package. However, when building the Next.js app, Turborepo will infer that environment variables starting with NEXT_PUBLIC_
could alter the output of the .next
folder and should thus be included when calculating the hash. Similarly, when calculating the hash of the Create React App's build
script, all build time environment variables starting with REACT_APP_PUBLIC_
will be included.
This improvement in hash specificity by framework is a significant step toward optimal, safe, and correct caching.
eslint-config-turbo
We've also created a new ESLint config for further in-editor assistance to help ensure your Turborepo cache can be correctly shared across every environment. While our new hashing algorithm should cover most situations with most frameworks, this ESLint config will provide in-editor feedback for teams using other build time inlined environment variables that are not framework-prefixed but impact build outputs (i.e. caching), and teams using their own in-house frameworks that we cannot detect automatically.
To get started, extend from eslint-config-turbo
in your root eslintrc
file:
If you prefer more control over the rules - use can install and configure the eslint-plugin-turbo
plugin directly by first adding it to plugins and then configuring the desired rules:
The plugin will warn you if you are using non-framework-related environment variables in your code that have not been declared in your turbo.json
.
As of 1.4.x, we now include eslint-config-turbo
in all of our examples and in new projects generated via npx create-turbo
.
Learn more about ESLint configs and plugins in the ESLint docs.
New framework and library examples
Based on your feedback and suggestions, we've created new examples to integrate Turborepo into your workflow:
Other bug fixes and improvements
- Allow both sides of git comparison (#1442)
- Properly rebuild packages that share a name prefix (#1538)
- Cache files with the correct file permissions (#1429)
Community
Since releasing Turborepo v1.3 in June, we've seen incredible adoption and community growth:
- 8.65k+ GitHub Stars
- 365k weekly NPM downloads, up 2x since late April
- 10 years of compute time saved through Remote Caching on Vercel, saving 10 months per week
Turborepo is the result of the combined work of all of our contributors including our core team.
This release was brought to you by the contributions of: @B2o5T, @chitchu, @elis, @gsoltis, @harshcut, @jaredpalmer, @kocisov, @nathanhammond, @neolivz, @NuroDev, @oneezy, @samouri, @shayc, @StevenMatchett, @tknickman, @trevorr, @zsoldosp, and more!
Thank you for your continued support, feedback, and collaboration to make Turborepo your build tool of choice.