turbo icon indicating copy to clipboard operation
turbo copied to clipboard

Feature Request: support negated globs in `outputs`

Open felixmosh opened this issue 3 years ago • 3 comments

What version of Turborepo are you using?

1.4.0

What package manager are you using / does the bug impact?

Yarn v2/v3 (node_modules linker only)

What operating system are you using?

Linux

Describe the Bug

With the following turbo.json file,

{
  "globalDependencies": [
    "./env"
  ],
  "pipeline": {
    "build": {
      "dependsOn": [
        "^build"
      ],
      "outputs": [
        ".next/**",
        "!.next/cache/**"
      ]
    },
  }
}

The !.next/cache/** glob doesn't ignores the .next/cache folder, which is redundant in artifact cache & bloats the artifact zip size.

Expected Behavior

It should ignore the specified folder.

To Reproduce

Use the basic Next.js example with Next.js cache enabled with the given turbo.json file

felixmosh avatar Aug 02 '22 07:08 felixmosh

Heya @felixmosh! This is actually something that we've never implemented.

https://github.com/vercel/turborepo/blob/a7de4010a1691a4c9ec0f11fd4adb85669eac3f5/cli/internal/runcache/runcache.go#L272

This is a feature we should definitely add, though.

nathanhammond avatar Aug 02 '22 15:08 nathanhammond

Funny because @jaredpalmer gave me this answer in Discord 😅

felixmosh avatar Aug 02 '22 15:08 felixmosh

@jaredpalmer thinks it probably existed in the JS version and was never ported over. It is definitely on our list now.

nathanhammond avatar Aug 02 '22 17:08 nathanhammond

There is any progress with this one?

felixmosh avatar Aug 25 '22 12:08 felixmosh

Is it solved? I've updated to the latest Turbo, and seems that my cache artifacts are ignoring next's cache folder.

felixmosh avatar Oct 20 '22 13:10 felixmosh

@felixmosh I'm terribly sorry we forgot to get back here and update you! @NicholasLYang got to this in #2031 which showed up as part of v1.5.6.

I think you've already discovered that though. Let me know if you discover anything weird with it!

nathanhammond avatar Oct 21 '22 04:10 nathanhammond

@nathanhammond thank you! This feature helps me a lot 🎊

felixmosh avatar Oct 26 '22 08:10 felixmosh

@nathanhammond @NicholasLYang What do you think about adding this to inputs too? I'm trying to get cache based on all files except package.json because we do version bump after merge which invalidates cache that was created just before merging a feature

filipw01 avatar Oct 27 '22 12:10 filipw01

Unfortunately, we cannot generalize a solution for that. It might work, it might not work. Certain build scripts could pull in the version number and include that in the actual execution of the command.

Presumably you do not version after every single merge, so this is likely not a significant reduction in your cache hit ratio?

nathanhammond avatar Oct 27 '22 12:10 nathanhammond

Presumably you do not version after every single merge, so this is likely not a significant reduction in your cache hit ratio?

Actually we do. Only changed packages, but on every merge to master. I know package.json could affect some outputs, but it's not the case for us

filipw01 avatar Oct 27 '22 13:10 filipw01

So, unfortunately, I'm not aware of a generalizable solution here. We explicitly include package.json ourselves and even if you were to specify !package.json we'd add it back in for you. Excluding it is not viable for the general case.

So, your workflow is not compatible with the Turborepo workflow.

nathanhammond avatar Nov 02 '22 07:11 nathanhammond