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
"Module Resolution Error" when bundling Pino logger package #1841
Comments
Update: Looks like the package is working properly:
Any ideas to make it work without peerDeps and extraconf on next.js.config side, thanks in advance :) |
I can report the exact same behavior. When we refactored our logger into its own package (migrating to turbo repo) it kept working, but we also forgot to remove The Problem doesn't exist with our node api. So I guess the problem is probably frontend related (nextjs/webpack) |
I have absolutely no clue, but a PR/fix/doc update would be highly welcomed. |
@victorlrz> * Or when using config.external.push({'thread-stream': 'commonjs thread-stream'}) in NextJs webpack config peerDependencies approach did not work for me, neither serverComponentsExternalPackages Webpack externals works great! - small typo though, should be: Is it related to pino packaging then? This issue is spooky as there is no easy way to tell if it is related to pino and then no hint of how to fix it e.g.: |
I've been struggling with this for two days now. PNPM monorepo, Next 14.0.3. Working solution for me right now:
Haven't tried adding transports yet. There are instructions about instructions about pino bundling here, but I had no luck with the webpack plugin. |
A better guide/doc would be awesome to have. |
I was having issues with |
Hello there,
I am working on a pino logger package for a NextJS application, structured with Turborepo and managed by PNPM. My bundling process involves esbuild-plugin-pino and tsup. For enhancing the development logging, I employ pino-pretty and have crafted a custom module to tailor the messageFormat function to my needs.
However, upon installing my logger package in my NextJS application, I encounter a series of errors that seem to stem from module resolution issues. Here's the detailed error trace:
`- error uncaughtException: Error: Cannot find module 'apps/web/.next/server/pages/api/lib/worker.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
... (truncated for brevity)
at MessagePort. (node:internal/main/worker_thread:164:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:737:20)
... (truncated for brevity)
Error: the worker thread exited
at Worker.onWorkerExit (webpack-internal:///.../node_modules/.pnpm/thread-stream@2.4.1/node_modules/thread-stream/index.js:201:32)
... (truncated for brevity)
at Worker.onWorkerExit (webpack-internal:///.../node_modules/.pnpm/thread-stream@2.4.1/node_modules/thread-stream/index.js:201:32)
... (truncated for brevity)`
From my observations, keeping pino as a dependency in my package seems to trigger these issues. However, when I install pino in my NextJS app and specify it as a peerDep in my package, the errors are resolved. A similar resolution occurs when I install thread-stream directly in the app, although this workaround is not ideal.
I am looking for insights or recommendations on why this behavior occurs and how I might resolve it while keeping my package structure. For a hands-on look, I've set up a minimal repository to replicate the issue here.
Any guidance or suggestions would be greatly appreciated!
Thanks!
The text was updated successfully, but these errors were encountered: