-
Notifications
You must be signed in to change notification settings - Fork 896
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
feat: Support bundlers. #1209
feat: Support bundlers. #1209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs automated tests
Why are we patching around other tool's problems? |
We're not patching around their problems. |
Tests added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add docs?
Sure, will add them soon. |
I don't understand how checking for magic variables (that look to be intended as private) in the global object so that we can then use a patched up |
There is a missing webpack plugin that will make this possible. Currently pino and transport do not work at all with bundled codebases. |
@jsumners Yeah, Matteo is right. Sorry, I should have mentioned that as we speak I'm working on one of the plugin that will add this support to webpack. |
My question is: how is that the fault of Pino? |
It's not the fault of pino. This is not a bugfix but an additional feature. People will ask for this and there are valid usecases for bundling their codebase. |
This is the slippery slope I'm trying to guard against. This PR addresses |
Nope, the fix is universal. I already experimented for webpack and esbuild. |
The gist of the fix:
This is generic. |
@jsumners You can take a look at pinojs/pino-webpack-plugin#1 to see how a bundler plugin might work. |
Truthfully, no. I know nothing of webpack nor it's API. I'm not going to block this work. I just disagree with it for the reasoning stated above. |
Docs added as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@jsumners I'll chime in to provide some context around the underlying issue and why we thought it would be a good idea to address it. First of all, this problem is introduced by pino@7. Why? Because using service workers requires physical files on the file systems. Hence, even though I can agree that bundling a Node application is not necessarily a great idea this change has broken all such usages of pino. And this is "pino's fault" if you wish. Obviously, all such usages could just as well decide to not upgrade to pino@7, but this breaking change is not really something that was even foreseen, it was just realized afterwards. Because bundling an application is something that in some cases is actually a valid scenario, we decided to try to see what supporting it would imply. What it implies is that the original requirement of worker threads to have the file run by the worker exist physically on the file system remains, hence we needed to find a way to make it happen when using a bundler, which turned out to be tricky but doable. It required the change contained in this PR for pino which can be used for all bundlers (or at least we hope so), and the rest will be done on the bundler's side. For webpack, which is the only implementation we have so far, we created a plugin. https://github.com/pinojs/pino-webpack-plugin For the other bundlers, which we are not actively working on, there will be similar approaches that we can follow. Hopefully with the webpack plugin we have paved the way for the other bundlers. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This PR add supports for using pino in bundled source files.
In particular:
Note that in order for this to fully work, pinojs/thread-stream#48 must be merged and released.
Fixes #1164
Fixes #1104