adamgibbons / ics

iCalendar (ics) file generator for node.js
ISC License
715 stars 152 forks source link

Fix exports in package.json #235

Closed remcohaszing closed 1 year ago

remcohaszing commented 1 year ago

TypeScript 4.7 introduced the node16 module resolution. This is more strict, and more correct than older module resolution options.

According to TypeScript, before this change it is possible to use require('ics'), but not import 'ics' from native ESM. This is because there is an explicit require export, that is accompanied by a .d.ts file, but there’s also a default export, which is untyped.

This change fixes it by removing index.js altogether. Its only purpose was to re-export everything from dist/index.js. This is now handled by pointing the main entrypoint and the default export in package.json to dist/index.js. The types export is necessary, because the file doesn’t exist in the same place as the dist files.

The module option was removed entirely. This is a faux ESM option that is supposed to point to a module using ESM syntax. It’s pointing to a CJS file instead, and it would now match the main field anyway.

adamgibbons commented 1 year ago

Thanks for the explanation @remcohaszing!