Skip to content

v0.2.2

Choose a tag to compare

@BogdanTaranenko BogdanTaranenko released this 21 Jul 13:31
· 6 commits to main since this release

Packaging fixes. No API changes, no runtime behaviour changes — this release only affects how TypeScript resolves the package's types.

If you are on moduleResolution: "bundler" or "node16" from ESM, 0.2.1 already worked for you and nothing here changes.

react-threat-map/geo now has types under moduleResolution: "node"

node10 resolution ignores the exports map, and there was no typesVersions fallback, so the subpath resolved to nothing:

error TS2307: Cannot find module 'react-threat-map/geo' or its corresponding
type declarations. There are types at '.../dist/geo.d.ts', but this result
could not be resolved under your current 'moduleResolution' setting.

This lands hardest on the consumers 0.2.1 set out to support: projects still on node10 resolution skew old, which is the same population still on React 16/17.

If you worked around this with react-threat-map/dist/geo — that path typechecks but fails at runtime with ERR_PACKAGE_PATH_NOT_EXPORTED, and webpack 5 enforces the same restriction. Switch back to react-threat-map/geo.

CommonJS consumers no longer receive ESM type declarations

Both entry points declared a single "types" covering the import and require conditions. Because this package is "type": "module", that .d.ts is read as an ES module — so CommonJS consumers on node16/nodenext were told the types were ESM while the runtime correctly handed them the .cjs build:

error TS1479: The current file is a CommonJS module whose imports will produce
'require' calls; however, the referenced file is an ECMAScript module...

The correct CJS declarations (index.d.cts, geo.d.cts) were already being built and shipped — the exports map just never pointed at them. Types are now declared per condition.

Verified

Entry node10 node16 (CJS) node16 (ESM) bundler
react-threat-map ✅ ✅ ✅ ✅
react-threat-map/geo ✅ ✅ ✅ ✅

npm run check:exports (arethetypeswrong) now runs in CI against a real npm pack, covering every entry point against every resolution mode. Nothing else in the suite could see this class of fault: the tests import from src/, so a package that is correct at runtime can still fail to typecheck for a large share of its consumers.