这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@anthonyshew
Copy link
Contributor

@anthonyshew anthonyshew commented Mar 5, 2025

Description

Microsyntax for file globbing from the workspace root. Our file globs are anchored to packages, but there are use cases where anchoring at the root is more preferable.

Adds $TURBO_ROOT$ which can be used in task inputs and outputs. It can only be used at the start of an inclusion/exclusion so ../$TURBO_ROOT$/config.txt isn't valid usage.

We achieve this by swapping out $TURBO_ROOT$ as we convert a raw task definition to a usable one. This allows us to not handle this at any later steps since all inputs/outpus are expected to be relative to the package directory.

Testing Instructions

Added unit tests for:

  • Replacing of $TURBO_ROOT$ with the relative path to the repo root
  • Calculation of the relative path to repo root for packages
[0 olszewski@macbookpro] /tmp/watch-time $ bat turbo.json 
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: turbo.json
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "$schema": "https://turbo.build/schema.json",
   3   │   "ui": "tui",
   4   │   "tasks": {
   5   │     "build": {
   6   │       "dependsOn": ["^build"],
   7 ~ │       "inputs": ["$TURBO_DEFAULT$", ".env*", "$TURBO_ROOT$/my-configs/*"],
   8   │       "outputs": [".next/**", "!.next/cache/**"]
   9   │     },
  10   │     "lint": {
  11   │       "dependsOn": ["^lint"]
  12   │     },
  13   │     "check-types": {
  14   │       "dependsOn": ["^check-types"]
  15   │     },
  16   │     "dev": {
  17   │       "cache": false,
  18   │       "persistent": true
  19   │     }
  20   │   }
  21   │ }

[0 olszewski@macbookpro] /tmp/watch-time $ turbo_dev --skip-infer build --output-logs=hash-only                     
turbo 2.4.5-canary.2

• Packages in scope: @repo/eslint-config, @repo/typescript-config, @repo/ui, docs, web
• Running build in 5 packages
• Remote caching disabled
 web#build > cache hit, suppressing logs cf5b7818b9c2c383 
 docs#build > cache hit, suppressing logs 9306af3d3750177a 

 Tasks:    2 successful, 2 total
Cached:    2 cached, 2 total
  Time:    110ms >>> FULL TURBO

[0 olszewski@macbookpro] /tmp/watch-time $ echo 'a change' > my-configs/config.txt 
[0 olszewski@macbookpro] /tmp/watch-time $ turbo_dev --skip-infer build --output-logs=hash-only
turbo 2.4.5-canary.2

• Packages in scope: @repo/eslint-config, @repo/typescript-config, @repo/ui, docs, web
• Running build in 5 packages
• Remote caching disabled
 web#build > cache miss, executing 0acfce06b3b2069d 
 docs#build > cache miss, executing cfb4227df7dfd1fc 

 Tasks:    2 successful, 2 total
Cached:    0 cached, 2 total
  Time:    7.97s 

[0 olszewski@macbookpro] /tmp/watch-time $ vim turbo.json 
[0 olszewski@macbookpro] /tmp/watch-time $ turbo_dev --skip-infer build --output-logs=hash-only
turbo 2.4.5-canary.2

  × Cannot use '$TURBO_ROOT$' anywhere besides start of string.
   ╭─[turbo.json:7:46]
 6 │       "dependsOn": ["^build"],
 7 │       "inputs": ["$TURBO_DEFAULT$", ".env*", "../$TURBO_ROOT$/my-configs/*"],
   ·                                              ───────────────┬──────────────
   ·                                                             ╰── must be at start
 8 │       "outputs": [".next/**", "!.next/cache/**"]
   ╰────

@turbo-orchestrator turbo-orchestrator bot added the area: docs Improvements or additions to documentation label Mar 5, 2025
@vercel
Copy link
Contributor

vercel bot commented Mar 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 1:48pm

@anthonyshew anthonyshew changed the title feat: Workspace root microsyntax [WIP] feat: Workspace root microsyntax Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants