-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Yarn Berry #194
Conversation
… Add unresolved questions
text/nodejs/0014-yarn-berry.md
Outdated
## Unresolved Questions and Bikeshedding | ||
|
||
|
||
- Should this buildpack require `yarn`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love to hear any thoughts on this item (and the related one below). Configuring corepack
to correctly enable yarn
in the offline case would require the developer to corepack prepare
their yarn release so that the buildpack can corepack hydrate
it. Does that seem reasonable? Foregoing the yarn
requirement is starting to feel more idealistic than it is practical.
An argument against introducing another buildpack here is that it would increase complexity in other buildpacks that use yarn
like the Web Servers buildpack.
text/nodejs/0014-yarn-berry.md
Outdated
|
||
- If there is no `.pnp.cjs` in the working directory, even if a local cache exists. | ||
|
||
- If the `yarn.lock` has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what? Is this from a checksum recorded in a previous build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the yarn-install
buildpack generates a checksum of yarn.lock
and the output of yarn config --list
. The plan is to do the same, replacing yarn config
with yarn info
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what happens if there is a .pnp.cjs
file and a local cache and the yarn.lock
file has changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworked this section a bit, let me know if that makes sense.
text/nodejs/0014-yarn-berry.md
Outdated
|
||
`yarn-berry-install` | ||
|
||
Provides: `yarn_packages` OR `node_modules` Requires: `node`, during `build` and `launch` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this require anything at launch? At launch, this buildpack isn't really doing anything other than making sure that there are some JavaScript files available on the filesystem. I'd expect that if someone wanted to run these files, they'd need to require node
some other way, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, I've updated accordingly.
text/nodejs/0014-yarn-berry.md
Outdated
|
||
- If there is no `.pnp.cjs` in the working directory, even if a local cache exists. | ||
|
||
- If the `yarn.lock` has changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what happens if there is a .pnp.cjs
file and a local cache and the yarn.lock
file has changed?
fail if the `yarn.lock` file needs to be updated. As such, developers must run | ||
`yarn install` locally in order to update their app's `yarn.lock` file. | ||
`--frozen-lockfile` has been deprecated in favour of `--immutable`, which this | ||
buildpack will utilize. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am bit concerned by this.
I agree --immutable
is a good idea in theory.
But I had strange cases where for an identical node and yarn version, yarn install --immutable
would fail on some env and succeed on others. Very frustrating and hard to debug.
Should we instead not specify the option by default and let users either
- add
enableImmutableInstalls: true
to.yarnrc.yml
- or set with yarn env vars mechanism:
YARN_ENABLE_IMMUTABLE_INSTALLS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is helpful feedback, thank you. I'm okay with making this configurable.
text/nodejs/0014-yarn-berry.md
Outdated
- Include logic for Yarn Berry workflows in the existing `yarn-install` | ||
buildpack. | ||
|
||
Berry includes breaking changes to the `yarn` CLI used by the buildpack to | ||
install dependencies. The changes to CLI options are such that at the very | ||
least, the buildpack would need to decide which ones to use based on the type | ||
of application being built. Trying to incorporate both workflows will | ||
increase the scope of responsibility of the buildpack, likely increasing its | ||
complexity at the expense of maintainability. Classic Yarn is now in | ||
maintenance mode and, though it is still heavily used now (due to the | ||
relatively slow adoption of Berry), its unclear how long it will be | ||
supported. For this reason, it is even more prudent to keep the logic | ||
separate to facilitate the eventual transition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be reasonable to still get Berry support in the existing buildpack if we just take some effort to keep the "Classic" and Berry parts separate. If we did something like move all the existing code in the buildpack into a classic
package and then created a new berry
package we can keep them logically separated. We could then just have a small amount of code at the top-level that decides with codepath to invoke.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't considered separate packages, that's an interesting suggestion. It would remove a lot of overhead in the event that we drop support for Classic altogether.
text/nodejs/0014-yarn-berry.md
Outdated
id = "paketo-buildpacks/yarn-berry-install" | ||
|
||
[[order.group]] | ||
id = "paketo-buildpacks/node-module-bom" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are any updates to this buildpack required to generate the SBOM in cases where there is a yarn cache instead of node_modules
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I think the inclusion of node-module-bom
here is a mistake on my part. The buildpack shouldn't need to leverage that buildpack at all for generating the SBoM and would instead include logic for SBoM generation akin to what exists in yarn-install
currently.
text/nodejs/0014-yarn-berry.md
Outdated
All `node` commands run via the shell should be run with `yarn node` instead. The default | ||
start command in the Yarn Start buildpack may need to be modified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we elaborate on any changes needed to the yarn-start or node-start (included in the berry group above) buildpacks? Seems like there could be some gotchas here with detection criteria and cache vs modules configurations.
text/nodejs/0014-yarn-berry.md
Outdated
[[order.group]] | ||
id = "paketo-buildpacks/yarn-berry-install" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be optional and opt out if users are going with the zero-installs method? This might mess up detection for the group without some changes in (yarn start), but it could be confusing to see yarn install opt-in when you are explicitly striving for zero-installs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This order group may now be obsolete as I was able to prove out a sane way to keep the build logic for both Yarn classic and Berry in a single buildpack (per @ryanmoran's suggestion). As for the UX, I figured we could indicate through the logs whenever the buildpack has chosen to forgo running yarn install
based on adherence to the zero-installs setup.
Is this RFC still actively being worked on? We have interest in helping push this forward as well, if help is needed. |
@thitch97 IIRC you mentioned during WG you were making some largish changes to the RFC. Do you mind posting a comment describing where it is at and what your intentions are? If it needs more work before it is ready for further discussion/reviews maybe we should put it back into draft temporarily? |
@divoxx @ekcasey My intention at the moment is to shift to the model initially enumerated in the "Rationale and Alternatives" section. It turns out that hosting both Classic and Berry codepaths in one buildpack isn't as heavy an engineering/maintenance burden as it seemed (and in fact removes some overhead). As such, many of the technical decisions here, especially the order groupings, are now obsolete. |
From WG 7/19/22:
Seeking @paketo-buildpacks/nodejs-maintainers feedback on these changes. |
text/nodejs/0014-yarn-berry.md
Outdated
Provides: `node_pkgs` | ||
Requires: `node`, `yarn` during `build` | ||
|
||
The Node.js buildpacks use `node_modules` as a keyword for providing/requiring | ||
packages in the build plan across the board. Since Berry explicitly excludes | ||
`node_modules`, however, it seems reasonable to instead use a generic term for | ||
node packages such as `node_pkgs`. | ||
|
||
The buildpacks affected by this change to the `node_modules` build plan dependency are: | ||
|
||
- `npm-install` | ||
- `yarn-install` | ||
- `npm-start` | ||
- `yarn-start` | ||
- `node-start` | ||
- `node-run-script` | ||
- `node-module-bom` | ||
- `rails-assets` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some more of the rational behind this choice? I'm not seeing how we don't end up in a state where its either confusing to Berry users or confusing to non-Berry users about what is being provided here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryanmoran The rationale was that node_modules
is just not an artifact that is produced in the Berry PnP case. I thought that providing node_modules
would be confusing to users who've opted into PnP, and that referring to them both as a set of Node.js "packages" was a reasonable compromise. It also seemed neater than using the Or
field to provide either node_modules
or something like yarn_cache
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me, it'd be more intuitive if the yarn classic and yarn berry paths resulted in two slightly different build plans, since they do involve dealing with different sets of artifacts.
I'd be in favor of the yarn-install buildpack providing node_modules
if it plans on running yarn install
and yarn_cache
if it doesn't. Then the start command buildpacks could require one Or
the other.
2022-07-26 Working Group notes: Use different build plans for yarn classic and yarn berry (#194 (comment)) |
2022-08-02 WG Notes: Approved by Node maintainers. Final call for any comments. Scheduled to be merged soon. |
Readable
Checklist