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(browser): fix chai and loupe deps and silence util.inspect warning #5339

Closed

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Mar 5, 2024

Description

This is an another idea I had for #5082. This should work in principle, but silencing known warning is not pretty.

Also, Instead of doing yet another optimizeDeps patch, maybe it's time to start to think about bundling more packages #5278 (comment), but I haven't got through the idea yet.

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 Mar 5, 2024

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 26b1a07
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65e7a59305ba0300089fa6bd

@hi-ogawa hi-ogawa marked this pull request as ready for review March 6, 2024 00:14
@@ -31,6 +31,11 @@ export async function setupConsoleLogSpy() {
return base(...args)
}
const stderr = (base: (...args: unknown[]) => void) => (...args: unknown[]) => {
// silence warning from loupe's node util.inspect with deps optimization
// https://github.com/vitejs/vite/blob/0c0aeaeb3f12d2cdc3c47557da209416c8d48fb7/packages/vite/src/node/optimizer/esbuildDepPlugin.ts#L227
if (typeof args[0] === 'string' && args[0].startsWith('Module "util" has been externalized for browser compatibility. Cannot access "util.inspect" in client code.'))
Copy link
Member

Choose a reason for hiding this comment

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

This just silences the actual error, Vite should never trigger this error message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I know. This was an only way I found so far to pre-bundle loupe and chai properly without users getting flooded with this auto warning by Vite.

Copy link
Member

Choose a reason for hiding this comment

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

Still, this just hides the problem. Let's close this PR for now.

@hi-ogawa hi-ogawa deleted the fix-browser-chai-loupe-node-util branch March 14, 2024 23:42
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.

vitest/browser fails to run when the dependent package has chai v5
2 participants