turf icon indicating copy to clipboard operation
turf copied to clipboard

Building Next 14+ project blocked by turf - webpack

Open darenmalfait opened this issue 2 years ago • 5 comments

Please provide the following when reporting an issue:

  • The version of Turf you are using, and any other relevant versions. 6.5.0 + 7.0.0-alpha.2
  • GeoJSON data as a gist file or geojson.io (filename extension must be .geojson). not relevant
  • Snippet of source code or for complex examples use jsfiddle. not relevant

In development mode, everything works fine (also did in < NextJS 14 versions). It's webpack related.

../../node_modules/@turf/turf/node_modules/@turf/buffer/dist/es/index.js + 62 modules
Cannot get final name for export 'merge' of ../../node_modules/d3-geo/node_modules/d3-array/src/index.
> Build failed because of webpack errors
   Creating an optimized production build

darenmalfait avatar Nov 10 '23 10:11 darenmalfait

Possible workaround here @darenmalfait Let us know if that helps.

smallsaucepan avatar Dec 17 '23 05:12 smallsaucepan

Same issue here. @darenmalfait did you figure out a workaround?

@smallsaucepan I've tried that workaround, I'm trying with serverComponentsExternalPackages: ['d3-array', '@turf/buffer'], but I can't figure it out.

bernatfortet avatar Feb 06 '24 03:02 bernatfortet

@bernatfortet it's not a great solution, but I solved my problem just by installing the modules I am using and its dependancies. So, avoid installing the whole @turf/turf library.

P.S: Maybe the problem could be solved just by importing the essential modules, and still installing the whole library, but I didn't tried that.

sebaterrazas avatar Feb 06 '24 19:02 sebaterrazas

Adding @turf/buffer to serverComponentsExternalPackages does seem to work for me. Although I cannot 100% confirm, I had other priorities and the project I am using it in has other issues that needs solving.

My experimental config

experimental: {
    serverActions: {
      bodySizeLimit: '2mb',
    },
    serverComponentsExternalPackages: ['@turf/buffer'],
    esmExternals: 'loose',
  },

darenmalfait avatar Feb 07 '24 09:02 darenmalfait

Hi all, my issue was solved after upgrading to turf 7.0.0-alpha.2

bernatfortet avatar Feb 07 '24 18:02 bernatfortet

Hi @bernatfortet and @darenmalfait. Just released a new alpha that changes our packaging approach somewhat. Would you mind checking to make sure it isn't a step backwards for you? 7.0.0-alpha.114

smallsaucepan avatar Mar 12 '24 00:03 smallsaucepan

So far 114 works on dev, deploys to Vercel, and works on prod. If I find any issues I'll let you know.

bernatfortet avatar Mar 14 '24 19:03 bernatfortet

Thanks @bernatfortet Will mark this resolved for now and include something in the 7.0.0 release notes to that effect.

smallsaucepan avatar Mar 29 '24 03:03 smallsaucepan