pino-webpack-plugin icon indicating copy to clipboard operation
pino-webpack-plugin copied to clipboard

Importing this package breaks Next.js build

Open nemanjam opened this issue 1 year ago • 1 comments

In next.config.js it's enough to import this plugin and it breaks the build.

// next.config.js

const { PinoWebpackPlugin } = require("pino-webpack-plugin");
username@computer3:~/Desktop/pino-webpack-test$ yarn dev
yarn run v1.22.19
$ next dev
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- error Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Cannot find module 'webpack/lib/dependencies/CommonJsRequireDependency'
Require stack:
- /home/username/Desktop/pino-webpack-test/node_modules/pino-webpack-plugin/src/index.js
- /home/username/Desktop/pino-webpack-test/next.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
    at /home/username/Desktop/pino-webpack-test/node_modules/next/dist/server/require-hook.js:189:36
    at Module._load (node:internal/modules/cjs/loader:885:27)
    at Module.require (node:internal/modules/cjs/loader:1105:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/home/username/Desktop/pino-webpack-test/node_modules/pino-webpack-plugin/src/index.js:2:35)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12) {
  type: 'Error',
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/username/Desktop/pino-webpack-test/node_modules/pino-webpack-plugin/src/index.js',
    '/home/username/Desktop/pino-webpack-test/next.config.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
username@computer3:~/Desktop/pino-webpack-test$ 

Here is the same test case from another issue, but I get the same error in other latest Next.js project.

https://github.com/nemanjam/pino-webpack-test

nemanjam avatar Jun 15 '23 18:06 nemanjam