Skip to content

Commit

Permalink
🌚 add ts-polyfill to solve ie11 issues (react-hook-form#1018)
Browse files Browse the repository at this point in the history
* Add ts-polyfill to solve ie11 issues

* update yarn.lock

* use polyfill config only for ie11

* cleanup
  • Loading branch information
Vova Bezhenar authored Feb 13, 2020
1 parent 3bd81fc commit a28554e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"rollup-plugin-terser": "^5.1.1",
"rollup-plugin-typescript2": "^0.25.3",
"ts-jest": "^25.1.0",
"ts-polyfill": "^3.7.5",
"typescript": "^3.7.4"
},
"bundlesize": [
Expand Down
6 changes: 4 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import pkg from './package.json';

export function getConfig({
tsconfig = './tsconfig.json',
input = 'src/index.ts',
output = [
{
file: `dist/${pkg.name}.js`,
Expand All @@ -14,10 +15,11 @@ export function getConfig({
format: 'esm',
},
],
external = ['react', 'react-dom']
} = {}) {
return {
input: 'src/index.ts',
external: ['react', 'react-dom'],
input,
external,
plugins: [
typescript({
tsconfig,
Expand Down
2 changes: 2 additions & 0 deletions rollup.ie11.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import pkg from './package.json';

export default getConfig({
tsconfig: './tsconfig.ie11.json',
input: 'src/index.ie11.ts',
output: [
{
file: `dist/${pkg.name}.ie11.js`,
format: 'cjs',
exports: 'named',
},
],
external: ['react', 'react-dom', 'ts-polyfill', 'ts-polyfill/es2015-iterable', 'ts-polyfill/es2015-symbol', 'ts-polyfill/es2015-symbol-wellknown']
});
5 changes: 5 additions & 0 deletions src/index.ie11.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'ts-polyfill';
import 'ts-polyfill/es2015-iterable';
import 'ts-polyfill/es2015-symbol';
import 'ts-polyfill/es2015-symbol-wellknown';
export * from './index';
18 changes: 17 additions & 1 deletion tsconfig.ie11.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es5",
"downlevelIteration": true
"downlevelIteration": true,
"lib": [
"DOM",
"DOM.Iterable",
"ES2015",
"ES2016.Array.Include",
"ES2017.Object",
"ES2017.String",
"ES2018.AsyncIterable",
"ES2018.Promise",
"ES2019.Array",
"ES2019.Object",
"ES2019.String",
"ES2019.Symbol",
"ES2020.String",
"ES2020.Symbol.WellKnown"
]
}
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,11 @@ copy-descriptor@^0.1.0:
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=

core-js@^3.6.4:
version "3.6.4"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.4.tgz#440a83536b458114b9cb2ac1580ba377dc470647"
integrity sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw==

[email protected], core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -5640,6 +5645,13 @@ ts-jest@^25.1.0:
semver "^5.5"
yargs-parser "10.x"

ts-polyfill@^3.7.5:
version "3.7.5"
resolved "https://registry.yarnpkg.com/ts-polyfill/-/ts-polyfill-3.7.5.tgz#c8d0fb9e771857cd0c910f049f06adb5c94c0686"
integrity sha512-KJQ+5JQQoiy7LN1K7SQZj8+J5k4zDzZp20KjaR4s4M93eIbHT760IhoVcQBgwrgEJPip0InaxBTP0JWZ6cNopQ==
dependencies:
core-js "^3.6.4"

[email protected], tslib@^1.8.1, tslib@^1.9.0:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
Expand Down

0 comments on commit a28554e

Please sign in to comment.