Skip to content

Commit

Permalink
Configure project to use local vitest
Browse files Browse the repository at this point in the history
This took a bit of figuring out. The process was:

- Add `.npmrc` to this repo per:
  - https://pnpm.io/npmrc#auto-install-peers
  - https://pnpm.io/npmrc#prefer-frozen-lockfile
  - https://pnpm.io/npmrc#prefer-workspace-packages

- `git clone https://github.com/vitest-dev/vitest.git` in the parent
  directory of this repository.

- Add 'file:' dependencies to vitest and @vitest/browser, both residing
  within '../vitest/packages'.
  https://pnpm.io/cli/link#whats-the-difference-between-pnpm-link-and-using-the-file-protocol

- Add pnpm-workspace.yaml with an '../vitest/packages/*' entry so the
  local vitest modules can find their peer modules in the same
  workspace.
  https://pnpm.io/pnpm-workspace_yaml

- Set vite to 4.5.1, since I eventually learned the problem always
  occurs with vite 5.0.5. (I suspect this may have something to do with
  the upgrade from Rollup 4 to Rollup 5.)

Then in the `../vitest` directory:

```sh
git reset --hard v1.0.0-beta.4
pnpm i --ignore-scripts --frozen-lockfile
pnpm build
```

And back in this repository:

```sh
pnpm i
pnpm test
```

I can now get the demo test running successfully against the local
vitest v1.0.0-beta.4. Repeating the process for v1.0.0-beta.5, I can
reproduce the vitest/utils import problem/reload loop.

Now let's see what a `git bisect` will produce...

...one thing I already noticed:

- The vitest packages from v1.0.0-beta.4 depend on vite < 5.0.0
- The vitest packages from v1.0.0-beta.5 depend on vite >= 5.0.0-beta*

So...could be the issue resides within Vite somehow.

The vitest repo is OK up through this commit, which is the last working
commit before the Vite ^5.0.0 bump:

- commit f6a445dbc86e0e5b7de29ae650ecebf8ac6e4ffa

The next commit breaks the pnpm-lock.yaml file, and remains broken until
the following commit and the PR containing it gets merged:

- commit 5b738663197b78cf103b269c6e7489286957c1a7
- vitest-dev/vitest#4368

```sh
git diff f6a445dbc86e0e5b7de29ae650ecebf8ac6e4ffa 5b738663197b78cf103b269c6e7489286957c1a7
```

Yep. None of the changes there seem to have anything directly to do with
packages/browser/src/client/main.ts or the `config.base` value. It
seems to be the Vite 5 upgrade, which is consistent with the fact that
v1.0.0-beta.4 works with Vite 4.5.1, but not Vite 5.0.5.

Now that I've got my methodology down, next I'll start bisecting commits
in Vite.
  • Loading branch information
mbland committed Dec 6, 2023
1 parent 5ed256a commit 52783ac
Show file tree
Hide file tree
Showing 4 changed files with 4,236 additions and 468 deletions.
3 changes: 3 additions & 0 deletions .npmrc
@@ -0,0 +1,3 @@
auto-install-peers=false
prefer-frozen-lockfile=false
prefer-workspace-packages=true
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -11,9 +11,9 @@
"test:bisect": "vitest --run --browser.headless"
},
"devDependencies": {
"@vitest/browser": "^1.0.1",
"vite": "^5.0.5",
"vitest": "^1.0.1",
"@vitest/browser": "file:../vitest/packages/browser",
"vite": "4.5.1",
"vitest": "file:../vitest/packages/vitest",
"webdriverio": "^8.24.6"
}
}

0 comments on commit 52783ac

Please sign in to comment.