Closed AymenBenAmor closed 3 years ago
Hi. Webpack 5 is the default in Next.js 11, or you can opt-in in Next 10.2 when you have a custom config by creating the following config:
// next.config.js
module.exports = {
future: {
webpack5: true,
},
}
Hi @ascorbic Thank you for your response. Even with forcing webpack5 I still had issues in the netlify build. However I could fix my issue by deploying my puppeteer related code to a standalone function and not as part of nextjs. So I guess I will close this.
Describe the bug My build is failing when trying to deploy my NextJS project on Netilify with the next error: It works perfectly locally when I don't use a specific webpack config (and therefor use webpack 5). If I add a custom webpack config to my nextJS project and it starts using webpack 4 then I have the same issue.
I am not sure this is a bug with netlify-plugin-nextjs but Is there a way to use webpack 5 when deploying to netlify?
Failed to compile. 10:56:44 PM: 10:56:44 PM: ./node_modules/chrome-aws-lambda/build/puppeteer/lib/Browser.js.map 10:56:44 PM: Module parse failed: Unexpected token (1:10) 10:56:44 PM: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders 10:56:44 PM: > {"version":3,"file":"Browser.js","sourceRoot":"","sources":["../../../source/puppeteer/lib/Browser.ts"],"names":[],"mappings":";;AAGA,IAAI,KAAK,GAAuB,IAAI,CAAC;AAErC,IAAI;IACF,KAAK,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC,OAAO,CAAC;CACvE;AAAC,OAAO,KAAK,EAAE;IACd,KAAK,GAAG,OAAO,CAAC,iDAAiD,CAAC,CAAC,OAAO,CAAC;CAC5E;AAED,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,KAAK,WAAW,GAAG,KAAa;IAC5D,IAAI,IAAI,GAAS,IAAI,CAAC;IACtB,IAAI,KAAK,GAAW,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAEvC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,KAAK,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;KAChC;IAED,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAErB,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QAClD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,IAAI,OAAO,GAAQ,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC;AAE3C,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,WAAW,GAAG,KAAa;IACxD,IAAI,IAAI,GAAS,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAEtD,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;QAClD,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;SACzB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"} 10:56:44 PM: > Build error occurred 10:56:44 PM: Error: > Build failed because of webpack errors 10:56:44 PM: at /opt/build/repo/node_modules/next/dist/build/index.js:17:924 10:56:44 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/telemetry/trace/trace.js:6:584)
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen. The build should success as when executed locally.
Versions
If you're using the CLI to build
If you're using file-based installation