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

Allow ES2015+ supported features #4286

Merged
merged 7 commits into from
Nov 20, 2023
Merged

Allow ES2015+ supported features #4286

merged 7 commits into from
Nov 20, 2023

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Oct 2, 2023

This PR pulls together a few ES2015+ code changes with their supporting ESLint config

These were recommendations from the ESLint stylistic typed linting plugin in #4106

Already supported by ES modules

  • ES2015 Array.from() Done in #4322
  • ES2015 ''.includes()
  • ES2016 [].includes()
  • ES2017 Object.entries() Done in #4322

Total bundle size

all.mjs 69.3 KiB 68.66 KiB

Babel transforms without polyfills

  • ES2020 ?. optional chaining (+ 0.09 KiB)
  • ES2020 ?? nullish coalescing (+ 0.55 KiB)

Total bundle size

all.mjs 68.66 KiB 69.3 KiB

Transform examples

Note the following size increases using != versus !== to check for nullish rather than falsy values

Before

if ($summary?.parentNode) {
  // ...
}

if (config.scope ?? document) {
  // ...
}

After

if ($summary != null && $summary.parentNode) {
  // ...
}

var _config$scope
if ((_config$scope = config.scope) != null ? _config$scope : document)) {
  // ...
}

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 2, 2023 10:07 Inactive
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

📋 Stats

File sizes

File Size
dist/govuk-frontend-5.0.0-beta.1.min.css 114 KiB
dist/govuk-frontend-5.0.0-beta.1.min.js 37.93 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 77.58 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 72.89 KiB
packages/govuk-frontend/dist/govuk/all.mjs 3.86 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 113.53 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 38.11 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.38 KiB

Modules

File Size
all.mjs 69.22 KiB
components/accordion/accordion.mjs 21.47 KiB
components/button/button.mjs 4.5 KiB
components/character-count/character-count.mjs 21.05 KiB
components/checkboxes/checkboxes.mjs 5.63 KiB
components/error-summary/error-summary.mjs 5.89 KiB
components/exit-this-page/exit-this-page.mjs 15.89 KiB
components/header/header.mjs 3.71 KiB
components/notification-banner/notification-banner.mjs 4.34 KiB
components/radios/radios.mjs 4.63 KiB
components/skip-link/skip-link.mjs 3.61 KiB
components/tabs/tabs.mjs 9.47 KiB

View stats and visualisations on the review app


Action run for 47f697d

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 2, 2023 10:49 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 2, 2023 11:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 10, 2023 16:07 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 10, 2023 16:09 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 12, 2023 12:40 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 17, 2023 11:01 Inactive
@colinrotherham colinrotherham changed the base branch from main to null-checks October 17, 2023 11:05
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 17, 2023 11:33 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 18, 2023 14:38 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 19, 2023 11:09 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 October 19, 2023 11:20 Inactive
@colinrotherham colinrotherham changed the title [SPIKE] Try ES2015+ transpiled or supported features Allow ES2015+ supported features Oct 23, 2023
@colinrotherham colinrotherham marked this pull request as ready for review October 23, 2023 11:08
@colinrotherham colinrotherham force-pushed the null-checks branch 2 times, most recently from 79b4285 to 4fb611f Compare October 23, 2023 11:21
colinrotherham added a commit that referenced this pull request Nov 8, 2023
We have another PR open to discuss these features: #4286

Some ES2015+ features already have browser support or are enabled by Babel transforms
@colinrotherham colinrotherham changed the base branch from main to strict-mode November 8, 2023 12:16
Base automatically changed from strict-mode to main November 8, 2023 13:44
querkmachine pushed a commit that referenced this pull request Nov 13, 2023
We have another PR open to discuss these features: #4286

Some ES2015+ features already have browser support or are enabled by Babel transforms
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4286 November 20, 2023 10:25 Inactive
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

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

Nicely handy features to be able to use 😊

@colinrotherham colinrotherham merged commit 74dfa59 into main Nov 20, 2023
43 checks passed
@colinrotherham colinrotherham deleted the syntax-enabled branch November 20, 2023 10:43
owenatgov pushed a commit that referenced this pull request Jan 11, 2024
We have another PR open to discuss these features: #4286

Some ES2015+ features already have browser support or are enabled by Babel transforms
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.

3 participants