From d4f69a2d6667199745838662755a95a49060d1bc Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Fri, 5 May 2023 23:33:43 +0200 Subject: [PATCH 1/3] :hammer: [#34] -- Fix rewriting ts config path aliases in build --- package.json | 5 +++-- yarn.lock | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 290e2dd..812efb2 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "./esm/": "./dist/esm/" }, "scripts": { - "build:esm": "tsc", - "build:cjs": "tsc --module commonjs --outDir dist/cjs", + "build:esm": "tsc && tsc-alias", + "build:cjs": "tsc --module commonjs --outDir dist/cjs && tsc-alias --outDir dist/cjs", "build:storybook": "build-storybook --webpack-stats-json", "build": "npm-run-all build:*", "test": "run-s test:lint", @@ -75,6 +75,7 @@ "prettier": "^2.8.7", "react": "^17.0.2", "react-dom": "^17.0.2", + "tsc-alias": "^1.8.6", "tsconfig-paths-webpack-plugin": "^4.0.1", "typescript": "^4.9.5" }, diff --git a/yarn.lock b/yarn.lock index 3c2c0d7..2d3ac2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4317,7 +4317,7 @@ chokidar@^2.1.8: optionalDependencies: fsevents "^1.2.7" -chokidar@^3.4.1, chokidar@^3.4.2: +chokidar@^3.4.1, chokidar@^3.4.2, chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -4532,6 +4532,11 @@ commander@^8.3.0: resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== +commander@^9.0.0: + version "9.5.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" + integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== + common-path-prefix@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0" @@ -6486,7 +6491,7 @@ globalthis@^1.0.0, globalthis@^1.0.3: dependencies: define-properties "^1.1.3" -globby@^11.0.2, globby@^11.1.0: +globby@^11.0.2, globby@^11.0.4, globby@^11.1.0: version "11.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== @@ -8315,6 +8320,11 @@ mute-stream@0.0.8: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== +mylas@^2.1.9: + version "2.1.13" + resolved "https://registry.yarnpkg.com/mylas/-/mylas-2.1.13.tgz#1e23b37d58fdcc76e15d8a5ed23f9ae9fc0cbdf4" + integrity sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg== + nan@^2.12.1: version "2.17.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" @@ -9056,6 +9066,13 @@ pkg-dir@^5.0.0: dependencies: find-up "^5.0.0" +plimit-lit@^1.2.6: + version "1.5.0" + resolved "https://registry.yarnpkg.com/plimit-lit/-/plimit-lit-1.5.0.tgz#f66df8a7041de1e965c4f1c0697ab486968a92a5" + integrity sha512-Eb/MqCb1Iv/ok4m1FqIXqvUKPISufcjZ605hl3KM/n8GaX8zfhtgdLwZU3vKjuHGh2O9Rjog/bHTq8ofIShdng== + dependencies: + queue-lit "^1.5.0" + pnp-webpack-plugin@1.6.4: version "1.6.4" resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.6.4.tgz#c9711ac4dc48a685dabafc86f8b6dd9f8df84149" @@ -9404,6 +9421,11 @@ querystring@0.2.0: resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g== +queue-lit@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/queue-lit/-/queue-lit-1.5.0.tgz#8197fdafda1edd615c8a0fc14c48353626e5160a" + integrity sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA== + queue-microtask@^1.2.2: version "1.2.3" resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" @@ -10967,6 +10989,18 @@ ts-pnp@^1.1.6: resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92" integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw== +tsc-alias@^1.8.6: + version "1.8.6" + resolved "https://registry.yarnpkg.com/tsc-alias/-/tsc-alias-1.8.6.tgz#28300ed398e90b1c600548ed956f58dfbecc1589" + integrity sha512-vq+i6VpE83IeMsSJVcFN03ZBofADhr8/gIJXjxpbnTRfN/MFXy0+SBaKG2o7p95QqXBGkeG98HYz3IkOOveFbg== + dependencies: + chokidar "^3.5.3" + commander "^9.0.0" + globby "^11.0.4" + mylas "^2.1.9" + normalize-path "^3.0.0" + plimit-lit "^1.2.6" + tsconfig-paths-webpack-plugin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.0.1.tgz#a24651d0f69668a1abad38d3c2489855c257460d" From dc05f595d1eaafbd6e2b5abf0f90c6ea892c1c86 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Fri, 5 May 2023 23:35:21 +0200 Subject: [PATCH 2/3] :hammer: [#34] -- Configure typescript to emit modern JS ES8 is supported by the bulk of the browsers nowadays. --- src/lib/renderer/renderer.stories.tsx | 1 - tsconfig.json | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/renderer/renderer.stories.tsx b/src/lib/renderer/renderer.stories.tsx index 57a1f80..c7b77fa 100644 --- a/src/lib/renderer/renderer.stories.tsx +++ b/src/lib/renderer/renderer.stories.tsx @@ -4,7 +4,6 @@ import {expect} from '@storybook/jest'; import type {ComponentStory, Meta} from '@storybook/react'; import {userEvent, within} from '@storybook/testing-library'; import {Formik} from 'formik'; -import React from 'react'; const meta: Meta = { title: 'Usage / Renderer', diff --git a/tsconfig.json b/tsconfig.json index fbd8088..471b5b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,9 @@ "baseUrl": "./", "outDir": "dist/esm", "module": "esnext", - "target": "es6", - "lib": ["es6", "dom", "es2016", "es2017"], - "jsx": "react", + "target": "es2017", + "lib": ["dom"], + "jsx": "react-jsx", "declaration": true, "moduleResolution": "node", "noUnusedLocals": true, From ed0a712e40eedc7617f0d375de82cde5ca968586 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 11 May 2023 15:21:43 +0200 Subject: [PATCH 3/3] :hammer: [#34] -- control what gets built into the package * Do not ship storybook stories modules * Do not ship tests/** modules --- package.json | 4 ++-- tsconfig.prod.json | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 tsconfig.prod.json diff --git a/package.json b/package.json index 812efb2..8754d24 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "./esm/": "./dist/esm/" }, "scripts": { - "build:esm": "tsc && tsc-alias", - "build:cjs": "tsc --module commonjs --outDir dist/cjs && tsc-alias --outDir dist/cjs", + "build:esm": "tsc -p tsconfig.prod.json && tsc-alias -p tsconfig.prod.json", + "build:cjs": "tsc -p tsconfig.prod.json --module commonjs --outDir dist/cjs && tsc-alias -p tsconfig.prod.json --outDir dist/cjs", "build:storybook": "build-storybook --webpack-stats-json", "build": "npm-run-all build:*", "test": "run-s test:lint", diff --git a/tsconfig.prod.json b/tsconfig.prod.json new file mode 100644 index 0000000..26f0c35 --- /dev/null +++ b/tsconfig.prod.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig", + "exclude": ["node_modules", "dist", "**/*.stories.*", "src/tests", "src/fixtures"] +}