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 'tslib.umd.js' to avoid global pollution #52

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented May 13, 2018

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
Copy link
Member Author

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
Copy link
Member Author

I've updated this to support multiple variants:

  • tslib.js - A bundle of all helpers that supports both CommonJS and AMD modules as well as adds global (for use with <script></script> tags).
  • tslib.umd.js - A bundle of all helpers that supports both CommonJS and AMD modules, but does not add global variables.
  • tslib.cjs.js - A bundle of all helpers that supports only CommonJS (this is the default variant used as "main" in package.json).
  • tslib.amd.js - A bundle of all helpers that supports only AMD.
  • tslib.es6.js - A bundle of all helpers that supports ECMAScript module syntax.
  • tslib.global.js - A bundle of all helpers that only adds globals (for use with <script></script> tags).

@rbuckton
Copy link
Member Author

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

@rbuckton rbuckton requested a review from mhegazy May 14, 2018 20:33
@slaneyrw
Copy link

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

@Clashsoft
Copy link

Any news on this?

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

Successfully merging this pull request may close these issues.

tslib is polluting window object
3 participants