-
Notifications
You must be signed in to change notification settings - Fork 241
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
Conversation
✅ You can preview this change here:
To edit notification comments on pull requests, go to your Netlify site settings. |
3d8656b
to
874dc19
Compare
@@ -1,10 +1,8 @@ | |||
import common from 'govuk-frontend/govuk/common' | |||
import { nodeListForEach } from './components/helpers.js' |
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.
👍
// 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' |
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.
🔥
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.
This is awesome 👏
I've rebased this to get rid of the pre-release commit, so I think this can be merged once the tests pass. |
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.
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 andinitAll()
Note: this PR is based on a pre-release, and will need to be updated/that commit removed before merging