From 8626fa4c099e79ca9d8fec7e1297ddd51e79dfba Mon Sep 17 00:00:00 2001 From: Roy Gal Date: Mon, 3 Aug 2026 12:05:44 +0300 Subject: [PATCH] fix: add "type": "module" + rename CJS bundle to .cjs (fixes #233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @dagrejs/graphlib points exports.import at dist/graphlib.esm.js (ESM syntax) but has no "type": "module", so runtimes that don't auto-detect ESM (tsx, Node without --experimental-detect-module) treat that .js file as CommonJS. Named imports then resolve to undefined and `new Graph()` throws TypeError. Add "type": "module" so the ESM bundle is interpreted as ESM, and rename the CJS bundle from dist/graphlib.cjs.js to dist/graphlib.cjs — the .cjs extension is pinned to CommonJS regardless of package type, so `require()` keeps working. A naive "Option A" (type: module without the .cjs rename) would break require() with ERR_REQUIRE_ESM, since the CJS bundle is a .js file using module.exports. The IIFE browser bundles (dist/graphlib.js, dist/graphlib.min.js) stay .js: they are loaded via