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

fix(coverage): fix bundling of v8-to-istanbul #5549

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Apr 15, 2024

Description

Looks like Rollup doesn't transpile require('fs').promises.

Changes in bundle:

-const compatError = Error(`requires Node.js ${require$$9.engines.node}`);
-const { readFileSync } = require$$10;
-let readFile = () => { throw compatError };
-try {
-  readFile = require('fs').promises.readFile;
-} catch (_err) {
-  // most likely we're on an older version of Node.js.
-}
+import require$$9 from 'fs';
...
+const { readFileSync, promises } = require$$9;
+const readFile = promises.readFile;

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit fb6c375
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/661d373f19413600089cc1cc
😎 Deploy Preview https://deploy-preview-5549--fastidious-cascaron-4ded94.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@AriPerkkio AriPerkkio marked this pull request as ready for review April 15, 2024 14:56
Copy link
Contributor

@hi-ogawa hi-ogawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Regarding this comment #5532 (comment)

This is working fine in Vitest's monorepo and in ecosystem-ci projects.

I think, for the tests inside this repo, Vitest (vite-node) see @vitest/coverage-v8 as non external, so it's probably injecting cjs compat including require:

// cjs compact
require: createRequire(href),

I thought ecosystem-ci would catch this, but maybe we don't test @vitest/coverage-v8? It looks like the one in coverage-large is using only istanbul https://github.com/vitest-tests/coverage-large/blob/6dc5a055b30556e78ee3a0b6fff3968fac222c07/vitest.config.ts#L29

@AriPerkkio
Copy link
Member Author

Looks like v8-to-istanbul also calls this method on certain conditions so it's possible that Vitest monorepo is not running into that.

@AriPerkkio AriPerkkio merged commit df6a432 into vitest-dev:main Apr 16, 2024
19 checks passed
@AriPerkkio AriPerkkio deleted the fix/v8-to-istanbul-require branch April 16, 2024 14:15
@dschmidt
Copy link

When can we expect a release with a fix?

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.

V8 Coverage fails
3 participants