Open Maronato opened 8 months ago
If I run next-on-pages with --disableChunksDedup
, it works ok. The duplicate identifier seems to be webpack
! Is it safe to run un-deduped builds? 😄
If I run next-on-pages with
--disableChunksDedup
, it works ok. The duplicate identifier seems to bewebpack
! Is it safe to run un-deduped builds? 😄
It's safe to, you'll just have a much much larger bundle size
Any update on this? @Maronato were you able to find a workaround other than disabling the ChunksDedup?
Just leaving some insights, in case anyone is interested:
As @ostenbom indicated, the above error seems to originate from the Webpack module ID assignment. Overwriting the default assignment algorithm fixes the error; however, it results in a much larger bundle size (a factor of 8 in my case), which usually makes the bundle exceed Cloudflare's maximum limit of 25 MB.
Example that fixes the error, but bloats the bundle size:
//next.config.js
webpack: (config) => {
config.optimization = {
...config.optimization,
moduleIds: false, // Disable built-in module ID algorithms
};
config.plugins.push(new webpack.ids.NaturalModuleIdsPlugin());
}
I tried all algorithms listed in the webpack optimization documentation, but all of them either cause the build error or led to a significant increase in bundle size. Trying other options to reduce the bundle size did not make a significant difference.
This is unfortunate, as this is by far the most convenient way of adding observability to a Next.js application. From Cloudflare's perspective, fixing this would especially make sense given their acquisition of Baselime, which is currently almost useless for Cloudflare Pages (except for Edge logging). I hope this issue will be addressed at some point.
next-on-pages environment related information
Description
next-on-pages breaks when using Next's default instrumentation
@vercel/otel
, resulting in the following error:Reproduction
Repo: https://github.com/Maronato/next-on-pages-instrumentation-repro
Steps to reproduce:
npm create cloudflare@latest next-on-pages -- --framework=next
@vercel/otel
(npm install @vercel/otel
)experimental: { instrumentationHook: true }
to your next configsrc
or root of the project calledinstrumentation.ts
import { registerOTel } from "@vercel/otel"
export function register() { registerOTel() }