Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Improve Yarn berry support #612

Open
JGAntunes opened this issue Aug 13, 2021 · 12 comments
Open

Improve Yarn berry support #612

JGAntunes opened this issue Aug 13, 2021 · 12 comments
Labels
theme/caching theme/dependencies theme/package-managers type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@JGAntunes
Copy link
Contributor

JGAntunes commented Aug 13, 2021

This is a cover issue to track problems our build system has with Yarn 2/3. Specifically:

@ehmicky
Copy link
Contributor

ehmicky commented Aug 13, 2021

Note: related issue on netlify/build: netlify/build#1535

@JGAntunes JGAntunes added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Aug 18, 2021
@JGAntunes JGAntunes changed the title Improve Yarn 2 support Improve Yarn berry support Aug 30, 2021
@mauriciabad
Copy link

Is there any progress on this? 😊 I'm also having this issue.

@jasikpark
Copy link

I'd love to see this fixed to reduce build times for my sites!

@rmcfadzean
Copy link

I'm not sure where I saw it on github and it isn't my favourite way but this works in a pinch until it's better supported out of the box:

[build.environment]
YARN_ENABLE_GLOBAL_CACHE = "true"
YARN_GLOBAL_FOLDER = "/opt/buildhome/.yarn_cache"

Add that to your netlify.toml.

➤ YN0000: ┌ Fetch step
➤ YN0013: │ 4 packages were already cached, 2089 had to be fetched
➤ YN0000: └ Completed in 1m 58s

Became:

➤ YN0000: ┌ Fetch step
➤ YN0013: │ 2089 packages were already cached
➤ YN0000: └ Completed in 536ms

@marcofugaro
Copy link

We are wasting precious netlify build minutes.
Would love to see some progress on this as well.

@marcofugaro
Copy link

Thanks @rmcfadzean, your solution works wonderfully for now!

@jesse-holden
Copy link

Can confirm solution provided by @rmcfadzean also works for monorepos that use a custom base directory, am now saving an average of 2 minutes on each build since using this fix

@robations
Copy link

I don't know if this needs a separate issue but I get the following error with "@netlify/plugin-functions-install-core" (yarn 3.0.2):

Error while installing dependencies in /opt/build/repo/functions
Unknown Syntax Error: Unsupported option name ("--no-progress").

$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]

Plugin details
Package:        @netlify/plugin-functions-install-core
Version:        18.17.2
Repository:     git+https://github.com/netlify/build.git
npm link:       https://www.npmjs.com/package/@netlify/build
Report issues:  https://github.com/netlify/build/issues
...

I was thinking PnP would be a good solution to speed up build/deploy but seems like there's a bit of work to do. I was also weighing up pnpm, but seems like support would be patchy. Are there any sane workarounds for disabling npm/yarn and manually packaging functions? Or otherwise decoupling the package manager from build process?

One other note, I added the functions/ dir as a workspace in yarn to silence various warning errors about stray package.json files. Not sure what best practice is here.

@jonioni
Copy link

jonioni commented Nov 9, 2021

The solution mentioned above #612 (comment) doesn't seem to work anymore with Yarn v3 (#615). Is there an updated fix?

@aduh95
Copy link

aduh95 commented Jan 6, 2022

Could we add to the list:

  • Adding support for "packageManager" field in the package.json?
  • Adding support for interacting with Yarn using Corepack (corepack yarn handles the download of the correct version instead of having to specify a version from the env variable)?

Corepack is listed as the preferred install method for Yarn according to https://yarnpkg.com/getting-started/install, but it seems it's not possible to use it with Netlify Deploys.

@kachkaev
Copy link

Seems like there is still no solution for Yarn 3 caching. I tried finding a workaround today but gave up: netlify/build#1535 (comment) HALP! 🙏

@gpoole
Copy link

gpoole commented Jan 3, 2023

Hopefully to save a bit of digging for anyone else facing this issue with Yarn v3, here's a working fix: netlify/build#1535 (comment)

The change from #612 (comment) is that the cache variable is now YARN_CACHE_FOLDER instead of YARN_GLOBAL_FOLDER as per the Yarn documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/caching theme/dependencies theme/package-managers type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

13 participants