Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So the current setup is that
zod
has a compile target of es5, which applies to both its ES Module and CJS distributions. Zod's internals use quite a lot of modern features. TypeScript is polyfilling all of those features in the distributed code. TypeScript's polyfills are very good and probably as fast as they can be, but they're not as fast as the native code. For example, every array or object spread and every generator gets compiled to something with a bit more indirection.That indirection looks like it's costing a real slowdown for some Zod functions.
So, bumping the target to ES2018 would cost IE11 support if it was done uniformly. Assuming that IE11 support is still critical (that's for the maintainers to decide, not me), a possibility might be targeting es2018 in the module entrypoint and keeping es5 in the main.
Okay, so before:
After: