Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exports in package.json #235

Merged
merged 1 commit into from
Feb 20, 2023
Merged

Fix exports in package.json #235

merged 1 commit into from
Feb 20, 2023

Conversation

remcohaszing
Copy link
Contributor

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.

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 adamgibbons merged commit ae4e382 into adamgibbons:master Feb 20, 2023
@adamgibbons
Copy link
Owner

Thanks for the explanation @remcohaszing!

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.

2 participants