forked from extend-chrome/jest-chrome
-
Notifications
You must be signed in to change notification settings - Fork 7
Add export field to package.json #1
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
Open
steciuk
wants to merge
1
commit into
probil:master
Choose a base branch
from
steciuk:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Would love for this to be merged. |
|
I was literally about to open the exact same PR. This would be great! |
aspiers
pushed a commit
to aspiers/vitest-chrome
that referenced
this pull request
Jan 1, 2025
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,
such as
probil#1
in order to obtain functioning ESM support.
In theory this should be achievable via:
"vitest-chrome": "probil/vitest-chrome#5fb1634b"
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
However it seems that, at least with pnpm, the presence of a "build"
step is not sufficient.
So add a "prepare" step which just dispatches to the "build" step.
This makes vitest-chrome installable via a git dependency.
aspiers
pushed a commit
to aspiers/vitest-chrome
that referenced
this pull request
Jan 1, 2025
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,
such as
probil#1
in order to obtain functioning ESM support.
In theory this should be achievable via:
"vitest-chrome": "probil/vitest-chrome#5fb1634b"
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`
However it seems that, at least with pnpm, the presence of a `build`
step is not sufficient.
So add a `prepare` step which just dispatches to the `build` step.
This makes vitest-chrome installable via a git dependency.
|
Since this package is abandoned, here's the fix: import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
setupFiles: ['./source/vitest.setup.js'],
},
resolve: {
alias: {
'vitest-chrome': import.meta.resolve('vitest-chrome/lib/index.esm.js'),
},
},
});and then place this in your setup file: import {chrome} from 'vitest-chrome';
globalThis.chrome = chrome; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the
exportfield is missing vitest is using CommonJS version of the package even if themodulekey is specified which leads to problems with importing vitest from inside the package in a ESM project.For example using:
leads to:
See: vitest-dev/vitest#4233