Skip to content

fix: import consola properly to ensure logs appear in console - #109

Merged
dulnan merged 4 commits into
dulnan:mainfrom
euaaaio:fix-debug-logger
Sep 20, 2025
Merged

fix: import consola properly to ensure logs appear in console#109
dulnan merged 4 commits into
dulnan:mainfrom
euaaaio:fix-debug-logger

Conversation

@euaaaio

@euaaaio euaaaio commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

When importing from consola/core, the logger was created without reporters, resulting in logs not appearing in the console. This made debugging difficult as module messages weren’t displayed.

Fixed by changing the import path from consola/core to just consola, ensuring the logger is created with proper default reporters.

https://github.com/unjs/consola/blob/512d570b3f99a27b6766a885cae2730aa3dc0ed4/src/index.ts#L17-L42

@dulnan

@euaaaio

euaaaio commented Sep 17, 2025

Copy link
Copy Markdown
Contributor Author

It seems that tests failed because of an outdated lock-file. So I’ll leave it up to you.

@dulnan

dulnan commented Sep 20, 2025

Copy link
Copy Markdown
Owner

Thank you very much! I will look into the lock file issue.

@dulnan

dulnan commented Sep 20, 2025

Copy link
Copy Markdown
Owner

Ah, I now remember why I did use that import. It is to prevent including consola in the client bundle. Because, even if logger is only ever used inside a import.meta.server check, for some reason a lot of consola stuff is still included in the client bundle, where it's definitely not needed. Too bad it doesn't work that way on the server... I'll need to figure out how to get rid of it in client bundles.

@dulnan

dulnan commented Sep 20, 2025

Copy link
Copy Markdown
Owner

I'm now overriding the contents of the logger file with export const logger = console for the client bundle via a build plugin. That solves the issue of consola being included in client bundles and makes it work correctly on the server. Also added a test to check the presence of the string consola in the playground's generated client bundles.

@dulnan
dulnan merged commit f3f3d3a into dulnan:main Sep 20, 2025
5 checks passed
@euaaaio

euaaaio commented Sep 22, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for your work and your quick response.
Awesome package!

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.

2 participants