From f9f566f1c1f86c6c72047a9794d2fde19e5c80a6 Mon Sep 17 00:00:00 2001 From: Wenche Tollevsen Date: Tue, 25 Aug 2020 13:34:28 +0200 Subject: [PATCH] Typescript support in icons package (#514) * Fix tsconfig for tokens package. Didn't realise that this was missing... * Add typescript and typescript config * Rename index.js -> index.ts * Rename file endings for icons in figma broker --- apps/figma-broker/actions/createAssets.js | 2 +- libraries/icons/{index.js => index.ts} | 0 libraries/icons/package.json | 4 +- libraries/icons/pnpm-lock.yaml | 136 ++++++++++++++++++++++ libraries/icons/rollup.config.js | 13 ++- libraries/icons/tsconfig.json | 18 +++ libraries/tokens/package.json | 1 + libraries/tokens/pnpm-lock.yaml | 127 ++++++++++++++++++++ libraries/tokens/rollup.config.js | 13 ++- libraries/tokens/tsconfig.json | 18 +++ 10 files changed, 326 insertions(+), 6 deletions(-) rename libraries/icons/{index.js => index.ts} (100%) create mode 100644 libraries/icons/tsconfig.json create mode 100644 libraries/tokens/tsconfig.json diff --git a/apps/figma-broker/actions/createAssets.js b/apps/figma-broker/actions/createAssets.js index 3b1373ecb5..41c3931f7a 100644 --- a/apps/figma-broker/actions/createAssets.js +++ b/apps/figma-broker/actions/createAssets.js @@ -76,7 +76,7 @@ export const ${name} = { R.head, )(assets) - writeFile(PATHS.ICON_FILES, 'index', 'js', jsFile) + writeFile(PATHS.ICON_FILES, 'index', 'ts', jsFile) } const writeJsonAssets = (assets) => { diff --git a/libraries/icons/index.js b/libraries/icons/index.ts similarity index 100% rename from libraries/icons/index.js rename to libraries/icons/index.ts diff --git a/libraries/icons/package.json b/libraries/icons/package.json index 4a8f11365f..d503762150 100644 --- a/libraries/icons/package.json +++ b/libraries/icons/package.json @@ -37,7 +37,9 @@ ], "devDependencies": { "@rollup/plugin-node-resolve": "^8.0.1", - "rollup": "^2.15.0" + "rollup": "^2.15.0", + "rollup-plugin-typescript2": "^0.27.2", + "typescript": "^4.0.2" }, "engines": { "pnpm": ">=4", diff --git a/libraries/icons/pnpm-lock.yaml b/libraries/icons/pnpm-lock.yaml index 623c92e6ee..6508d75b82 100644 --- a/libraries/icons/pnpm-lock.yaml +++ b/libraries/icons/pnpm-lock.yaml @@ -1,6 +1,8 @@ devDependencies: '@rollup/plugin-node-resolve': 8.0.1_rollup@2.15.0 rollup: 2.15.0 + rollup-plugin-typescript2: 0.27.2_rollup@2.15.0+typescript@4.0.2 + typescript: 4.0.2 lockfileVersion: 5.1 packages: /@rollup/plugin-node-resolve/8.0.1_rollup@2.15.0: @@ -53,6 +55,10 @@ packages: node: '>=6' resolution: integrity: sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== + /commondir/1.0.1: + dev: true + resolution: + integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= /deep-freeze/0.0.1: dev: true resolution: @@ -67,6 +73,35 @@ packages: dev: true resolution: integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + /find-cache-dir/3.3.1: + dependencies: + commondir: 1.0.1 + make-dir: 3.1.0 + pkg-dir: 4.2.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== + /find-up/4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + /fs-extra/8.1.0: + dependencies: + graceful-fs: 4.2.4 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: true + engines: + node: '>=6 <7 || >=8' + resolution: + integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== /fsevents/2.1.3: dev: true engines: @@ -76,10 +111,64 @@ packages: - darwin resolution: integrity: sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + /graceful-fs/4.2.4: + dev: true + resolution: + integrity: sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== /is-module/1.0.0: dev: true resolution: integrity: sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= + /jsonfile/4.0.0: + dev: true + optionalDependencies: + graceful-fs: 4.2.4 + resolution: + integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + /locate-path/5.0.0: + dependencies: + p-locate: 4.1.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + /make-dir/3.1.0: + dependencies: + semver: 6.3.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== + /p-limit/2.3.0: + dependencies: + p-try: 2.2.0 + dev: true + engines: + node: '>=6' + resolution: + integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + /p-locate/4.1.0: + dependencies: + p-limit: 2.3.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + /p-try/2.2.0: + dev: true + engines: + node: '>=6' + resolution: + integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + /path-exists/4.0.0: + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== /path-parse/1.0.6: dev: true resolution: @@ -90,12 +179,35 @@ packages: node: '>=8.6' resolution: integrity: sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + /pkg-dir/4.2.0: + dependencies: + find-up: 4.1.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== /resolve/1.17.0: dependencies: path-parse: 1.0.6 dev: true resolution: integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + /rollup-plugin-typescript2/0.27.2_rollup@2.15.0+typescript@4.0.2: + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.15.0 + find-cache-dir: 3.3.1 + fs-extra: 8.1.0 + resolve: 1.17.0 + rollup: 2.15.0 + tslib: 2.0.1 + typescript: 4.0.2 + dev: true + peerDependencies: + rollup: '>=1.26.3' + typescript: '>=2.4.0' + resolution: + integrity: sha512-zarMH2F8oT/NO6p20gl/jkts+WxyzOlhOIUwUU/EDx5e6ewdDPS/flwLj5XFuijUCr64bZwqKuRVwCPdXXYefQ== /rollup/2.15.0: dev: true engines: @@ -105,6 +217,30 @@ packages: fsevents: 2.1.3 resolution: integrity: sha512-HAk4kyXiV5sdNDnbKWk5zBPnkX/DAgx09Kbp8rRIRDVsTUVN3vnSowR7ZHkV6/lAiE6c2TQ8HtYb72aCPGW4Jw== + /semver/6.3.0: + dev: true + hasBin: true + resolution: + integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + /tslib/2.0.1: + dev: true + resolution: + integrity: sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== + /typescript/4.0.2: + dev: true + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== + /universalify/0.1.2: + dev: true + engines: + node: '>= 4.0.0' + resolution: + integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== specifiers: '@rollup/plugin-node-resolve': ^8.0.1 rollup: ^2.15.0 + rollup-plugin-typescript2: ^0.27.2 + typescript: ^4.0.2 diff --git a/libraries/icons/rollup.config.js b/libraries/icons/rollup.config.js index 8a5ac21077..89cfd55d1f 100644 --- a/libraries/icons/rollup.config.js +++ b/libraries/icons/rollup.config.js @@ -1,15 +1,24 @@ import resolve from '@rollup/plugin-node-resolve' import pkg from './package.json' +import typescript from 'rollup-plugin-typescript2' import commonjsPkg from './commonjs/package.json' // eslint-disable-next-line import/no-default-export export default [ { - input: 'index.js', + input: 'index.ts', watch: { clearScreen: true, }, - plugins: [resolve()], + plugins: [ + resolve(), + typescript({ + tsconfig: 'tsconfig.json', + typescript: require('typescript'), + include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.js+(|x)', '**/*.js+(|x)'], + exclude: ['node_modules/**'], + }), + ], output: [ { file: pkg.module, diff --git a/libraries/icons/tsconfig.json b/libraries/icons/tsconfig.json new file mode 100644 index 0000000000..f6a6377c6f --- /dev/null +++ b/libraries/icons/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "esnext", + "lib": ["dom", "es2015"], + "moduleResolution": "node", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "sourceMap": false, + "allowJs": true, + "checkJs": true, + "noEmit": true, + "jsx": "react" + }, + "include": ["index.ts"], + "exclude": ["node_modules"] +} diff --git a/libraries/tokens/package.json b/libraries/tokens/package.json index 36bfe445a2..5a74fbe3f1 100644 --- a/libraries/tokens/package.json +++ b/libraries/tokens/package.json @@ -38,6 +38,7 @@ "devDependencies": { "@rollup/plugin-node-resolve": "^8.0.1", "rollup": "^2.15.0", + "rollup-plugin-typescript2": "^0.27.2", "typescript": "^4.0.2" }, "engines": { diff --git a/libraries/tokens/pnpm-lock.yaml b/libraries/tokens/pnpm-lock.yaml index d5d3f2d2ec..6508d75b82 100644 --- a/libraries/tokens/pnpm-lock.yaml +++ b/libraries/tokens/pnpm-lock.yaml @@ -1,6 +1,7 @@ devDependencies: '@rollup/plugin-node-resolve': 8.0.1_rollup@2.15.0 rollup: 2.15.0 + rollup-plugin-typescript2: 0.27.2_rollup@2.15.0+typescript@4.0.2 typescript: 4.0.2 lockfileVersion: 5.1 packages: @@ -54,6 +55,10 @@ packages: node: '>=6' resolution: integrity: sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw== + /commondir/1.0.1: + dev: true + resolution: + integrity: sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= /deep-freeze/0.0.1: dev: true resolution: @@ -68,6 +73,35 @@ packages: dev: true resolution: integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + /find-cache-dir/3.3.1: + dependencies: + commondir: 1.0.1 + make-dir: 3.1.0 + pkg-dir: 4.2.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ== + /find-up/4.1.0: + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + /fs-extra/8.1.0: + dependencies: + graceful-fs: 4.2.4 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: true + engines: + node: '>=6 <7 || >=8' + resolution: + integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== /fsevents/2.1.3: dev: true engines: @@ -77,10 +111,64 @@ packages: - darwin resolution: integrity: sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + /graceful-fs/4.2.4: + dev: true + resolution: + integrity: sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== /is-module/1.0.0: dev: true resolution: integrity: sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= + /jsonfile/4.0.0: + dev: true + optionalDependencies: + graceful-fs: 4.2.4 + resolution: + integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + /locate-path/5.0.0: + dependencies: + p-locate: 4.1.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + /make-dir/3.1.0: + dependencies: + semver: 6.3.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== + /p-limit/2.3.0: + dependencies: + p-try: 2.2.0 + dev: true + engines: + node: '>=6' + resolution: + integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + /p-locate/4.1.0: + dependencies: + p-limit: 2.3.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + /p-try/2.2.0: + dev: true + engines: + node: '>=6' + resolution: + integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + /path-exists/4.0.0: + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== /path-parse/1.0.6: dev: true resolution: @@ -91,12 +179,35 @@ packages: node: '>=8.6' resolution: integrity: sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== + /pkg-dir/4.2.0: + dependencies: + find-up: 4.1.0 + dev: true + engines: + node: '>=8' + resolution: + integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== /resolve/1.17.0: dependencies: path-parse: 1.0.6 dev: true resolution: integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + /rollup-plugin-typescript2/0.27.2_rollup@2.15.0+typescript@4.0.2: + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.15.0 + find-cache-dir: 3.3.1 + fs-extra: 8.1.0 + resolve: 1.17.0 + rollup: 2.15.0 + tslib: 2.0.1 + typescript: 4.0.2 + dev: true + peerDependencies: + rollup: '>=1.26.3' + typescript: '>=2.4.0' + resolution: + integrity: sha512-zarMH2F8oT/NO6p20gl/jkts+WxyzOlhOIUwUU/EDx5e6ewdDPS/flwLj5XFuijUCr64bZwqKuRVwCPdXXYefQ== /rollup/2.15.0: dev: true engines: @@ -106,6 +217,15 @@ packages: fsevents: 2.1.3 resolution: integrity: sha512-HAk4kyXiV5sdNDnbKWk5zBPnkX/DAgx09Kbp8rRIRDVsTUVN3vnSowR7ZHkV6/lAiE6c2TQ8HtYb72aCPGW4Jw== + /semver/6.3.0: + dev: true + hasBin: true + resolution: + integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + /tslib/2.0.1: + dev: true + resolution: + integrity: sha512-SgIkNheinmEBgx1IUNirK0TUD4X9yjjBRTqqjggWCU3pUEqIk3/Uwl3yRixYKT6WjQuGiwDv4NomL3wqRCj+CQ== /typescript/4.0.2: dev: true engines: @@ -113,7 +233,14 @@ packages: hasBin: true resolution: integrity: sha512-e4ERvRV2wb+rRZ/IQeb3jm2VxBsirQLpQhdxplZ2MEzGvDkkMmPglecnNDfSUBivMjP93vRbngYYDQqQ/78bcQ== + /universalify/0.1.2: + dev: true + engines: + node: '>= 4.0.0' + resolution: + integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== specifiers: '@rollup/plugin-node-resolve': ^8.0.1 rollup: ^2.15.0 + rollup-plugin-typescript2: ^0.27.2 typescript: ^4.0.2 diff --git a/libraries/tokens/rollup.config.js b/libraries/tokens/rollup.config.js index 8a5ac21077..8ac4774e98 100644 --- a/libraries/tokens/rollup.config.js +++ b/libraries/tokens/rollup.config.js @@ -1,15 +1,24 @@ import resolve from '@rollup/plugin-node-resolve' +import typescript from 'rollup-plugin-typescript2' import pkg from './package.json' import commonjsPkg from './commonjs/package.json' // eslint-disable-next-line import/no-default-export export default [ { - input: 'index.js', + input: 'index.ts', watch: { clearScreen: true, }, - plugins: [resolve()], + plugins: [ + resolve(), + typescript({ + tsconfig: 'tsconfig.json', + typescript: require('typescript'), + include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.js+(|x)', '**/*.js+(|x)'], + exclude: ['node_modules/**'], + }), + ], output: [ { file: pkg.module, diff --git a/libraries/tokens/tsconfig.json b/libraries/tokens/tsconfig.json new file mode 100644 index 0000000000..088755e571 --- /dev/null +++ b/libraries/tokens/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "esnext", + "lib": ["dom", "es2015"], + "moduleResolution": "node", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "sourceMap": false, + "allowJs": true, + "checkJs": true, + "noEmit": true, + "jsx": "react" + }, + "include": ["index.ts"], + "exclude": ["node_modules", "**/*.test.jsx"] +}