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

Rename all files to index for our Sass entrypoints #4955

Merged
merged 4 commits into from
May 1, 2024

Conversation

36degrees
Copy link
Contributor

@36degrees 36degrees commented Apr 24, 2024

Use index as the entrypoint for each layer as it:

  • matches how we’re structuring the Sass for components
  • allows users to omit ‘index’ from the filename where their Sass compiler supports index files (Dart Sass, LibSass 3.6.0 or higher, or Ruby Sass 3.6.0 or higher 1)
  • is a small stepping stone towards moving to the Sass module system 2

Keep the existing all files as aliases, but add deprecation warnings when importing via them so we can remove those files in the next major release.

Fixes #4960

Footnotes

  1. https://sass-lang.com/documentation/at-rules/import/#index-files

  2. https://tannerdolby.com/writing/using-index-files-in-sass/

Use `index` as the entrypoint for each layer as it:

- matches how we’re structuring the Sass for components
- allows users to omit ‘index’ from the filename where their Sass compiler supports index files (Dart Sass, LibSass 3.6.0 or higher, or Ruby Sass 3.6.0 or higher [1])
- is a small stepping stone towards moving to the Sass module system [2]

Keep the existing `all` files as aliases, but add deprecation warnings when importing  via them so we can remove those files in the next major release.

[1]: https://sass-lang.com/documentation/at-rules/import/#index-files
[2]: https://tannerdolby.com/writing/using-index-files-in-sass/
@36degrees 36degrees changed the title Rename ‘all’ files to ‘index’ for our Sass entrypoints Rename all files to index for our Sass entrypoints Apr 24, 2024
Copy link

github-actions bot commented Apr 24, 2024

📋 Stats

File sizes

File Size
dist/govuk-frontend-development.min.css 113.24 KiB
dist/govuk-frontend-development.min.js 42.21 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 87.21 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 81.95 KiB
packages/govuk-frontend/dist/govuk/all.mjs 4.17 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 113.23 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 42.2 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.55 KiB

Modules

File Size (bundled) Size (minified)
all.mjs 77.67 KiB 40.19 KiB
accordion.mjs 22.71 KiB 12.85 KiB
button.mjs 5.98 KiB 2.69 KiB
character-count.mjs 22.4 KiB 9.92 KiB
checkboxes.mjs 5.83 KiB 2.83 KiB
error-summary.mjs 7.89 KiB 3.46 KiB
exit-this-page.mjs 17.1 KiB 9.26 KiB
header.mjs 4.46 KiB 2.6 KiB
notification-banner.mjs 6.26 KiB 2.62 KiB
password-input.mjs 15.15 KiB 7.25 KiB
radios.mjs 4.83 KiB 2.38 KiB
skip-link.mjs 4.39 KiB 2.18 KiB
tabs.mjs 10.13 KiB 6.11 KiB

View stats and visualisations on the review app


Action run for 85e7fe4

Copy link

github-actions bot commented Apr 24, 2024

Other changes to npm package

diff --git a/packages/govuk-frontend/dist/govuk/_base.scss b/packages/govuk-frontend/dist/govuk/_base.scss
index 58c825543..adc899c85 100644
--- a/packages/govuk-frontend/dist/govuk/_base.scss
+++ b/packages/govuk-frontend/dist/govuk/_base.scss
@@ -1,5 +1,5 @@
-@import "settings/all";
-@import "tools/all";
-@import "helpers/all";
+@import "settings/index";
+@import "tools/index";
+@import "helpers/index";
 
 /*# sourceMappingURL=_base.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/all.scss b/packages/govuk-frontend/dist/govuk/all.scss
index f3125cbb0..d906d5093 100644
--- a/packages/govuk-frontend/dist/govuk/all.scss
+++ b/packages/govuk-frontend/dist/govuk/all.scss
@@ -1,11 +1,11 @@
 @import "base";
 
-@import "core/all";
-@import "objects/all";
+@import "core/index";
+@import "objects/index";
 
-@import "components/all";
+@import "components/index";
 
-@import "utilities/all";
-@import "overrides/all";
+@import "utilities/index";
+@import "overrides/index";
 
 /*# sourceMappingURL=all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/components/_all.scss b/packages/govuk-frontend/dist/govuk/components/_all.scss
index e0f702951..b8fd480b8 100644
--- a/packages/govuk-frontend/dist/govuk/components/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/components/_all.scss
@@ -1,39 +1,10 @@
-@import "../base";
+@import "../settings/warnings";
+@import "index";
 
-@import "accordion/index";
-@import "back-link/index";
-@import "breadcrumbs/index";
-@import "button/index";
-@import "character-count/index";
-@import "checkboxes/index";
-@import "cookie-banner/index";
-@import "date-input/index";
-@import "details/index";
-@import "error-message/index";
-@import "error-summary/index";
-@import "exit-this-page/index";
-@import "fieldset/index";
-@import "file-upload/index";
-@import "footer/index";
-@import "header/index";
-@import "hint/index";
-@import "input/index";
-@import "inset-text/index";
-@import "label/index";
-@import "notification-banner/index";
-@import "pagination/index";
-@import "panel/index";
-@import "password-input/index";
-@import "phase-banner/index";
-@import "radios/index";
-@import "select/index";
-@import "skip-link/index";
-@import "summary-list/index";
-@import "table/index";
-@import "tabs/index";
-@import "tag/index";
-@import "task-list/index";
-@import "textarea/index";
-@import "warning-text/index";
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/components/all' is deprecated. Update your import statement to import 'govuk/components/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/components/_index.scss b/packages/govuk-frontend/dist/govuk/components/_index.scss
new file mode 100644
index 000000000..c0c34dca3
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/_index.scss
@@ -0,0 +1,39 @@
+@import "../base";
+
+@import "accordion/index";
+@import "back-link/index";
+@import "breadcrumbs/index";
+@import "button/index";
+@import "character-count/index";
+@import "checkboxes/index";
+@import "cookie-banner/index";
+@import "date-input/index";
+@import "details/index";
+@import "error-message/index";
+@import "error-summary/index";
+@import "exit-this-page/index";
+@import "fieldset/index";
+@import "file-upload/index";
+@import "footer/index";
+@import "header/index";
+@import "hint/index";
+@import "input/index";
+@import "inset-text/index";
+@import "label/index";
+@import "notification-banner/index";
+@import "pagination/index";
+@import "panel/index";
+@import "password-input/index";
+@import "phase-banner/index";
+@import "radios/index";
+@import "select/index";
+@import "skip-link/index";
+@import "summary-list/index";
+@import "table/index";
+@import "tabs/index";
+@import "tag/index";
+@import "task-list/index";
+@import "textarea/index";
+@import "warning-text/index";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/core/_all.scss b/packages/govuk-frontend/dist/govuk/core/_all.scss
index a9c87c554..919b9ac03 100644
--- a/packages/govuk-frontend/dist/govuk/core/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/core/_all.scss
@@ -1,8 +1,10 @@
-@import "govuk-frontend-properties";
-@import "links";
-@import "lists";
-@import "typography";
-@import "section-break";
-@import "global-styles";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/core/all' is deprecated. Update your import statement to import 'govuk/core/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/core/_index.scss b/packages/govuk-frontend/dist/govuk/core/_index.scss
new file mode 100644
index 000000000..b0b59758e
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/core/_index.scss
@@ -0,0 +1,8 @@
+@import "govuk-frontend-properties";
+@import "links";
+@import "lists";
+@import "typography";
+@import "section-break";
+@import "global-styles";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/helpers/_all.scss b/packages/govuk-frontend/dist/govuk/helpers/_all.scss
index d79faf6ac..b6850afda 100644
--- a/packages/govuk-frontend/dist/govuk/helpers/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/helpers/_all.scss
@@ -1,14 +1,10 @@
-@import "clearfix";
-@import "colour";
-@import "device-pixels";
-@import "focused";
-@import "font-faces";
-@import "grid";
-@import "links";
-@import "media-queries";
-@import "shape-arrow";
-@import "spacing";
-@import "typography";
-@import "visually-hidden";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/helpers/all' is deprecated. Update your import statement to import 'govuk/helpers/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/helpers/_index.scss b/packages/govuk-frontend/dist/govuk/helpers/_index.scss
new file mode 100644
index 000000000..7a039bdd1
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/helpers/_index.scss
@@ -0,0 +1,14 @@
+@import "clearfix";
+@import "colour";
+@import "device-pixels";
+@import "focused";
+@import "font-faces";
+@import "grid";
+@import "links";
+@import "media-queries";
+@import "shape-arrow";
+@import "spacing";
+@import "typography";
+@import "visually-hidden";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/index.scss b/packages/govuk-frontend/dist/govuk/index.scss
new file mode 100644
index 000000000..393a85f39
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/index.scss
@@ -0,0 +1,11 @@
+@import "base";
+
+@import "core/index";
+@import "objects/index";
+
+@import "components/index";
+
+@import "utilities/index";
+@import "overrides/index";
+
+/*# sourceMappingURL=index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/objects/_all.scss b/packages/govuk-frontend/dist/govuk/objects/_all.scss
index 50c692a7a..a393b2724 100644
--- a/packages/govuk-frontend/dist/govuk/objects/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/objects/_all.scss
@@ -1,8 +1,10 @@
-@import "button-group";
-@import "form-group";
-@import "grid";
-@import "main-wrapper";
-@import "template";
-@import "width-container";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/objects/all' is deprecated. Update your import statement to import 'govuk/objects/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/objects/_index.scss b/packages/govuk-frontend/dist/govuk/objects/_index.scss
new file mode 100644
index 000000000..9a9ec28cd
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/objects/_index.scss
@@ -0,0 +1,8 @@
+@import "button-group";
+@import "form-group";
+@import "grid";
+@import "main-wrapper";
+@import "template";
+@import "width-container";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/overrides/_all.scss b/packages/govuk-frontend/dist/govuk/overrides/_all.scss
index 0e9a9fb14..d28d0e7a9 100644
--- a/packages/govuk-frontend/dist/govuk/overrides/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/overrides/_all.scss
@@ -1,7 +1,9 @@
-@import "display";
-@import "spacing";
-@import "text-align";
-@import "typography";
-@import "width";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/overrides/all' is deprecated. Update your import statement to import 'govuk/overrides/index'."
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/overrides/_index.scss b/packages/govuk-frontend/dist/govuk/overrides/_index.scss
new file mode 100644
index 000000000..27886c3b1
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/overrides/_index.scss
@@ -0,0 +1,7 @@
+@import "display";
+@import "spacing";
+@import "text-align";
+@import "typography";
+@import "width";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/settings/_all.scss b/packages/govuk-frontend/dist/govuk/settings/_all.scss
index b28454af9..7fc16e9b4 100644
--- a/packages/govuk-frontend/dist/govuk/settings/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/settings/_all.scss
@@ -1,23 +1,10 @@
-// The order we import settings in is important, as some settings files rely on
-// others
-
-@import "assets";
-
-@import "warnings";
-@import "global-styles";
-
-@import "media-queries";
-
-@import "colours-palette";
-@import "colours-organisations";
-@import "colours-applied";
-
-@import "spacing";
-@import "measurements";
-
-@import "typography-font";
-@import "typography-responsive";
-
-@import "links";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/settings/all' is deprecated. Update your import statement to import 'govuk/settings/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/settings/_index.scss b/packages/govuk-frontend/dist/govuk/settings/_index.scss
new file mode 100644
index 000000000..e46fb4637
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/settings/_index.scss
@@ -0,0 +1,23 @@
+// The order we import settings in is important, as some settings files rely on
+// others
+
+@import "assets";
+
+@import "warnings";
+@import "global-styles";
+
+@import "media-queries";
+
+@import "colours-palette";
+@import "colours-organisations";
+@import "colours-applied";
+
+@import "spacing";
+@import "measurements";
+
+@import "typography-font";
+@import "typography-responsive";
+
+@import "links";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/settings/_warnings.scss b/packages/govuk-frontend/dist/govuk/settings/_warnings.scss
index af64de8c0..e9fe535dc 100644
--- a/packages/govuk-frontend/dist/govuk/settings/_warnings.scss
+++ b/packages/govuk-frontend/dist/govuk/settings/_warnings.scss
@@ -37,17 +37,22 @@ $govuk-suppressed-warnings: () !default;
 /// - To format the passed warning `$message` with the warning key at the end
 /// - To prevent duplicate warnings by adding the passed `$key` to
 /// `$govuk-suppressed-warnings` after `@warn` is called to ensure it only runs
-/// once per sass compilation
+/// once per sass compilation (unless $silence-further-warnings is false)
 ///
 /// @param {String} $key - The key to be checked against `$govuk-suppressed-warnings`
 /// and then passed to it to prevent multiple of the same warning.
 /// @param {String} $message - The message to use when calling `@warn`
+/// @param {Boolean} $silence-further-warnings - Whether to silence future
+/// warnings that use the same $key
 /// @access private
 
-@mixin _warning($key, $message) {
+@mixin _warning($key, $message, $silence-further-warnings: true) {
   @if _should-warn($key) {
     @warn _warning-text($key, $message);
-    $govuk-suppressed-warnings: append($govuk-suppressed-warnings, $key) !global;
+
+    @if $silence-further-warnings {
+      $govuk-suppressed-warnings: append($govuk-suppressed-warnings, $key) !global;
+    }
   }
 }
 
diff --git a/packages/govuk-frontend/dist/govuk/tools/_all.scss b/packages/govuk-frontend/dist/govuk/tools/_all.scss
index 8c5556175..857712d6b 100644
--- a/packages/govuk-frontend/dist/govuk/tools/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/tools/_all.scss
@@ -1,7 +1,10 @@
-@import "exports";
-@import "font-url";
-@import "image-url";
-@import "px-to-em";
-@import "px-to-rem";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/tools/all' is deprecated. Update your import statement to import 'govuk/tools/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/tools/_index.scss b/packages/govuk-frontend/dist/govuk/tools/_index.scss
new file mode 100644
index 000000000..df0739053
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/tools/_index.scss
@@ -0,0 +1,7 @@
+@import "exports";
+@import "font-url";
+@import "image-url";
+@import "px-to-em";
+@import "px-to-rem";
+
+/*# sourceMappingURL=_index.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/utilities/_all.scss b/packages/govuk-frontend/dist/govuk/utilities/_all.scss
index 77dbb46ba..cc1da2ab0 100644
--- a/packages/govuk-frontend/dist/govuk/utilities/_all.scss
+++ b/packages/govuk-frontend/dist/govuk/utilities/_all.scss
@@ -1,4 +1,10 @@
-@import "clearfix";
-@import "visually-hidden";
+@import "../settings/warnings";
+@import "index";
+
+@include _warning(
+  "import-using-all",
+  "Importing using 'govuk/utilities/all' is deprecated. Update your import statement to import 'govuk/utilities/index'.",
+  $silence-further-warnings: false
+);
 
 /*# sourceMappingURL=_all.scss.map */
diff --git a/packages/govuk-frontend/dist/govuk/utilities/_index.scss b/packages/govuk-frontend/dist/govuk/utilities/_index.scss
new file mode 100644
index 000000000..7adb7f6c5
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/utilities/_index.scss
@@ -0,0 +1,4 @@
+@import "clearfix";
+@import "visually-hidden";
+
+/*# sourceMappingURL=_index.scss.map */

Action run for 85e7fe4

@36degrees
Copy link
Contributor Author

36degrees commented Apr 24, 2024

If we're happy with this change we should create an issue to clean up the all files in v6.

We'll also need to add a changelog entry and update any documentation that has examples that import the all files.

Base automatically changed from rename-all-test-file to main April 29, 2024 13:31
This is useful if we want to make users aware of all of the related issues at once (rather than playing whack-a-mole fixing one at a time), but still allow them to silence them using a single key.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4955 April 29, 2024 16:49 Inactive
36degrees added a commit to alphagov/govuk-frontend-docs that referenced this pull request Apr 29, 2024
Update the documentation to suggest importing using `index` files rather the now-deprecated `all` files following the changes in alphagov/govuk-frontend/pull/4955 [1]

[1]: alphagov/govuk-frontend#4955
@36degrees 36degrees merged commit f047499 into main May 1, 2024
46 checks passed
@36degrees 36degrees deleted the rename-all-to-index branch May 1, 2024 08:35
36degrees added a commit that referenced this pull request May 10, 2024
After the changes in #4955 we need to follow the instructions in our own deprecation message to update the imports from our full-page examples:

```
Importing using 'govuk/core/all' is deprecated. Update your import statement to import 'govuk/core/index'.
```
36degrees added a commit that referenced this pull request May 17, 2024
In #4955 we renamed all of the entrypoints within the individual layers from `all.scss` to `index.scss`, leaving `all.scss` in place as an alias that outputs a deprecation warning.

We also inadvertently introduced an `index.scss` in the root ‘govuk’ folder but with identical contents to `all.scss`. [1]

We ultimately intend to rename this root entrypoint to `index.scss` to be consistent with the other changes, but this requires further changes to our documentation, entrypoints in package.json etc.

In order to get the next release out, we’re just going to make `all.scss` a proxy for `index.scss`, without adding a deprecation warning.

We’ll make those changes and introduce a deprecation warning in a future release.

[1]: https://github.com/alphagov/govuk-frontend/pull/4955/files#diff-ec46cef55fb94c8061eaf2fd3f241998f9a13d56fdad7018fe1712e00d5ae3aa
domoscargin pushed a commit that referenced this pull request Jun 19, 2024
In #4955 we renamed all of the entrypoints within the individual layers from `all.scss` to `index.scss`, leaving `all.scss` in place as an alias that outputs a deprecation warning.

We also inadvertently introduced an `index.scss` in the root ‘govuk’ folder but with identical contents to `all.scss`. [1]

We ultimately intend to rename this root entrypoint to `index.scss` to be consistent with the other changes, but this requires further changes to our documentation, entrypoints in package.json etc.

In order to get the next release out, we’re just going to make `all.scss` a proxy for `index.scss`, without adding a deprecation warning.

We’ll make those changes and introduce a deprecation warning in a future release.

[1]: https://github.com/alphagov/govuk-frontend/pull/4955/files#diff-ec46cef55fb94c8061eaf2fd3f241998f9a13d56fdad7018fe1712e00d5ae3aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename any _all.scss files to _index.scss so they work as index files
3 participants