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

Use prepack instead of prepublish #389

Merged
merged 2 commits into from
Mar 31, 2018
Merged

Conversation

knpwrs
Copy link
Contributor

@knpwrs knpwrs commented Mar 28, 2018

prepublish is no longer the correct way to build before publish. The correct script to use is prepack. The reason for this is that prepublish runs after pack and before publish, and pack is the script which defines what is published during publish, i.e., the package being published is already created by the time prepublish is called. By building in prepack the package will be created properly during pack and then published during publish. Using prepublish relies on having an already-done, possibly stale build.

`prepublish` is no longer the correct way to build before `publish`. The correct script to use is `prepack`. The reason for this is that `prepublish` runs after `pack` and before `publish`, and `pack` is the script which defines what is published during `publish`, i.e., the package being published is already created by the time `prepublish` is called. By building in `prepack` the package will be created properly during `pack` and then published during `publish`. Using `prepublish` relies on having an already-done, possibly stale build.
@KiaraGrouwstra
Copy link
Member

sounds good, thanks for the PR! not sure what CI is yapping about. @ikatyang?

@ikatyang
Copy link
Member

We use prepublish to build types after npm install, you probably have to add yarn run build to .travis.yml as well.

@knpwrs
Copy link
Contributor Author

knpwrs commented Mar 31, 2018

Yep, that appears to have fixed it!

@ikatyang ikatyang merged commit 1936b72 into typed-typings:master Mar 31, 2018
@ikatyang
Copy link
Member

Thanks!

@Draeken
Copy link

Draeken commented Mar 31, 2018

So, yarn is mandatory if I want to use @types/ramda ?

@ikatyang
Copy link
Member

No, see Usage.

@Draeken
Copy link

Draeken commented Mar 31, 2018

Yes, but when performing
npm install --save-dev types/npm-ramda#dist
I get:

> @types/ramda@0.25.0 prepack /Users/***/.npm/_cacache/tmp/git-clone-73a2dbb0`
> yarn run build

sh: yarn: command not found

ikatyang added a commit that referenced this pull request Mar 31, 2018
@ikatyang
Copy link
Member

Ah, sorry. I didn't notice that'll trigger the prepack script after installing from git. Reverted in bf2c978.

prepack: run BEFORE a tarball is packed (on npm pack, npm publish, and when installing git dependencies)

@knpwrs knpwrs deleted the patch-1 branch March 31, 2018 13:41
@knpwrs
Copy link
Contributor Author

knpwrs commented Mar 31, 2018

@ikatyang would it possibly be best to change the package.json script to use npm instead of yarn? As it stood previously, prepublish would require yarn. Not particularly a big deal if all the maintainers use yarn. Ultimately the change to use the prepack script is meant to reduce the chance of a possible error getting published.

@ikatyang
Copy link
Member

Actually, the problem is that we don't need to build from source, the files from dist branch are already built. And currently, we do not publish anything to npm since @types namespace are handled by DefinitelyTyped.

@KiaraGrouwstra
Copy link
Member

I don't know all the considerations for yarn, but I think recent npm releases did fix much of their original issues.

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.

4 participants