-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiIcon] Upgrade svgr
/svgo
dependencies to latest
#6843
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
const glob = require('glob'); | ||
const svgr = require('@svgr/core').default; | ||
const svgr = require('@svgr/core').transform; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const license = require('../.eslintrc.js').rules[ | ||
'local/require-license-header' | ||
][1].license; | ||
const license = | ||
require('../.eslintrc.js').rules['local/require-license-header'][1].license; | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was Prettier autolinting this file on save |
||
|
||
const rootDir = path.resolve(__dirname, '..'); | ||
const srcDir = path.resolve(rootDir, 'src'); | ||
|
@@ -37,10 +36,15 @@ iconFiles.forEach((filePath) => { | |
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'], | ||
svgoConfig: { | ||
plugins: [ | ||
{ cleanupIDs: true }, | ||
{ prefixIds: false }, | ||
{ removeViewBox: false }, | ||
{ removeUselessStrokeAndFill: false }, | ||
{ | ||
name: 'preset-default', | ||
params: { | ||
overrides: { | ||
removeViewBox: false, | ||
removeUselessStrokeAndFill: false, | ||
}, | ||
}, | ||
}, | ||
Comment on lines
37
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see https://github.com/svg/svgo/releases/tag/v2.0.0 config changes. Also see SVGO's default preset docs and their plugins table - |
||
], | ||
}, | ||
svgProps: { | ||
|
@@ -49,12 +53,11 @@ iconFiles.forEach((filePath) => { | |
titleProp: true, | ||
typescript: true, | ||
template: ( | ||
{ template }, | ||
opts, | ||
{ imports, interfaces, componentName, props, jsx } | ||
{ imports, interfaces, componentName, props, jsx }, | ||
{ tpl } | ||
) => | ||
hasIds | ||
? template.ast` | ||
? tpl` | ||
Comment on lines
55
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
${imports} | ||
import { htmlIdGenerator } from '../../../services'; | ||
${interfaces} | ||
|
@@ -66,7 +69,7 @@ const ${componentName} = (${props}) => { | |
}; | ||
export const icon = ${componentName}; | ||
` | ||
: template.ast` | ||
: tpl` | ||
${imports} | ||
${interfaces} | ||
const ${componentName} = (${props}) => ${jsx} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,16 +9,16 @@ | |
// THIS IS A GENERATED FILE. DO NOT MODIFY MANUALLY. @see scripts/compile-icons.js | ||
|
||
import * as React from 'react'; | ||
import type { SVGProps } from 'react'; | ||
interface SVGRProps { | ||
title?: string; | ||
titleId?: string; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this note for my own edification - the newline removal actually doesn't have anything to do with this upgrade/PR or with the recent Node v18 upgrade. It occurred due to our recent babel upgrades, and is a known issue: gregberge/svgr#809 Since this doesn't affect any actual consumer or user experience due to it being generated code, I think we can safely ignore it for now. |
||
const EuiIconAccessibility = ({ | ||
title, | ||
titleId, | ||
...props | ||
}: React.SVGProps<SVGSVGElement> & SVGRProps) => ( | ||
}: SVGProps<SVGSVGElement> & SVGRProps) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={16} | ||
|
@@ -28,8 +28,7 @@ const EuiIconAccessibility = ({ | |
{...props} | ||
> | ||
{title ? <title id={titleId}>{title}</title> : null} | ||
<path d="M8 0a8 8 0 110 16A8 8 0 018 0zm0 1a7 7 0 100 14A7 7 0 008 1zm3.974 4.342a.5.5 0 01-.233.596l-.083.036L9 6.86v2.559l.974 2.923a.5.5 0 01-.233.596l-.083.036a.5.5 0 01-.596-.233l-.036-.083-1-3L8 9.5l-.026.158-1 3a.5.5 0 01-.97-.228l.022-.088L7 9.416V6.86l-2.658-.886a.5.5 0 01.228-.97l.088.022L7.583 6h.833l2.926-.974a.5.5 0 01.632.316zM8 3a1 1 0 110 2 1 1 0 010-2z" /> | ||
<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0Zm0 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm3.974 4.342a.5.5 0 0 1-.233.596l-.083.036L9 6.86v2.559l.974 2.923a.5.5 0 0 1-.233.596l-.083.036a.5.5 0 0 1-.596-.233l-.036-.083-1-3L8 9.5l-.026.158-1 3a.5.5 0 0 1-.97-.228l.022-.088L7 9.416V6.86l-2.658-.886a.5.5 0 0 1 .228-.97l.088.022L7.583 6h.833l2.926-.974a.5.5 0 0 1 .632.316ZM8 3a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z" /> | ||
</svg> | ||
); | ||
|
||
export const icon = EuiIconAccessibility; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
@svgr/plugin-jsx
dependency needs to be manually listed now as it's no longer bundled in@svgr/core
as of https://github.com/gregberge/svgr/releases/tag/v7.0.0