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

Add fallback for package exports #107

Merged
merged 6 commits into from
Dec 16, 2021
Merged

Conversation

MattiasBuelens
Copy link
Owner

In #83, we switched to using package entry points for the different variants. Unfortunately, TypeScript 4.5 doesn't yet support this: support has been deferred to a future release. This prevents TypeScript users from importing a polyfill variant, which is not great.

This PR adds a fallback to also provide the variants like we did in version 3, i.e. with "sub packages" (e.g. es5/package.json). Modern versions of Node and modern bundlers will still pick up the new package entry points. However, tools that don't support this feature yet (like older Node versions and TypeScript 4.5) will instead find the sub packages and resolve the variant that way.

@MattiasBuelens MattiasBuelens added this to the v4.0.0 milestone Nov 19, 2021
@MattiasBuelens MattiasBuelens self-assigned this Nov 19, 2021
@MattiasBuelens
Copy link
Owner Author

This increases the final package size... slightly. As noted in #83 (comment), these extra package.json files weren't that large to begin with, so I think this is still worth keeping in.

@MattiasBuelens MattiasBuelens merged commit 2b09e55 into next Dec 16, 2021
@MattiasBuelens MattiasBuelens deleted the package-exports-fallback branch December 16, 2021 22:16
@yume-chan
Copy link

@MattiasBuelens Could you please release another beta version with this? I'm currently using TypeScript nightly to test my library against the new Node.js ESM format.

Also microsoft/TypeScript#48555 had removed the nightly-only flag so it should be shipped with TypeScript 4.7-beta in days.

@MattiasBuelens
Copy link
Owner Author

@yume-chan I'm going to do a bit more polishing in #113, and then I'll publish a new beta. Thank you for your patience. 🙂

@MattiasBuelens
Copy link
Owner Author

Released as v4.0.0-beta.2. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants