Skip to content
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

Bump svgo to ^3.0.2 #38231

Merged
merged 2 commits into from Aug 31, 2023
Merged

Bump svgo to ^3.0.2 #38231

merged 2 commits into from Aug 31, 2023

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jul 30, 2023

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
svgo ^2.8.0 -> ^3.0.2 age adoption passing confidence

Release Notes

svg/svgo (svgo)

v3.0.2

Compare Source

Installing @types/csso no longer required

v3.0.1

Compare Source

  • store exposed types only in .d.ts files, no longer need to enable js checking
  • update svgo.browser.js
  • fixed "begin" attribute cleanup

Thanks to @​Kreeg, @​XhmikosR and @​TrySound

v3.0.0

Compare Source

SVGO v3

Improvements and fixes

  • fixed datauri option when multipass is not enabled
  • improved default preset warnings

Breaking channges

  • Node.js 14+ is required for version
  • stable package is replaced with native stable sort (required node 12+)
Config

Typescript types are exposed out of the box. No longer need to install @types/svgo

// svgo.config.js
/**
 * @​type {import('svgo').Config}
 */
export default {
  // svgo configuration
}

Active flag is no longer supported

export default {
  plugins: [
    {
      name: 'removeDoctype',
      active: true
    },
    {
      name: 'removeComments',
      active: false
    }
  ]
}

extendDefaultPlugins is removed, preset-default plugin should be used instead
when need to customize plugins defaults

export default {
  plugins: [
    {
      name: 'preset-default',
      params: {
        overrides: {
          // plugins customization
        }
      }
    }
  ]
}

Enabled sortAttrs plugin by default to get better gzip compression.

<svg>
-  <rect fill-opacity="" stroke="" fill="" stroke-opacity="" />
+  <rect fill="" fill-opacity="" stroke="" stroke-opacity="" />
</svg>

Can be disabled if necessary

export default {
  plugins: [
    {
      name: 'preset-default',
      params: {
        overrides: {
          sortAttrs: false
        }
      }
    }
  ]
}

cleanupIDs plugin is renamed to cleanupIds

export default {
  plugins: [
    'cleanupIds'
  ]
}
// or
export default {
  plugins: [
    {
      name: 'preset-default',
      params: {
        overrides: {
          cleanupIds: {}
        }
      }
    }
  ]
}

Removed cleanupIds plugin "prefix" param, prefixIds should be used instead

export default {
  plugins: [
    'cleanupIds',
    {
      name: 'prefixIds',
      params: {
        prefix: 'my-prefix'
      }
    }
  ]
}
Public API

Removed width and height from optimization result.

const { width, height } = optimize(svg).info

Can be found with custom plugin

let width = null
let height = null
const plugin = {
  name: 'find-size',
  fn: () => {
    return {
      element: {
        enter: (node, parentNode) => {
          if (parentNode.type === 'root') {
            width = node.attributes.width
            height = node.attributes.height
          }
        }
      }
    }
  }
}
optimize(svg, {
  plugins: ['preset-default', plugin]
})

Removed error and modernError from optimization result

const {data, error, modernError } = optimize(svg)

Now all errors are thrown, parsing error can be checked by name

try {
  const { data } = optimize(svg)
} catch (error) {
  if (error.name === 'SvgoParserError') {
    // formatted error
    error.toString()
  } else {
    // runtime error
  }
}
Custom plugins

Removed full, perItem and perItemReverse plugin types.
visitor is the only supported plugin api so plugin.type
is no longer required.

Removed plugin.active flag.

Removed plugin.params used as default params, destructuring with defaults can be used instead

name and fn are only required now

const plugin = {
  name: 'my-custom-plugin',
  fn: (root, params) => {
    const { myParam = true } = params
    return {}
  }
}

Removed createContentItem and JSAPI class from nodes.
All nodes are now plain objects with one exception.
parentNode need to be defined to not break builtin plugins.

const plugin = {
  name: 'my-custom-plugin',
  fn: () => {
    return {
      element: {
        enter: (node) => {
          if (node === 'g') {
            const child = {
              type: 'element',
              name: 'g',
              attributes: {},
              children: []
            }
            Object.defineProperty(child, 'parentNode', {
              writable: true,
              value: node,
            })
            node.children.push(child)
          }
        }
      }
    }
  }
}

Thanks to @​istarkov, @​boidolr, @​deining, @​ranman, @​mondeja, @​liamcmitchell-sc, @​rogierslag, @​kriskowal, @​hugolpz and @​TrySound


Configuration

📅 Schedule: Branch creation - "on sunday before 6:00am" in timezone UTC, Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added the dependencies Update of dependencies label Jul 30, 2023
@mui-bot
Copy link

mui-bot commented Jul 30, 2023

Netlify deploy preview

https://deploy-preview-38231--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against acb69a6

@michaldudak
Copy link
Member

I had to change the icon builder script to adapt to the changes in SVGO v3.
@siriwatknp, I'd appreciate a second pair of eyes here.

@renovate
Copy link
Contributor Author

renovate bot commented Aug 8, 2023

Edited/Blocked Notification

Renovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR.

You can manually request rebase by checking the rebase/retry box above.

Warning: custom changes will be lost.

@adaptly-bot

This comment was marked as abuse.

@michaldudak michaldudak merged commit ffa4751 into master Aug 31, 2023
18 checks passed
@michaldudak michaldudak deleted the renovate/svgo-3.x branch August 31, 2023 10:21
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 8, 2023
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michał Dudak <michal@mui.com>
mnajdova pushed a commit to mnajdova/material-ui that referenced this pull request Sep 8, 2023
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michał Dudak <michal@mui.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Update of dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants