feedback icon indicating copy to clipboard operation
feedback copied to clipboard

Use govuk-frontend v5

Open patrickpatrickpatrick opened this issue 1 year ago • 1 comments

Trello

What

  • Replace Uglifier with Terser, add patch which adds Sprockets support for Terser
  • Move components that rely on govuk-frontend modules to separate es6-components.js file

Why

govuk_publishing_components uses v5 of govuk-frontend. There are several breaking changes in this release and so we need to update the applications that use govuk_publishing_components. Please read what has changed in govuk_publishing_components and govuk-frontend. This specific changes this PR addresses are:

  • Replace Uglifier with Terser, add patch which adds Sprockets support for Terser
    • govuk-frontend v5 UMD component JS uses ES6 features which aren't supported by Uglifier, so we have to make the change to use Terser instead
    • Sprockets doesn't support Terser by default, need to add in a patch which adds Terser to list of supported JS compressors
  • Move components that rely on govuk-frontend modules to seperate es6-components.js file
    • In the event that a browser below the target for govuk-frontend loads a page with JS on it, attempting to parse the JS from govuk-frontend will cause an error. To avoid this from happening, JS that contains govuk-frontend JS has been moved to seperate file which will be loaded in a script tag with type="module". This will prevent the JS from being parsed and so prevent the error

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

patrickpatrickpatrick avatar Nov 28 '23 14:11 patrickpatrickpatrick