-
Notifications
You must be signed in to change notification settings - Fork 17
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
Use govuk-frontend v5 #2989
Use govuk-frontend v5 #2989
Conversation
00fbcac
to
c8b446d
Compare
c8b446d
to
a193195
Compare
a193195
to
fd85855
Compare
9016f95
to
9dc9a2a
Compare
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
9dc9a2a
to
befbd14
Compare
65d938c
to
343ec30
Compare
343ec30
to
e8eba12
Compare
In govuk-frontend v5, the `init` function is now called when a module is created. This meant changing how the `initAll()` function works in govuk_publishing_components so that it does not call `init()` when initialising components JavaScript. It also meant moving `init` functions in components to the constructor to bring them in line with the new way of initialising.
govuk_publishing_components has govuk-frontend as a dependency. govuk-frontend v5 now targets browsers that support ES6. This means that the UMD modules used in govuk_publsihing_components from govuk-frontend use features of ES6 and so it means that Uglifier can't be used anymore because it only supports ES5. As well as installing terser and updating the config, this commit also contains a patch for getting terser working. Sprockets doesn't have an built-in loader for terser so we need to add this functionality.
To prevent browsers evaluating JS that isn't supported, components that contain code from govuk-frontend have been moved to a separate file `es6-components.js` which is included in `application.html.erb` as a script tag with `type="module"`.
e8eba12
to
9b96d8f
Compare
Closing as we now have a new branch to upgrade to 5.1.0 - #3206 |
Trello
What
es6-components.js
fileWhy
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:
es6-components.js
filegovuk-frontend
loads a page with JS on it, attempting to parse the JS fromgovuk-frontend
will cause an error. To avoid this from happening, JS that containsgovuk-frontend
JS has been moved to seperate file which will be loaded in a script tag withtype="module"
. This will prevent the JS from being parsed and so prevent the error$legacy
attribute ingovuk-colour
has been deprecated and using it will have no effect (other than generating warnings on pre-compilation)$govuk-compatibility-govuktemplate
has been removed and using it will have no effect$govuk-new-link-styles
does not need to be setFollow these steps if you are doing a Rails upgrade.