Skip to content

Commit afa104c

Browse files
mrTuomoKcursoragent
andcommitted
fix: resolve leaflet markercluster ESM build failure under pnpm
Use esmExternals loose and transpile @changey/react-leaflet-markercluster so its CJS dist can require @react-leaflet/core during Next.js production builds. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 957ebe8 commit afa104c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

next.base.config.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ if (NEXTJS_SENTRY_DEBUG) {
7474

7575
// Tell webpack to compile those packages
7676
// @link https://www.npmjs.com/package/next-transpile-modules
77-
const tmModules = ['@events-helsinki/components'];
77+
const tmModules = [
78+
'@events-helsinki/components',
79+
// CJS dist requires @react-leaflet/core; transpile for Next esmExternals
80+
'@changey/react-leaflet-markercluster',
81+
];
7882

7983
const projectFolder = process.cwd();
8084

@@ -134,8 +138,8 @@ const nextBaseConfig = ({
134138
outputFileTracingRoot: __dirname,
135139

136140
experimental: {
137-
// Prefer loading of ES Modules over CommonJS
138-
esmExternals: true,
141+
// 'loose' allows CJS deps (e.g. @changey/react-leaflet-markercluster) to require ESM packages
142+
esmExternals: 'loose',
139143
// Experimental monorepo support
140144
externalDir: true,
141145
scrollRestoration: true,

0 commit comments

Comments
 (0)