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

customLogger option ignored when logging "failed to load config from..." errors #15824

Closed
broofa opened this issue Feb 6, 2024 · 0 comments · Fixed by #15831
Closed

customLogger option ignored when logging "failed to load config from..." errors #15824

broofa opened this issue Feb 6, 2024 · 0 comments · Fixed by #15831
Labels
contribution welcome p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@broofa
Copy link

broofa commented Feb 6, 2024

Describe the bug

When invoking the vite.build() API programatically, the customLogger option is ignored when reporting an config file load error.

Note

The source of this problem appears to be this code in loadConfigFromFile(). It's creating a new createLogger() instance, when it should be using the customLogger that gets passed to vite.build()

Reproduction

see steps to reproduce, below

Steps to reproduce

Copy the following code to vite_config_error_test.mjs:

import {build, createLogger} from 'vite';

const customLogger = {
  info() {},
  warn() {},
  error() {},
};

build({
  configFile: './nosuchfile.json',
  customLogger
})

Then node vite_config_error_test.mjs and you should see something like this:

CleanShot 2024-02-06 at 11 18 55

System Info

> [!NOTE]
> I'm aware I'm running an older version of `vite`, but judging by the source (see link above), this is pretty clearly an issue on the `main` branch, too.


$ npx envinfo --system --npmPackages '{vite,@vitejs/*,rollup}' --binaries --browsers

  System:
    OS: macOS 14.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.19 GB / 64.00 GB
    Shell: 5.2.15 - /opt/homebrew/bin/bash
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.18.0 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
    Watchman: 2023.10.09.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 121.0.6167.139
    Firefox: 121.0.1
    Safari: 17.2
  npmPackages:
    @vitejs/plugin-vue2: ^2.2.0 => 2.3.1
    vite: ^4.4.11 => 4.5.1


### Used Package Manager

yarn

### Logs

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@bluwy bluwy added contribution welcome p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Feb 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome 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.

2 participants