MetaMask / metamask-module-template

A simple template repository for starting new modules in the latest MetaMask fashion.
26 stars 23 forks source link

Fix 'yarn pack' #238

Closed mcmire closed 7 months ago

mcmire commented 7 months ago

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.

Mrtenz commented 7 months ago

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 commented 7 months ago

@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