-
Notifications
You must be signed in to change notification settings - Fork 7
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
Simplifying imports within GOV.UK Frontend to improve compilation performance #22
Simplifying imports within GOV.UK Frontend to improve compilation performance #22
Conversation
Thanks @36degrees, looks like this will resolve my previous feedback! |
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 sounds good to me 👍
```scss | ||
@import "govuk/settings/all"; | ||
@import "govuk/tools/all"; | ||
@import "govuk/helpers/all"; |
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.
Sorry to repeat a question I asked before I'm just wondering if we can combine these dependencies into a single import.
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.
I think this is definitely something we'll consider, but we didn't want to add too much 'noise' to the proposal. I'm seeing it as an implementation detail at this point.
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.
I'm not sure I'm being of any help with my comment, but I'll leave it in case someone feels the same.
This proposal is good as a short term solution (and I highly appreciate that the team dedicated time to look into it), in a sense that it seems to be helping with improving the Rails assets compilation times, as it is addressing/mitigating the effects of @import
rule by using it more strategically, but on the long run I would prefer us to move towards @use
and the new way of doing modules in SCSS – and this would be, in my humble view, a more justified way of having a breaking change (v4) for the way we use SCSS modules.
As @36degrees showed in #1752, GOV.UK would benefit from switching from the blackhole of Ruby Sass to LibSass (30s -> 0.2s) much more than this change in govuk-frontend
would bring (0.2s -> 0.18).
|
||
## Problem | ||
|
||
It can take a long time to compile GOV.UK Frontend’s Sass to CSS. This is because many of the individual files within GOV.UK Frontend import their own dependencies, even if they would usually have already been imported. We originally did this so that you could import specific bits of GOV.UK Frontend without having to separately import their dependencies. |
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.
We originally did this so that you could import specific bits of GOV.UK Frontend without having to separately import their dependencies.
I'm on the opinion that we should continue to value the principle of importing specific bits without having to separately import dependencies. The fact that the legacy sass implementation (where 'modularisation' was only possible with @import
and @export
) didn't allow any sort of 'import-once'/'tree-shaking' was overcome later on with @use
which allows us to preserve this principle.
proposals/008-simplifying-imports-to-improve-compilation-performance.md
Outdated
Show resolved
Hide resolved
This is definitely on our roadmap, but at the minute only Dart Sass supports For that reason, we can't move to the module system until LibSass has had support for it for at least 3-6 months, and the related issue looks like it's currently tracking against LibSass 5.0 – for context, the latest release is 3.6.3. (The 'future plans' section of the module system blog post sets a hard limit of October 2021 for deprecating Realistically, I think this pushes a migration to In the meantime, the proposed changes for 4.0, although breaking, will only affect users who currently import from the core or overrides layer without importing the dependencies. I think the risk of these changes is pretty low? However, most of the performance gains do come from the changes to the components, so we could consider leaving the other layers alone if we don't think the benefit is worth it.
My understanding (based on @kevindew's comment here – #21 (comment)) is that without reducing the number of imports LibSass when used with Sprockets also shows poor warm-cache compilation times. Therefore, reducing the number of imports is still beneficial to GOV.UK. My benchmarks were using libsass in isolation, and only considered behaviour with a cold cache. |
Co-Authored-By: Alex <alex-ju@users.noreply.github.com>
I've raised an issue on GOV.UK Frontend to track migrating to |
thank you for the thorough reply @36degrees. it's good to know modules are on the roadmap. I know they're not there yet and even if |
This is an iteration of a previous proposal, based on the feedback we received.
We're planning to make changes to the way that the base layers (settings, tools and helpers) are imported within different parts of GOV.UK Frontend’s Sass, to reduce the time it takes to compile to CSS.
Most of you will not be affected by these changes, and if you import "node_modules/govuk-frontend/govuk/all" you will not need to do anything to benefit from these performance improvements.
It will have the most impact on you if you import only specific parts of GOV.UK Frontend.
📖 Read the proposal
💬 Add comments to this pull request, or on the proposal itself
✉️ If you prefer, send feedback to govuk-design-system-support@digital.cabinet-office.gov.uk
👍 You can also +1 this pull request if you agree with the proposal and have no other feedback to give