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

Fix 'yarn pack' #238

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Fix 'yarn pack' #238

merged 2 commits into from
Jan 18, 2024

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jan 18, 2024

The yarn pack command is run by the npm-publish action prior to publishing the package. Unfortunately, this command does not work as the prepack lifecycle script is overridden to run yarn build:clean, which was removed when this repo was converted to use tsup for building. tsup already clears the dist directly, so in practice a build:clean script is not usually necessary, but there are occasions where we want to really be sure that dist does not exist, and publishing is one of them. Hence, this commit adds back build:clean, which should fix yarn pack and the publishing workflow.

Testing

Running yarn pack should not produce any errors.

Examples

N/A, as this is a bugfix to this repo.

The `yarn pack` command is run by the `npm-publish` action prior to
publishing the package. Unfortunately, this command does not work as the
`prepack` lifecycle script is overridden to run `yarn build:clean`,
which was removed when this repo was converted to use `tsup` for
building. `tsup` already clears the `dist` directly, so in practice a
`build:clean` script is not usually necessary, but there are occasions
where we want to _really_ be sure that `dist` does not exist, and
publishing is one of them. Hence, this commit adds back `build:clean`,
which should fix `yarn pack` and the publishing workflow.
@mcmire mcmire requested a review from a team as a code owner January 18, 2024 19:10
package.json Outdated Show resolved Hide resolved
@Mrtenz
Copy link
Member

Mrtenz commented Jan 18, 2024

tsup already clears the dist directly, so in practice a build:clean script is not usually necessary, but there are occasions where we want to really be sure that dist does not exist, and publishing is one of them. Hence, this commit adds back build:clean, which should fix yarn pack and the publishing workflow.

Not sure I understand the reasoning here. If tsup guarantees to clear the dist, isn't it easier to modify the prepack script to run yarn build?

@mcmire
Copy link
Contributor Author

mcmire commented Jan 18, 2024

@Mrtenz I wanted to make sure that we completely remove dist before publishing so that we can be absolutely certain that unwanted files don't slip into releases.

I checked the tsup source code and it does seem that everything gets removed from dist: https://github.com/egoist/tsup/blob/8c26e63c92711d60c05aedd3cdc358530ba266c5/src/index.ts#L303

So yes, you're right, we can just use yarn build in the prepack script. I've done that here: d04b7e7

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mcmire mcmire merged commit 354995b into main Jan 18, 2024
14 checks passed
@mcmire mcmire deleted the add-build-clean-task-back branch January 18, 2024 21:19
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