Skip to content

Revert d3-geo to 2.x to fix Node CJS consumers#3066

Merged
mfedderly merged 1 commit into
masterfrom
mf/revert-d3-geo
May 21, 2026
Merged

Revert d3-geo to 2.x to fix Node CJS consumers#3066
mfedderly merged 1 commit into
masterfrom
mf/revert-d3-geo

Conversation

@mfedderly

@mfedderly mfedderly commented May 21, 2026

Copy link
Copy Markdown
Collaborator

While building testing for the various consumer scenarios, it caught that the d3-geo upgrade from the @turf/buffer migration to TypeScript actually caused failures in node@18 from CJS. I believe this is because d3-geo incorrectly points to an ESM file when it is expecting a CJS one. See arethetypeswrong with node16+cjs.

The original upgrade was from d3-geo@1 to d3-geo@3, but d3-geo@2 hadn't yet been moved to ESM and so we can take that instead.


The failure that was caught by the consumer testing:

❌ > node-cjs:test
  
  
  > node-cjs@1.0.0 test /home/runner/work/turf/turf/test/node-cjs
  > pnpm run /test:.*/
  
  
  > node-cjs@1.0.0 test:node /home/runner/work/turf/turf/test/node-cjs
  > node index.cjs
  
  /home/runner/work/turf/turf/packages/turf-buffer/dist/cjs/index.cjs:5
  var _d3geo = require('d3-geo');
               ^
  
  Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/turf/turf/node_modules/.pnpm/d3-geo@3.1.1/node_modules/d3-geo/src/index.js from /home/runner/work/turf/turf/packages/turf-buffer/dist/cjs/index.cjs not supported.
  Instead change the require of index.js in /home/runner/work/turf/turf/packages/turf-buffer/dist/cjs/index.cjs to a dynamic import() which is available in all CommonJS modules.
      at Object.<anonymous> (/home/runner/work/turf/turf/packages/turf-buffer/dist/cjs/index.cjs:5:14)
      at Object.<anonymous> (/home/runner/work/turf/turf/packages/turf/dist/cjs/index.cjs:24:15)
      at Object.<anonymous> (/home/runner/work/turf/turf/test/node-cjs/index.cjs:3:14) {
    code: 'ERR_REQUIRE_ESM'
  }

@mfedderly mfedderly merged commit 467c9e4 into master May 21, 2026
4 checks passed
@mfedderly mfedderly deleted the mf/revert-d3-geo branch May 21, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant