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: make package.json 'exports' work with typescript moduleResolution: 'bundler' #4503

Closed
wants to merge 1 commit into from

Conversation

stackia
Copy link

@stackia stackia commented Dec 29, 2023

When importing antlr4 from a typescript project with moduleResolution: "bundler", typescript will fail to resolve the .d.ts provided by antlr4. That's because typescript tries to resolve the exports with condition ['types', 'import', 'default'] which does't match any of our declared exports.

Change the browser condition to default solves the issue. It's also recommended in Node.js doc:

When using environment branches, always include a "default" condition where possible. Providing a "default" condition ensures that any unknown JS environments are able to use this universal implementation, which helps avoid these JS environments from having to pretend to be existing environments in order to support packages with conditional exports. For this reason, using "node" and "default" condition branches is usually preferable to using "node" and "browser" condition branches.

@stackia stackia closed this Dec 29, 2023
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.

1 participant