Closed arturovt closed 2 months ago
Thank you for the PR @arturovt.
I'm not a Typescript expert, but does this change result in any backward incompatible changes for existing users of this library who upgrade to this version?
@jasonbosco When users upgrade to the newer version and run npm install
, npm will add tslib
as a dependency, and the new code will simply require helpers from the tslib
.
Enabling importHelpers
in the library doesn't change its external API or behavior, so existing consumers should still be able to use library without any modifications.
TypeScript will insert helper functions from tslib
into the compiled code instead of duplicating them in each file where they're used, thereby reducing the size of the compiled code.
Thank you for the additional context. That was helpful!
Published this in v1.9.0-7
In ES5 code, TypeScript relies on specific helpers (such as
__spreadArrays()
) to support ES2015+ features. These helpers can be either imported fromtslib
(by enabling theimportHelpers
TS compiler option) or inserted inline (by disabling bothimportHelpers
andnoEmitHelpers
, which are both initially set tofalse
).Currently, the helpers are directly inserted into each JavaScript module, resulting in a larger final size compared to importing them from the
tslib
library. Therefore, in this commit, we enable theimportHelpers
option and includetslib
as a dependency.