Skip to content

fix(browser): optimize build output and always prebundle vitest #8102

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
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sheremet-va
Copy link
Member

Description

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 Jun 5, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit d7532ac
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/68416d71cb3165000877dbd0
😎 Deploy Preview https://deploy-preview-8102--vitest-dev.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 project configuration.

Copy link

pkg-pr-new bot commented Jun 5, 2025

@vitest/browser

npm i https://pkg.pr.new/@vitest/browser@8102

@vitest/coverage-istanbul

npm i https://pkg.pr.new/@vitest/coverage-istanbul@8102

@vitest/coverage-v8

npm i https://pkg.pr.new/@vitest/coverage-v8@8102

@vitest/expect

npm i https://pkg.pr.new/@vitest/expect@8102

@vitest/mocker

npm i https://pkg.pr.new/@vitest/mocker@8102

@vitest/pretty-format

npm i https://pkg.pr.new/@vitest/pretty-format@8102

@vitest/runner

npm i https://pkg.pr.new/@vitest/runner@8102

@vitest/snapshot

npm i https://pkg.pr.new/@vitest/snapshot@8102

@vitest/spy

npm i https://pkg.pr.new/@vitest/spy@8102

@vitest/ui

npm i https://pkg.pr.new/@vitest/ui@8102

@vitest/utils

npm i https://pkg.pr.new/@vitest/utils@8102

vite-node

npm i https://pkg.pr.new/vite-node@8102

vitest

npm i https://pkg.pr.new/vitest@8102

@vitest/web-worker

npm i https://pkg.pr.new/@vitest/web-worker@8102

@vitest/ws-client

npm i https://pkg.pr.new/@vitest/ws-client@8102

commit: 41ef993

@sheremet-va sheremet-va requested a review from Copilot June 5, 2025 13:59
@sheremet-va
Copy link
Member Author

This seems to work..

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the browser build output and adjusts prebundling for Vitest. Key changes include updating export snapshots, refining module paths and dependencies for browser and node modules, and modifying timing calculations in the browser client tester.

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/core/test/exports.test.ts Added exports for additional functions and objects
packages/vitest/src/public/browser.ts Updated public exports to include new modules
packages/vitest/src/node/project.ts Modified prebundle imports to include additional modules
packages/vitest/rollup.config.js Added '@vitest/mocker/browser' as external dependency
packages/utils/package.json Removed "./ast" export block
packages/mocker/* Adjusted exports and dependencies for module mocker
packages/browser/* Updated module imports, exclusion/inclusion lists, and timing logic
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

packages/browser/src/client/tester/mocker.ts:1

  • [nitpick] The import for ModuleMocker has been changed from '@vitest/mocker/browser' to 'vitest/internal/browser'. Verify that this change is intentional and that it aligns with the intended public API exposure.
import { ModuleMocker } from 'vitest/internal/browser'

packages/browser/src/client/client.ts:3

  • [nitpick] Ensure that using 'vitest/internal/browser' for ModuleMocker is consistent with the rest of the codebase and does not inadvertently expose internal APIs.
import type { ModuleMocker } from 'vitest/internal/browser'

@@ -142,7 +144,7 @@ async function prepareTestEnvironment(options: PrepareOptions) {
})
}

state.durations.prepare = performance.now() - options.startTime
state.durations.prepare = options.startTime - now()
Copy link
Preview

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

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

The duration calculation subtracts now() from options.startTime, which is likely reversed. Consider calculating elapsed time as now() - options.startTime.

Suggested change
state.durations.prepare = options.startTime - now()
state.durations.prepare = now() - options.startTime

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant