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

clearScreen: 'update' #9378

Closed
4 tasks done
Rich-Harris opened this issue Jul 26, 2022 · 3 comments · Fixed by sveltejs/kit#7724 or #14936
Closed
4 tasks done

clearScreen: 'update' #9378

Rich-Harris opened this issue Jul 26, 2022 · 3 comments · Fixed by sveltejs/kit#7724 or #14936
Labels
contribution welcome enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@Rich-Harris
Copy link
Contributor

Description

If a plugin logs something to the console, the logs are destroyed as soon as the welcome text appears...

  VITE v3.0.0  ready in 243 ms

  ➜  Local:   http://127.0.0.1:5174/
  ➜  Network: use --host to expose

...unless you use clearScreen: false — in other words, potentially critical logs are hidden by default. Of course, there's a good reason why clearScreen: true is the default; setting it to false is often undesirable.

It's possible to work around this — in SvelteKit we're doing this...

const print_urls = vite.printUrls;
vite.printUrls = function () {
  print_urls.apply(this);
  if (deferred_warning) console.error('\n' + deferred_warning);
};

...but that only works for that deferred_warning; adding new stuff involves more plumbing, and can never cover arbitrary other plugins unless we monkey-patch console which is brittle and hacky. It's also clearly not an individual plugin's responsibility.

Suggested solution

It would be nice if we had a hybrid solution — don't clear the screen initially, but do clear it after updates. Something like this:

clearScreen: 'update'

I'd personally love it if this was the default, and I'd go so far as to argue that it's not a breaking change, though others might feel differently about that last part.

Alternative

The name 'update' is definitely bikesheddable.

Additional context

No response

Validations

@patak-dev patak-dev added the p2-to-be-discussed Enhancement under consideration (priority) label Jul 29, 2022
@patak-dev patak-dev added the enhancement New feature or request label Jul 29, 2022
@patak-dev patak-dev moved this to Discussing in Team Board Jul 29, 2022
@patak-dev patak-dev moved this from Discussing to P2 - 3 in Team Board Jul 29, 2022
@patak-dev patak-dev moved this from P2 - 3 to P2 - 4 in Team Board Jul 29, 2022
@patak-dev patak-dev moved this from P2 - 4 to P2 - 3 in Team Board Jul 29, 2022
@patak-dev patak-dev moved this from P2 - 3 to P2 - 4 in Team Board Jul 29, 2022
@patak-dev patak-dev moved this from P2 - 4 to P2 - 2 in Team Board Aug 26, 2022
@sapphi-red
Copy link
Member

It seems Vite already does this as long as config.logger.warn/warnOnce/error is used.

info(
`\n ${colors.green(
`${colors.bold('VITE')} v${VERSION}`
)} ${startupDurationString}\n`,
{ clear: !server.config.logger.hasWarned }
)

const logger: Logger = {
hasWarned: false,
info(msg, opts) {
output('info', msg, opts)
},
warn(msg, opts) {
logger.hasWarned = true
output('warn', msg, opts)
},
warnOnce(msg, opts) {
if (warnedMessages.has(msg)) return
logger.hasWarned = true
output('warn', msg, opts)
warnedMessages.add(msg)
},
error(msg, opts) {
logger.hasWarned = true
output('error', msg, opts)
},

@benmccann
Copy link
Collaborator

Oops. I didn't mean to close this

@benmccann benmccann reopened this Nov 19, 2022
@bluwy
Copy link
Member

bluwy commented Feb 23, 2023

Update from the last time we discussed in the meetings: ideally we want this to be the default instead of another option value.

@bluwy bluwy added contribution welcome p2-nice-to-have Not breaking anything but nice to have (priority) and removed p2-to-be-discussed Enhancement under consideration (priority) labels Apr 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
Archived in project
5 participants