├── .gitattributes ├── .github └── workflows │ └── nodejs.yml ├── .gitignore ├── .npmignore ├── .vscode └── settings.json ├── LICENSE ├── README.MD ├── build.ps1 ├── dist ├── ts-polyfill.js ├── ts-polyfill.min.js └── ts-polyfill.min.js.map ├── lib ├── es2015-collection.js ├── es2015-core.js ├── es2015-iterable.js ├── es2015-promise.js ├── es2015-reflect.js ├── es2015-symbol-wellknown.js ├── es2015-symbol.js ├── es2016-array-include.js ├── es2017-object.js ├── es2017-string.js ├── es2017-typed-arrays.js ├── es2018-async-iterable.js ├── es2018-promise.js ├── es2019-array.js ├── es2019-object.js ├── es2019-string.js ├── es2019-symbol.js ├── es2020-global-this.js ├── es2020-promise.js ├── es2020-string.js ├── es2020-symbol-wellknown.js └── index.js ├── official-lib-declarations ├── CHANGELOG.MD ├── lib.d.ts ├── lib.dom.d.ts ├── lib.dom.iterable.d.ts ├── lib.es2015.collection.d.ts ├── lib.es2015.core.d.ts ├── lib.es2015.generator.d.ts ├── lib.es2015.iterable.d.ts ├── lib.es2015.promise.d.ts ├── lib.es2015.proxy.d.ts ├── lib.es2015.reflect.d.ts ├── lib.es2015.symbol.d.ts ├── lib.es2015.symbol.wellknown.d.ts ├── lib.es2016.array.include.d.ts ├── lib.es2017.intl.d.ts ├── lib.es2017.object.d.ts ├── lib.es2017.sharedmemory.d.ts ├── lib.es2017.string.d.ts ├── lib.es2017.typedarrays.d.ts ├── lib.es2018.asyncgenerator.d.ts ├── lib.es2018.asynciterable.d.ts ├── lib.es2018.intl.d.ts ├── lib.es2018.promise.d.ts ├── lib.es2018.regexp.d.ts ├── lib.es2019.array.d.ts ├── lib.es2019.object.d.ts ├── lib.es2019.string.d.ts ├── lib.es2019.symbol.d.ts ├── lib.es2020.bigint.d.ts ├── lib.es2020.promise.d.ts ├── lib.es2020.string.d.ts └── lib.es2020.symbol.wellknown.d.ts ├── package.json ├── pnpm-lock.yaml ├── rollup.config.js ├── src ├── es2015-collection.ts ├── es2015-core.ts ├── es2015-iterable.ts ├── es2015-promise.ts ├── es2015-reflect.ts ├── es2015-symbol-wellknown.ts ├── es2015-symbol.ts ├── es2016-array-include.ts ├── es2017-object.ts ├── es2017-string.ts ├── es2017-typed-arrays.ts ├── es2018-async-iterable.ts ├── es2018-promise.ts ├── es2019-array.ts ├── es2019-object.ts ├── es2019-string.ts ├── es2019-symbol.ts ├── es2020-global-this.ts ├── es2020-promise.ts ├── es2020-string.ts ├── es2020-symbol-wellknown.ts └── index.ts ├── tsconfig.json ├── types ├── es2015-collection.d.ts ├── es2015-core.d.ts ├── es2015-iterable.d.ts ├── es2015-promise.d.ts ├── es2015-reflect.d.ts ├── es2015-symbol-wellknown.d.ts ├── es2015-symbol.d.ts ├── es2016-array-include.d.ts ├── es2017-object.d.ts ├── es2017-string.d.ts ├── es2017-typed-arrays.d.ts ├── es2018-async-iterable.d.ts ├── es2018-promise.d.ts ├── es2019-array.d.ts ├── es2019-object.d.ts ├── es2019-string.d.ts ├── es2019-symbol.d.ts ├── es2020-global-this.d.ts ├── es2020-promise.d.ts ├── es2020-string.d.ts ├── es2020-symbol-wellknown.d.ts └── index.d.ts └── update-libs.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | lib/**/*.js linguist-generated=true 2 | dist/**/*.js linguist-generated=true 3 | rollup*.js linguist-language=TypeScript 4 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | strategy: 11 | matrix: 12 | node-version: [10.x, 12.x] 13 | 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Use Node.js ${{ matrix.node-version }} 17 | uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - name: npm install, build, and test 21 | run: | 22 | npm install -g yarn 23 | yarn 24 | yarn build 25 | # npm test 26 | env: 27 | CI: true 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | official-lib-declarations/ 2 | src/ 3 | .travis.yml 4 | build.ps1 5 | rollup.config.js 6 | rollup.config.min.js 7 | tsconfig.json 8 | yarn.lock 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules\\typescript\\lib" 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Ryan Elian 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # TS-Polyfill 2 | 3 | > Runtime polyfills for TypeScript libs, powered by [core-js](https://github.com/zloirock/core-js)! :battery: :nut_and_bolt: 4 | 5 | [![npm](https://img.shields.io/npm/v/ts-polyfill.svg)](https://www.npmjs.com/package/ts-polyfill) [![GitHub Actions](https://github.com/ryanelian/ts-polyfill/workflows/Node%20CI/badge.svg)](https://github.com/ryanelian/ts-polyfill/actions) 6 | 7 | ## Install 8 | 9 | `npm install ts-polyfill` 10 | 11 | ## Getting Started 12 | 13 | - Modify your project `tsconfig.json` to add type definitions required. 14 | 15 | - *(Obviously, you don't need EVERYTHING. Pick the ones you actually need to minimize bandwidth!)* 16 | 17 | - In this example, we are targeting ES2015 so only ES2016 and above polyfills are needed: 18 | 19 | ```json 20 | { 21 | "compilerOptions": { 22 | "target": "ES2015", 23 | "lib": [ 24 | "DOM", 25 | "DOM.Iterable", 26 | "ES2015", 27 | "ES2016.Array.Include", 28 | "ES2017.Object", 29 | "ES2017.String", 30 | "ES2018.AsyncIterable", 31 | "ES2018.Promise", 32 | "ES2019.Array", 33 | "ES2019.Object", 34 | "ES2019.String", 35 | "ES2019.Symbol", 36 | "ES2020.Promise", 37 | "ES2020.String", 38 | "ES2020.Symbol.WellKnown" 39 | ] 40 | } 41 | } 42 | ``` 43 | 44 | > It is 2020 and you should be targeting ES2015. [Internet Explorer 11 and Windows 7 are no longer supported by Microsoft and no longer receive security patches](https://support.microsoft.com/en-us/help/17621/internet-explorer-downloads). 45 | 46 | - Then, in the entry point of your application, import the polyfills. 47 | 48 | - The complete list of available polyfills (including ES2015 polyfills for poor souls targeting ES5) can be found here: https://github.com/ryanelian/ts-polyfill/tree/master/lib 49 | 50 | ```ts 51 | // index.ts 52 | import 'ts-polyfill/lib/es2016-array-include'; 53 | import 'ts-polyfill/lib/es2017-object'; 54 | import 'ts-polyfill/lib/es2017-string'; 55 | import 'ts-polyfill/lib/es2018-async-iterable'; // for-await-of 56 | import 'ts-polyfill/lib/es2018-promise'; 57 | import 'ts-polyfill/lib/es2019-array'; 58 | import 'ts-polyfill/lib/es2019-object'; 59 | import 'ts-polyfill/lib/es2019-string'; 60 | import 'ts-polyfill/lib/es2019-symbol'; 61 | import 'ts-polyfill/lib/es2020-promise'; 62 | import 'ts-polyfill/lib/es2020-string'; 63 | import 'ts-polyfill/lib/es2020-symbol-wellknown'; 64 | 65 | import 'ts-polyfill/lib/es2020-global-this'; // globalThis (no tsconfig.json lib) 66 | ``` 67 | 68 | > Shameless self-promotion: **use [instapack](https://github.com/ryanelian/instapack) for easy, rapid, and painless web app development using TypeScript!** 69 | 70 | ## Alternative Techniques 71 | 72 | - Include everything implicitly: :ok_hand: 73 | 74 | - EXCEPT these non-essential polyfills (for portability): `es2015-iterable, es2015-reflect, es2015-symbol, es2015-symbol-wellknown, es2017-typed-arrays, es2018-async-iterable, es2019-symbol, es2020-symbol-wellknown` 75 | 76 | ```ts 77 | import 'ts-polyfill'; 78 | ``` 79 | 80 | - Include everything (also with exceptions listed above) using a pre-built script: download then include these as `