Skip to content

Commit

Permalink
Fix exports in package.json (#235)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
remcohaszing authored Feb 20, 2023
1 parent 2ba0a38 commit ae4e382
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"version": "3.0.1",
"description": "iCal (ics) file generator",
"exports": {
"require": "./index.js",
"types": "./index.d.ts",
"default": "./dist/index.js"
},
"main": "index.js",
"module": "./dist/index.js",
"main": "./dist/index.js",
"types": "index.d.ts",
"scripts": {
"start": "mocha --require @babel/register --watch --recursive",
Expand Down

0 comments on commit ae4e382

Please sign in to comment.