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

Use ESM modules from GOV.UK Frontend #2146

Merged
merged 2 commits into from
May 18, 2022
Merged

Use ESM modules from GOV.UK Frontend #2146

merged 2 commits into from
May 18, 2022

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented Apr 21, 2022

What

Update the Design System website to use the GOV.UK Frontend ES modules when they're published (added in alphagov/govuk-frontend#711 )

Why

We don't do any custom initialising of component JavaScript any more, so we can replace the code in govuk-frontend.js with an import and initAll()

Note: this PR is based on a pre-release, and will need to be updated/that commit removed before merging

@netlify
Copy link

netlify bot commented Apr 21, 2022

You can preview this change here:

Name Link
🔨 Latest commit 48fc4d0
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/6284e4283d4f4200089dc805
😎 Deploy Preview https://deploy-preview-2146--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@vanitabarrett vanitabarrett added this to the [NEXT] milestone Apr 21, 2022
@vanitabarrett vanitabarrett added javascript Pull requests that update Javascript code website Issues relating to the Design System website itself labels Apr 21, 2022
@vanitabarrett vanitabarrett requested a review from a team April 21, 2022 13:22
@vanitabarrett vanitabarrett force-pushed the use-esm branch 2 times, most recently from 3d8656b to 874dc19 Compare April 21, 2022 15:04
@@ -1,10 +1,8 @@
import common from 'govuk-frontend/govuk/common'
import { nodeListForEach } from './components/helpers.js'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// Find first skip link module to enhance.
var $skipLink = document.querySelector('[data-module="govuk-skip-link"]')
new SkipLink($skipLink).init()
import { initAll } from 'govuk-frontend'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Copy link
Contributor

@domoscargin domoscargin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👏

@36degrees
Copy link
Contributor

I've rebased this to get rid of the pre-release commit, so I think this can be merged once the tests pass.

Vanita Barrett added 2 commits May 18, 2022 13:18
The GOV.UK Frontend ES modules don't make the common (e.g: `nodeListForEach`)
function available to import. We've made this decision intentionally as we never
really intended for `nodeListForEach` to be something we provided.

This introduces a helper.js file which contains `nodeListForEach`. Switch our
JS files to use that helper, rather than the one from GOV.UK Frontend.
@36degrees 36degrees merged commit a67e3c6 into main May 18, 2022
@36degrees 36degrees deleted the use-esm branch May 18, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code website Issues relating to the Design System website itself
Projects
Development

Successfully merging this pull request may close these issues.

3 participants