Skip to content

fix: TypeScript ESM compatibility fixes for moduleResolution: NodeNext #107

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

Merged
merged 1 commit into from
May 22, 2023

Conversation

jimmycallin
Copy link
Contributor

@jimmycallin jimmycallin commented May 19, 2023

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

When importing the library in TypeScript using "moduleResolution": "NodeNext", the typings it produced were wrong due to TypeScript starting to rely on the native Node ESM module resolution implementation. You can read more about this here: https://www.typescriptlang.org/docs/handbook/esm-node.html

In short, we need to change all relative imports to use a .js file ending.

Test

Try importing this as a library using node and ts-node and make sure it behaves as expected. It's good to verify that the right bundle is imported by adding different console logs in both the umd and es build and verify that the output matches your expectations.

@jimmycallin jimmycallin requested a review from a team as a code owner May 19, 2023 10:40
@jimmycallin jimmycallin requested a review from gismya May 19, 2023 10:41
@jimmycallin jimmycallin merged commit efbc16f into main May 22, 2023
@jimmycallin jimmycallin deleted the esm-fixes branch May 22, 2023 12:22
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