vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
67.97k stars 6.12k forks source link

Support Rollup logging functions in dev #13624

Open sapphi-red opened 1 year ago

sapphi-red commented 1 year ago

Description

Rollup added logging functions (this.info, this.debug) in 3.25.0. Currently we added them as a no-op in #13608. But we should output logs.

Suggested solution

Implement them. I guess we would call config.logger.info for this.info(). I don't know what we should do for this.debug().

Also I guess we should pass logLevel to Rollup.

Alternative

No response

Additional context

No response

Validations

sun0day commented 1 year ago

Seems that this.info wouldn't be called by rollup itself until the plugins call it

mato533 commented 1 year ago

Hello!

When I use some rollup plugins, only warning log at the plugin for rollup is treated by the vite.

I propose the following three modifications.

  1. Use onLog instead of onwarn. (Rollup Configuration guide - onLog)

    https://github.com/vitejs/vite/blob/6d5be5c6c9547745d3cedef1ff1295be78c09193/packages/vite/src/node/build.ts#L537-L552

  2. Following codes would be modified to accept all log levels(info,warn,error,debug). https://github.com/vitejs/vite/blob/6d5be5c6c9547745d3cedef1ff1295be78c09193/packages/vite/src/node/build.ts#L869-L936

  3. Also change the options where Rollup is called in different code.

    https://github.com/vitejs/vite/blob/ef4602bc56c0b9579342acca7ef82ba655d56a2e/packages/vite/src/node/plugins/worker.ts#L75-L83

Thank you!

crystalfp commented 2 months ago

+1 Seems onwarn and onLog defined in vite.config.mts are not called when running npx vite build