-
Notifications
You must be signed in to change notification settings - Fork 9
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
Using transport with file with Next.js #81
Comments
@ShogunPanda wdyt? |
I need to look into it. @GodDrinkTeJAVA Can you please provide me a reproducible repository or a list of commands I can execute to reproduce this? |
https://github.com/GodDrinkTeJAVA/pino-webpack-test This is a simple example project made from create-next-app. In modules/logger.ts, Pino constructor actually has no transport property, and only adding PinoWebpackPlugin to plugin arrays from next.config.js causes the error. dev-server shows error information page when accessed, and next build fails with same error. If any of my implementation is broken, I would appreciate a lot for letting me notified. |
I tried cloning your repo and then run |
I've checked out the commit and you were right. I'll check more conditions and re-comment when the problem is correctly found. |
I'm not sure I understand the question. Can you please clarify? |
Sorry if it confuses you. What I just tried to tell was to check out which way of directory should be given as transport.target property in pino() function call. pino({
transport: {
target: PATH_TO_TRANSPORT
}
}) README.md says each file specified in plugin constructor's transports option would be generated at the root of the dist folder. I thought file with pino() function call would be generated in top level, too. Sorry for confusing comment. |
@mcollina I think you have more knowledge in this. Can you help? |
https://github.com/GodDrinkTeJAVA/pino-webpack-test Also, I found the way to reproduce the error. Now main branch shows error when npm build. |
Sorry about the somewhat off topic comment but I fail to understand what benefit using this would bring to a Next.js app? We're currently using Pino 7 with Next.js like any other library and everything seems to work as expected. |
This plugin allows you to use transports in a bundled server component. Not something that I would recommend, but it seems people are really interested in doing it. |
Has anyone here found a way forward for using Next.js with Pino transports? I've searched everywhere and come to no conclusion. #109 is the exact same issue as me and has received no attention from the PinoJS community in months. What do Next.js developers do, as there doesn't seem to be any other great logging libraries out there... |
Pull Requests are welcomed, especially for bugs like this. |
Hopefully the below helps in some following work on this, as I could not fix this problem.
import pino from "pino";
const logger = pino({
transport: {
target: `${__dirname}/modules/logger/transport.mjs`,
},
});
export default logger; Hope this helps for further investigation. |
Hi @mcollina . Without transports it is not possible to save the log to a file or push the log to an external SaaS log tracker. WIthout transports, in Next.js, pino can only be used without transport, or with pino-pretty if it is passed in as a stream. In other words, without bundling the worker etc, it is not possible to use pino in a meaningful way in Next.js 14 apps. Am I missing something, or would you agree? |
@ristomatti Are you doing it with transports? It does not work on my end in Next.js 14. Without transports, pino becomes a lot less useful (i.e. only console printing, unless I am missing something). |
While importing PinoWebpackPlugin in Next.config.js, next.js always shows the message for not having CommonJsRequireDependency.
When I push PinoWebpackPlugin into array of plugins by this clause where currDir is simply a variable for __dirname
The error for dependency always occurs, regardless of my TS-baed project, or new JS-based project created by create-next-app. next build always fail, and dev-server throws error for it.
The message below is shown by error page:
The message below is shown by terminal running server:
I've searched for the CommonJsRequireDependency error cases and haven't found any clue for it. If further information is needed, let me know by leaving a comment for that.
The text was updated successfully, but these errors were encountered: