Search code examples
npmyarnpkgmonorepoyarn-workspaces

Yarn Workspace, how to exclude package files in node_modules?


I am trying to find functionality equal to .npmignore for yarn workspaces.

For example, let's say I have test, src(typescript) and lib(compiled javascript) folder in a package name called '@walnut/peanut'.

I only need the compiled 'lib' folder in node_modules, so I only want lib folder to be included in node_modules/@walnut/peanut folder when yarn install.

I have tried putting .npmignore file in the package (obviously, but just in case), but it still seems to include all the files, not just lib folder. Also tried specifying following in package.json, but no luck

{
...,
files:["/lib"],
}

How do I configure this?

Thanks


Solution

  • I think the right format would be

    files: [
      "lib/"
    ]
    

    Note that this does not apply when you refer to this package from the same monorepo. In this case Yarn just symlinks the whole package directory from the top-level node-modules folder.