microsoft / tslib

Runtime library for TypeScript helpers.
BSD Zero Clause License
1.25k stars 126 forks source link

Add 'tslib.umd.js' to avoid global pollution #52

Open rbuckton opened 6 years ago

rbuckton commented 6 years ago

This adds a tslib.cjs.js file as the package main to reduce the impact of global variable pollution, as well as some additional variants. Also, in an effort to avoid redundancy between each variant, this adds a script to generate all files from a single source.

This also leaves tslib.js as is as it still has a use case to support both --importHelpers for modules and scripts (which depend on the helpers being available as globals).

Fixes: #32

rbuckton commented 6 years ago

This also paves the way for the possibility of supporting #33 as the generator script can be easily modified to emit each helper into its own file (current progress can be seen in https://github.com/Microsoft/tslib/tree/oneHelperPerFile).

rbuckton commented 6 years ago

I've updated this to support multiple variants:

rbuckton commented 6 years ago

@DanielRosenwasser If we end up taking this, should I also emit a copy of tslib.es6.js as tslib.mjs?

slaneyrw commented 5 years ago

Any action on this, global window pollution is a real problem

Clashsoft commented 3 years ago

Any news on this?