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

chore: add a prepare step so that git dependencies build #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aspiers
Copy link

@aspiers aspiers commented Jan 1, 2025

Community guidelines:

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers: none

Description

It is convenient to be able to specify dependencies in package.json which point to particular git commits. One use case is allowing dependencies on PRs which are not yet merged and published to npm.org.

In theory this should be achievable via:

"jest-chrome": "extend-chrome/vitest-chrome#some-PR-branch-name"

https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies states:

When installing from a git repository, the presence of certain fields in the package.json will cause npm to believe it needs to perform a build. To do so your repository will be cloned into a temporary directory, all of its deps installed, relevant scripts run, and the resulting directory packed and installed.

This flow will occur if your git dependency uses workspaces, or if any of the following scripts are present:

  • build
  • prepare
  • prepack
  • preinstall
  • install
  • postinstall

And indeed jest-chrome already has a build script.

However it seems that, at least with pnpm, the presence of a build script is not sufficient.

So add a prepare script which just dispatches to the build script. This makes jest-chrome installable via a git dependency.

See also probil#2

It is convenient to be able to specify dependencies in package.json
which point to particular git commits.  One use case is allowing
dependencies on PRs which are not yet merged and published to npm.org.

In theory this should be achievable via:

    "jest-chrome": "extend-chrome/vitest-chrome#some-PR-branch-name"

https://docs.npmjs.com/cli/v8/configuring-npm/package-json#git-urls-as-dependencies
states:

> When installing from a git repository, the presence of certain fields
> in the package.json will cause npm to believe it needs to perform a
> build. To do so your repository will be cloned into a temporary
> directory, all of its deps installed, relevant scripts run, and the
> resulting directory packed and installed.
>
> This flow will occur if your git dependency uses workspaces, or if
> any of the following scripts are present:
>
> - `build`
> - `prepare`
> - `prepack`
> - `preinstall`
> - `install`
> - `postinstall`

And indeed jest-chrome already has a `build` script.

However it seems that, at least with pnpm, the presence of a `build`
script is not sufficient.

So add a `prepare` script which just dispatches to the `build` script.
This makes jest-chrome installable via a git dependency.
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.

1 participant