Skip to content

Conversation

@arcanis
Copy link
Member

@arcanis arcanis commented Feb 16, 2023

What's the problem this PR addresses?

Making changes to the package.json during prepack is annoying, because whatever changes are made also need to be reverted (or committed, but if they are applied during build it's likely that the users don't want them).

How did you fix it?

This diff implements a new environment variable when the prepack lifecycle script is called: PACK_MANIFEST. If this file exists after prepack returns, Yarn will read it and merge it to the final manifest used to pack the package, before automatically removing it from the filesystem once it's no longer needed.

This way, prepack scripts have the ability to modify:

  • publishConfig (although they can now also directly modify the main, exports, etc fields)
  • version (can be handy to handle the versioning outside of Yarn itself)
  • authors (for example to automatically generate the authors list from the git commit)

As well as all the other fields from package.json. They can even add new ones, for example to attach a commit link to the package.json during builds.

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis arcanis changed the title Implements PACK_MANIFEST feat(pack): Add support for temporary changes to package.json during prepack Feb 16, 2023
@arcanis arcanis changed the title feat(pack): Add support for temporary changes to package.json during prepack feat(pack): Add support for temporary changing the package.json during prepack Feb 16, 2023
@arcanis arcanis changed the title feat(pack): Add support for temporary changing the package.json during prepack feat(pack): Allow temporary changing the package.json during prepack Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants