From 73db5eb35d8ddea4e7b49c9ee85e26d6edc178f4 Mon Sep 17 00:00:00 2001 From: bosiraphael <71827178+bosiraphael@users.noreply.github.com> Date: Fri, 10 Nov 2023 18:25:14 +0100 Subject: [PATCH] fix-svgr-issue-with-tsup (#2429) --- front/package.json | 2 ++ .../ui/display/icon/assets/address-book.svg | 4 +--- front/tsup.config.js | 16 +++++++++++++++- front/tsup.ui.index.tsx | 3 +++ front/yarn.lock | 12 ++++++++++-- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/front/package.json b/front/package.json index 77f9451ab..70bded7aa 100644 --- a/front/package.json +++ b/front/package.json @@ -127,6 +127,7 @@ "@storybook/react-webpack5": "^7.0.22", "@storybook/test-runner": "^0.10.0", "@storybook/testing-library": "^0.1.0", + "@svgr/plugin-jsx": "^8.1.0", "@svgr/webpack": "^8.0.1", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", @@ -151,6 +152,7 @@ "concurrently": "^8.0.1", "cross-var": "^1.1.0", "dotenv-cli": "^7.2.1", + "esbuild-plugin-svgr": "^2.1.0", "eslint": "^8.28.0", "eslint-config-prettier": "^8.5.0", "eslint-config-standard-with-typescript": "^23.0.0", diff --git a/front/src/modules/ui/display/icon/assets/address-book.svg b/front/src/modules/ui/display/icon/assets/address-book.svg index 2f6b55a1a..817890047 100644 --- a/front/src/modules/ui/display/icon/assets/address-book.svg +++ b/front/src/modules/ui/display/icon/assets/address-book.svg @@ -6,6 +6,4 @@ - - - + \ No newline at end of file diff --git a/front/tsup.config.js b/front/tsup.config.js index c8af13ffc..b2531efda 100644 --- a/front/tsup.config.js +++ b/front/tsup.config.js @@ -1,4 +1,5 @@ import { defineConfig } from "tsup"; +import svgr from 'esbuild-plugin-svgr' export default defineConfig([ { @@ -9,5 +10,18 @@ export default defineConfig([ dts: true, clean: true, outDir: "../docs/src/ui/generated", + esbuildPlugins: [svgr({ template })], }, -]); \ No newline at end of file +]); + +function template(variables, { tpl }) { + return tpl` + ${variables.imports}; + ${variables.interfaces}; + const ${variables.componentName} = (${variables.props}) => ( + ${variables.jsx} + ); + ${variables.exports}; + export const ReactComponent = ${variables.componentName}; + `; +}; \ No newline at end of file diff --git a/front/tsup.ui.index.tsx b/front/tsup.ui.index.tsx index 574ce8183..13b5cd0c8 100644 --- a/front/tsup.ui.index.tsx +++ b/front/tsup.ui.index.tsx @@ -10,4 +10,7 @@ declare module '@emotion/react' { } export * from './src/modules/ui/display/checkmark/components/Checkmark'; +export * from './src/modules/ui/display/checkmark/components/AnimatedCheckmark' +export * from './src/modules/ui/display/chip/components/Chip' export * from './src/modules/ui/input/button/components/Button'; +export * from './src/modules/ui/display/icon/components/IconAddressBook'; \ No newline at end of file diff --git a/front/yarn.lock b/front/yarn.lock index 2ec2c71b9..a9b237971 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -4942,7 +4942,7 @@ "@svgr/babel-plugin-transform-react-native-svg" "^5.4.0" "@svgr/babel-plugin-transform-svg-component" "^5.5.0" -"@svgr/core@8.1.0": +"@svgr/core@8.1.0", "@svgr/core@^8.0.0": version "8.1.0" resolved "https://registry.yarnpkg.com/@svgr/core/-/core-8.1.0.tgz#41146f9b40b1a10beaf5cc4f361a16a3c1885e88" integrity sha512-8QqtOQT5ACVlmsvKOJNEaWmRPmcojMOzCz4Hs2BGG/toAp/K38LcsMRyLp349glq5AzJbCEeimEoxaX6v/fLrA== @@ -4977,7 +4977,7 @@ dependencies: "@babel/types" "^7.12.6" -"@svgr/plugin-jsx@8.1.0": +"@svgr/plugin-jsx@8.1.0", "@svgr/plugin-jsx@^8.0.1", "@svgr/plugin-jsx@^8.1.0": version "8.1.0" resolved "https://registry.yarnpkg.com/@svgr/plugin-jsx/-/plugin-jsx-8.1.0.tgz#96969f04a24b58b174ee4cd974c60475acbd6928" integrity sha512-0xiIyBsLlr8quN+WyuxooNW9RJ0Dpr8uOnH/xrCVO8GLUcwHISwj1AG0k+LFzteTkAA0GbX0kj9q6Dk70PTiPA== @@ -9816,6 +9816,14 @@ esbuild-plugin-alias@^0.2.1: resolved "https://registry.yarnpkg.com/esbuild-plugin-alias/-/esbuild-plugin-alias-0.2.1.tgz#45a86cb941e20e7c2bc68a2bea53562172494fcb" integrity sha512-jyfL/pwPqaFXyKnj8lP8iLk6Z0m099uXR45aSN8Av1XD4vhvQutxxPzgA2bTcAwQpa1zCXDcWOlhFgyP3GKqhQ== +esbuild-plugin-svgr@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/esbuild-plugin-svgr/-/esbuild-plugin-svgr-2.1.0.tgz#2257d8bbffd15c7830a0afce7e9163e0a8283bd6" + integrity sha512-BKJOlQvXjLipPDPYfX+N6i2tPxSuVOhlg+hEF/nkQwMwFV6IymvuCRO0wLvf9tGyL3mc3yIZ4n9pfxcCx/7v2Q== + dependencies: + "@svgr/core" "^8.0.0" + "@svgr/plugin-jsx" "^8.0.1" + esbuild-register@^3.4.0: version "3.4.2" resolved "https://registry.yarnpkg.com/esbuild-register/-/esbuild-register-3.4.2.tgz#1e39ee0a77e8f320a9790e68c64c3559620b9175"