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

Warning when using with latest vite #5211

Closed
6 tasks done
danielroe opened this issue Feb 15, 2024 · 3 comments · Fixed by #5215
Closed
6 tasks done

Warning when using with latest vite #5211

danielroe opened this issue Feb 15, 2024 · 3 comments · Fixed by #5215
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@danielroe
Copy link
Contributor

Describe the bug

When using with a customLogger the following error is printed.

[warn] (!) Experimental optimizeDeps.disabled and deps pre-bundling during build were removed in Vite 5.1.
    To disable the deps optimizer, set optimizeDeps.noDiscovery to true and optimizeDeps.include as undefined or empty.
    Please remove optimizeDeps.disabled from your config.

Reproduction

https://stackblitz.com/edit/github-66e6cf-qyzv3j?file=vitest.config.ts,package.json,tests/my-file.test.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    vitest: ^1.2.2 => 1.2.2

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

I was wondering why warning shows up only with customLogger. It looks like this is because Vitest sets logLevel: 'error':

const config: ViteInlineConfig = {
logLevel: 'error',

const server = await createServer({
logLevel: 'error',
...inlineConfig,
})

so Vite's default logger silences warnings. But when using customLogger, Vite doesn't apply logLevel filtering, so warning shows up:
https://github.com/vitejs/vite/blob/775bb5026ee1d7e15b75c8829e7f528c1b26c493/packages/vite/src/node/logger.ts#L66-L72

Of course, Vitest should deal with deprecated optimizeDeps.disabled flag anyways, but is it possible that Nuxt's custom logger somehow misses logLevel coming from Vitest's inline config?

@sheremet-va sheremet-va removed the bug label Feb 16, 2024
@danielroe
Copy link
Contributor Author

Nuxt's customLogger isn't really expecting to be used in a vitest environment, so it's respecting the logLevel set in the vite config that is passed to it when it is created. Whereas vitest sets the logLevel after the Nuxt custom logger has already been created.

I have removed the customLogger from @nuxt/test-utils in any case but still thought it was worth raising here.

@hi-ogawa
Copy link
Contributor

@danielroe Understood. Thanks for sharing the context and putting together an issue here!

@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants