-
Notifications
You must be signed in to change notification settings - Fork 38
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
Upgrading to govuk-frontend v5 #352
Comments
A concern I have is us changing the asset pipeline in a way which impacts any JS currently written in various tech docs sites around. If we needed for force a rewrite there is dramatically raises the cost of this as a breaking change. If we did that then this might not even be a breaking change? |
yes do "generate two files: ESM and non-ESM and bundle downstream into the latter" then anyone who currently adds their own javascript into the |
oops forgot to push this earlier I've started a branch here: Tried to address all the initial build issues, but will need some help thinking through the JS from here on out. |
I'll have a look at your branch and try approaches there |
If that's helpful for the update, GOV.UK Frontend also provides unminified UMD modules. While they're not the main route for using GOV.UK Frontend, we have them in for projects whose assets compilation do not necessarily support ESM. The file with all the components is We'd still recommend loading the built script with |
Ah great, I'll take a closer look at that this week - perhaps we can find that time to pair. I'm intrigued from the commit that you say it's working for serve but not for build, So the last task is to ensure that assets unchanged here need to get through the build step? |
the newly created |
exploration using middleman |
We've explored this a bit further with @huwd , summary below ProblemsCompile SassSass files are currently compiled with SassC, which with govuk-frontend v5 that includes source maps, fails to compile styles correctly - only including source maps. This could potentially be resolved by replacing SassC with a Dart Sass conduit for Ruby allowing us to keep the current asset Compile Javascriptgovuk-frontend v5 dropped support for legacy browsers, so the preference when using it is to included as a Current flow is that downstream project has an For govuk-frontend v5 we want to compile two files:
To try and achieve that in a way where a downstream project doesn't have to make any additions we explored a) creating a WIth With Using Middleman external pipeline feels like the way forward, but we'd need to find a way for a downstream project to trigger gem build steps on Should above not be achievable, I believe the only other way to achieve separate entry points is:
Then their build should create all the necessary files. It's a similar flow to how |
Bit I want to really exhaust is "are we really sure we can't do this with sprockets". Things We've discovered:
Bits left for me to work out:
I'd really like to exhaust this line of thought as it's the least disruptive to the current delivery model of the tech-doc-gem, and keeps batteries included as much as possible without asking tech-doc folk to figure out how to run an external asset pipeline (which I think raises the congitive load for folks to use this) |
@kr8n3r I think i've found something in sprockets that might help Creates a new file under I testing that it does actually bring something across by creating a |
Rather than having to tie everything together in gem build and serve steps, I'd suggest going the rails route and having a bin/dev executable which can manage multiple processes. Then you can have dart sass process there and even a JS build too if needs be. You can put the executable in an exe directory to have it bundled as part of the gem and could maybe explore setting the executable up as a binstub that installers of the gem use. |
@huwd this produces an error during the build (CJS) as i don't think this pipeline handles es6 (esm). error is because so if we can switch minifiers, then we can provide a file where downstream can include it with a one-line in a new file |
This is needed because of the need to create two different JS rollups and because the default compressor fails. See link below. #352 (comment)
This is needed because of the need to create two different JS rollups and because the default compressor fails. See link below. #352 (comment)
This is needed because of the need to create two different JS rollups and because the default compressor fails. See link below. #352 (comment)
@kr8n3r what do we think about @kevindew's line above? I hadn't considered using /bin/dev in that way... could be a way to get us shifting to the "external pipeline" model, dropping a bunch of old dependencies and bringing in modern / quick ones... ... but if I understand @kevindew's comment right still having this as something that ships with the gem, and so keeps the feature set here as "batteries included", rather than pushing the burden down for every docsite to manage itself. |
not my area of expertise so cannot comment. |
As part of maintenance and WCAG 2.2 compliance, we'd like to use the latest major version of govuk-frontend
Version 5 Javascript support is limited to this support grades https://github.com/alphagov/govuk-frontend/blob/main/docs/contributing/browser-support.md as they use ES modules
"Only browsers in grades A, B and C will run our JavaScript enhancements. We will not support our JavaScript enhancements for older browsers in grade X"
We need to decide if
a) we're going to use babel to transpile to ES5 or
b) build govuk-frontend Javascript as intended and serve a no-js experience for browsers that don't support it.
Most of the Javascript modules here are ES5 using global
window
so we'll need to think about potentially rewriting those to ES modules.Additionally, downstream projects can write and include their own additions to application.js. We can expect that their javascript is likely to be ES5 and possibly using jQuery as well.
One of the options is to generate two files: ESM and non-ESM and bundle downstream into the latter. Similar to what we're doing on notify-admin for now
The text was updated successfully, but these errors were encountered: