Skip to content
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

Build package in prepack instead of prepublish #4493

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

Methuselah96
Copy link
Member

@Methuselah96 Methuselah96 commented Feb 22, 2023

From Yarn docs about lifecycle scripts:

Note about yarn pack: Although rarely called directly, yarn pack is a crucial part of Yarn. Each time Yarn has to fetch a dependency from a "raw" source (such as a Git repository), it will automatically run yarn install and yarn pack on it to know which are the files to use.

prepack is the lifecycle script called before each call to yarn pack. This is typically the place where you'll want to put scripts that build a package - such as transpiling its source.

prepublish is called before yarn npm publish and similar commands (even before the package has been packed). This is the place where you'll want to check that the project is in an ok state. Because it's only called on prepublish, the prepublish hook shouldn't have side effects. In particular don't transpile the package sources in prepublish, as people consuming directly your repository (such as through the git: protocol) wouldn't be able to use your project.

I have found this change to be helpful when trying to install Redux using the Git protocol in order to test out changes on a specific branch.

prepack is run as part of npm/yarn publish so this change should hopefully not change anything about publishing.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 22, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 64df556:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration

@Methuselah96 Methuselah96 changed the title Move build to prepack Build package in prepack instead of prepublish Feb 22, 2023
@timdorr
Copy link
Member

timdorr commented Feb 22, 2023

To be honest, I really hate these hook scripts anyways. We should just have an automated build and publishing process (we have this on React Router, for instance).

But for now, this at least alleviates some of the hassle.

@timdorr timdorr merged commit f503238 into reduxjs:master Feb 22, 2023
@Methuselah96 Methuselah96 deleted the prepack-script branch February 22, 2023 16:26
@markerikson
Copy link
Contributor

fwiw I've always published locally, first using np, now using release-it.

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.

3 participants