From 47485f7648870edcaa05d4f27084f2795afdaff5 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Mon, 1 Mar 2021 17:05:18 +0000 Subject: [PATCH 01/11] Remove createTsDec --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index e955ed94..051e9783 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ }, "scripts": { "start": "react-app-rewired start", - "build": "rollup --config && yarn createTsDec", + "build": "rollup --config && yarn tsc", "test": "jest", "tsc": "tsc", "validate": "yarn tsc && yarn test && yarn lint", @@ -104,7 +104,6 @@ "storybook": "start-storybook", "build-storybook": "build-storybook", "lint": "eslint . --ext .ts,.tsx", - "createTsDec": "tsc --emitDeclarationOnly true --declaration true --declarationDir build/ --noEmit false", "release": "yarn validate && yarn build && np" }, "eslintConfig": { From 355feef45b57a9b145112dd819b3b4764e3be996 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Mon, 1 Mar 2021 17:07:50 +0000 Subject: [PATCH 02/11] move config to config.ts --- tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index b7de299a..65273a5e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,8 @@ "module": "esnext", "lib": ["es2017", "es7", "es6", "dom", "DOM.Iterable"], "outDir": "build", + "emitDeclarationOnly": true, + "declaration": true, "strict": true, "esModuleInterop": true, "jsx": "react-jsx", From 9f24bed3e7a7cc54b67422ee775f3fb438143803 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 14:56:24 +0000 Subject: [PATCH 03/11] remove emitDeclarationOnly from ts config --- tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 65273a5e..c64d9219 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "module": "esnext", "lib": ["es2017", "es7", "es6", "dom", "DOM.Iterable"], "outDir": "build", - "emitDeclarationOnly": true, "declaration": true, "strict": true, "esModuleInterop": true, From 2eb68c2151ca2cee17050a3a1e1507760183a16d Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 14:57:21 +0000 Subject: [PATCH 04/11] ignore *.test.tsx files from ts compiler --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index c64d9219..bb38c320 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,5 @@ }, "files": ["src/types.ts"], "include": ["src/"], - "exclude": [] + "exclude": ["**/*.test.tsx"] } From bebca928eff5c0f4ae466770f49e34d57f690d07 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 15:31:22 +0000 Subject: [PATCH 05/11] ignore storybook files from ts build --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index bb38c320..34a511b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "module": "esnext", "lib": ["es2017", "es7", "es6", "dom", "DOM.Iterable"], "outDir": "build", + "rootDir": "src", "declaration": true, "strict": true, "esModuleInterop": true, @@ -20,5 +21,5 @@ }, "files": ["src/types.ts"], "include": ["src/"], - "exclude": ["**/*.test.tsx"] + "exclude": ["**/*.test.tsx", "**/*.stories.tsx"] } From b691ffee05b1368b57b0af11cf3f92ff1f1f6f59 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 17:09:08 +0000 Subject: [PATCH 06/11] use yarn validate in pre-push --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 051e9783..4973e17d 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "build": "rollup --config && yarn tsc", "test": "jest", "tsc": "tsc", - "validate": "yarn tsc && yarn test && yarn lint", + "validate": "yarn tsc && yarn test --watchAll=false && yarn lint", "eject": "react-scripts eject", "prettier:check": "prettier . --check", "prettier:fix": "prettier . --write", @@ -133,7 +133,7 @@ }, "husky": { "hooks": { - "pre-push": "pretty-quick --staged && yarn lint && yarn tsc && yarn test --watchAll=false && yarn prettier:check" + "pre-push": "pretty-quick --staged && validate && yarn prettier:check" } }, "jest": { From f125949fdac741b69584c45d7da4433889f50b39 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 17:10:08 +0000 Subject: [PATCH 07/11] use yarn validate in pre-push --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4973e17d..73918ac6 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ }, "husky": { "hooks": { - "pre-push": "pretty-quick --staged && validate && yarn prettier:check" + "pre-push": "pretty-quick --staged && yarn validate && yarn prettier:check" } }, "jest": { From 3cc47fa158d13f88155c3c39a17dfdc827e6fdfd Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 17:27:22 +0000 Subject: [PATCH 08/11] emitDeclarationOnly tsconfig --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 34a511b9..01b6e35f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,6 +4,7 @@ "module": "esnext", "lib": ["es2017", "es7", "es6", "dom", "DOM.Iterable"], "outDir": "build", + "emitDeclarationOnly": true, "rootDir": "src", "declaration": true, "strict": true, From 0906b734fd443665016d642ee114e17e926561e0 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 17:49:24 +0000 Subject: [PATCH 09/11] remove babel/resolve/common rollup dependencies --- package.json | 4 +-- yarn.lock | 89 +++------------------------------------------------- 2 files changed, 6 insertions(+), 87 deletions(-) diff --git a/package.json b/package.json index 73918ac6..b45bce01 100644 --- a/package.json +++ b/package.json @@ -55,9 +55,7 @@ "@guardian/src-link": "^3.3.0", "@guardian/src-text-input": "^3.3.0", "@guardian/types": "^3.0.0", - "@rollup/plugin-babel": "^5.3.0", - "@rollup/plugin-commonjs": "^17.1.0", - "@rollup/plugin-node-resolve": "^11.2.0", + "@rollup/plugin-typescript": "^8.2.0", "@storybook/addon-actions": "^6.1.18", "@storybook/addon-essentials": "^6.1.18", "@storybook/addon-links": "^6.1.18", diff --git a/yarn.lock b/yarn.lock index adc498f2..272b8b52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3084,39 +3084,14 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" -"@rollup/plugin-babel@^5.3.0": - version "5.3.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.0.tgz#9cb1c5146ddd6a4968ad96f209c50c62f92f9879" - integrity sha512-9uIC8HZOnVLrLHxayq/PTzw+uS25E14KPUBh5ktF+18Mjo5yK0ToMMx6epY0uEgkjwJw0aBW4x2horYXh8juWw== - dependencies: - "@babel/helper-module-imports" "^7.10.4" - "@rollup/pluginutils" "^3.1.0" - -"@rollup/plugin-commonjs@^17.1.0": - version "17.1.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-17.1.0.tgz#757ec88737dffa8aa913eb392fade2e45aef2a2d" - integrity sha512-PoMdXCw0ZyvjpCMT5aV4nkL0QywxP29sODQsSGeDpr/oI49Qq9tRtAsb/LbYbDzFlOydVEqHmmZWFtXJEAX9ew== +"@rollup/plugin-typescript@^8.2.0": + version "8.2.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.2.0.tgz#3e2059cbcae916785d8d7bf07816210c829f817c" + integrity sha512-5DyVsb7L+ehLfNPu/nat8Gq3uJGzku4bMFPt90XahtgiSBf7z9YKPLqFUJKMT41W/mJ98SVGDPOhzikGrr/Lhg== dependencies: "@rollup/pluginutils" "^3.1.0" - commondir "^1.0.1" - estree-walker "^2.0.1" - glob "^7.1.6" - is-reference "^1.2.1" - magic-string "^0.25.7" resolve "^1.17.0" -"@rollup/plugin-node-resolve@^11.2.0": - version "11.2.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.0.tgz#a5ab88c35bb7622d115f44984dee305112b6f714" - integrity sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA== - dependencies: - "@rollup/pluginutils" "^3.1.0" - "@types/resolve" "1.17.1" - builtin-modules "^3.1.0" - deepmerge "^4.2.2" - is-module "^1.0.0" - resolve "^1.19.0" - "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" @@ -3961,11 +3936,6 @@ resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d" integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag== -"@types/estree@*": - version "0.0.42" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.42.tgz#8d0c1f480339efedb3e46070e22dd63e0430dd11" - integrity sha512-K1DPVvnBCPxzD+G51/cxVIoc2X8uUVl1zpJeE6iKcgHMj4+tbat5Xu4TjV7v2QSDbIeAfLi2hIk+u2+s0MlpUQ== - "@types/estree@0.0.39": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" @@ -4225,13 +4195,6 @@ dependencies: "@types/react" "*" -"@types/resolve@1.17.1": - version "1.17.1" - resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6" - integrity sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== - dependencies: - "@types/node" "*" - "@types/responselike@*": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" @@ -6125,11 +6088,6 @@ buffer@^4.3.0: ieee754 "^1.1.4" isarray "^1.0.0" -builtin-modules@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.1.0.tgz#aad97c15131eb76b65b50ef208e7584cd76a7484" - integrity sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== - builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -8586,11 +8544,6 @@ estree-walker@^1.0.1: resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== -estree-walker@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" - integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== - esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -10681,7 +10634,7 @@ is-color-stop@^1.0.0: rgb-regex "^1.0.1" rgba-regex "^1.0.0" -is-core-module@^2.1.0, is-core-module@^2.2.0: +is-core-module@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.2.0.tgz#97037ef3d52224d85163f5597b2b63d9afed981a" integrity sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ== @@ -10841,11 +10794,6 @@ is-map@^2.0.1: resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== -is-module@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" - integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= - is-negative-zero@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" @@ -10946,13 +10894,6 @@ is-promise@^2.1.0: resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= -is-reference@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/is-reference/-/is-reference-1.2.1.tgz#8b2dac0b371f4bc994fdeaba9eb542d03002d0b7" - integrity sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ== - dependencies: - "@types/estree" "*" - is-regex@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491" @@ -13185,13 +13126,6 @@ lz-string@^1.4.4: resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26" integrity sha1-wNjq82BZ9wV5bh40SBHPTEmNOiY= -magic-string@^0.25.7: - version "0.25.7" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051" - integrity sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA== - dependencies: - sourcemap-codec "^1.4.4" - make-dir@^2.0.0, make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -16993,14 +16927,6 @@ resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.17 is-core-module "^2.1.0" path-parse "^1.0.6" -resolve@^1.19.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== - dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" - responselike@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" @@ -17709,11 +17635,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== -sourcemap-codec@^1.4.4: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - space-separated-tokens@^1.0.0: version "1.1.5" resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz#85f32c3d10d9682007e917414ddc5c26d1aa6899" From 99466dfb947d95e16053e32ba62bd3da70ece0d2 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 17:49:38 +0000 Subject: [PATCH 10/11] use typescript in rollup --- rollup.config.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index be62c834..f61d4d5b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,12 +1,8 @@ import pkg from './package.json'; -import { babel } from '@rollup/plugin-babel'; -import resolve from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; +import typescript from '@rollup/plugin-typescript'; import clear from 'rollup-plugin-clear'; import visualizer from 'rollup-plugin-visualizer'; -const extensions = ['.ts', '.tsx']; - module.exports = { input: './src/App.tsx', output: [ @@ -33,11 +29,7 @@ module.exports = { clear({ targets: ['build/'], }), - babel({ - extensions, - }), - resolve({ extensions }), - commonjs(), + typescript(), visualizer({ filename: 'build/stats.html' }), ], }; From b0c2a6cbf362cec5b989c75901930506513c5a63 Mon Sep 17 00:00:00 2001 From: William Lacroix Date: Tue, 2 Mar 2021 18:05:13 +0000 Subject: [PATCH 11/11] remove emitDeclarationOnly from tsconfig to fix storybook --- package.json | 2 +- rollup.config.js | 4 +++- tsconfig.json | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index b45bce01..925c992b 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "start": "react-app-rewired start", "build": "rollup --config && yarn tsc", "test": "jest", - "tsc": "tsc", + "tsc": "tsc --emitDeclarationOnly true", "validate": "yarn tsc && yarn test --watchAll=false && yarn lint", "eject": "react-scripts eject", "prettier:check": "prettier . --check", diff --git a/rollup.config.js b/rollup.config.js index f61d4d5b..b7db8814 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -29,7 +29,9 @@ module.exports = { clear({ targets: ['build/'], }), - typescript(), + typescript({ + emitDeclarationOnly: true + }), visualizer({ filename: 'build/stats.html' }), ], }; diff --git a/tsconfig.json b/tsconfig.json index 01b6e35f..34a511b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "module": "esnext", "lib": ["es2017", "es7", "es6", "dom", "DOM.Iterable"], "outDir": "build", - "emitDeclarationOnly": true, "rootDir": "src", "declaration": true, "strict": true,