TS compat: enable default importing #25
Closed
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.
This enables TypeScript developers that don't use
esModuleInterop
to consume this library when compiling for both the commonjs and es2015 module systems from the same source code.In the current state, there are two options:
If I use
it compiles fine in both cases, but throws an error like
escape is not a function
in the es2015 build at runtime. The commonjs build runs fine.Now if I use
instead, it throws a compile error, and if you ignore it, there's an error like
escape_string_regexp_1.default is not a function
at runtime in the commonjs build. The es2015 build runs fine.The latter is the easier thing to fix, and it's what I fixed in this PR. In essence, I'm changing the "correct" way (for the TS compiler) from the former to the latter, and making it run in either module environment.
It's also a breaking change for TS users without esModuleInterop, though.