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

Skip JSDoc, SassDoc, Rollup stats during dev, add ESLint #4241

Merged
merged 10 commits into from
Sep 26, 2023
Merged

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Sep 21, 2023

This PR does a few things to speed up development:

  1. Skips JSDoc, SassDoc, and Rollup stats
  2. Splits watch tasks into separate “lint” and “compile”
  3. Moves TypeScript compiler build:types to a watch task
  4. Adds new npm run clean task for workspaces without Gulp

Where have my type checks gone?

Type checks moved to npm run lint last month so we can skip npm run build:types

In development, ESLint, StyleLint and the TypeScript compiler now run via gulp.watch() instead

Where have my stats gone?

JSDoc, SassDoc and Rollup stats are now considered optional in development

That said, the Review app will turn on these optional sections when they're built using:

npm run build:jsdoc --workspace @govuk-frontend/review
npm run build:sassdoc --workspace @govuk-frontend/review
npm run build:stats --workspace govuk-frontend

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 21, 2023 09:32 Inactive
@github-actions
Copy link

github-actions bot commented Sep 21, 2023

📋 Stats

File sizes

File Size
dist/govuk-frontend-4.6.0.min.css 118.07 KiB
dist/govuk-frontend-4.6.0.min.js 47.1 KiB
dist/govuk-frontend-ie8-4.6.0.min.css 79.27 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 76.96 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 72.29 KiB
packages/govuk-frontend/dist/govuk/all.mjs 3.84 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 121.15 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 37.41 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.83 KiB

Modules

File Size
all.mjs 68.39 KiB
components/accordion/accordion.mjs 21.9 KiB
components/button/button.mjs 4.71 KiB
components/character-count/character-count.mjs 21.64 KiB
components/checkboxes/checkboxes.mjs 5.69 KiB
components/error-summary/error-summary.mjs 6.01 KiB
components/exit-this-page/exit-this-page.mjs 16.6 KiB
components/header/header.mjs 3.83 KiB
components/notification-banner/notification-banner.mjs 4.54 KiB
components/radios/radios.mjs 4.68 KiB
components/skip-link/skip-link.mjs 3.73 KiB
components/tabs/tabs.mjs 9.07 KiB

View stats and visualisations on the review app


Action run for f655b6d

@colinrotherham colinrotherham requested a review from a team as a code owner September 21, 2023 10:15
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 21, 2023 10:15 Inactive
@colinrotherham colinrotherham changed the title Skip JSDoc, SassDoc and stats during development Skip JSDoc, SassDoc, stats and types during development Sep 21, 2023
@domoscargin
Copy link
Contributor

domoscargin commented Sep 21, 2023

I don't have any major problem with this - takes my rebuild time from 4+ seconds to 1-2 seconds.

One slight concern is it makes it more annoying to develop things that focus on the stuff that's skipped. I can't just run npm run build:sassdoc, for example - I have to remember how to access the review app workspace and run it from there. Don't see that being a particular problem though.

Relatedly, does this mean we'll get all the type complaints only when we run the Github action workflow?

@colinrotherham
Copy link
Contributor Author

colinrotherham commented Sep 21, 2023

@domoscargin Yeah, that's the downside for documentation and stats

For others reading this you can still run them manually at any time:

npm run build:jsdoc --workspace @govuk-frontend/review
npm run build:sassdoc --workspace @govuk-frontend/review
npm run build:stats --workspace govuk-frontend

Relatedly, does this mean we'll get all the type complaints only when we run the Github action workflow?

Yeah but up for discussion? Similar with Prettier, we don't run it via gulp.watch()

Good to find the right balance

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 21, 2023 10:59 Inactive
@colinrotherham
Copy link
Contributor Author

Sometimes you might want to skip the slow predev build entirely and run these in separate tabs:

npm run dev --workspace govuk-frontend
npm run dev --workspace @govuk-frontend/review

Another top tip

@domoscargin
Copy link
Contributor

Yeah, I think running the doc stuff manually will be absolutely fine 99.5% of the time so that's grand.

Completely on the fence about whether it's nicer to develop without getting type failures, or whether it'd be worse to get a bunch of 'em at once and potentially have to do a bigger refactor. Hopefully somebody else chimes in and leans one way or the other!

@colinrotherham
Copy link
Contributor Author

@domoscargin I'd quite like them turned on too, but it's usually just me with that opinion 😆

If you don't mind TypeScript *.tsbuildinfo cache files it goes from ~7 seconds to 500ms (see below)

We do this in GitHub Actions already:

run: npm run lint:types -- --incremental

Type check

6.63s user 0.41s system 208% cpu 3.376 total

time npm run build:types --workspace govuk-frontend

Type check with cache

0.52s user 0.13s system 79% cpu 0.821 total

time npm run build:types --workspace govuk-frontend -- --incremental

@domoscargin domoscargin reopened this Sep 21, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 22, 2023 08:37 Inactive
@colinrotherham colinrotherham changed the title Skip JSDoc, SassDoc, stats and types during development Skip JSDoc, SassDoc, Rollup stats during dev, add ESLint Sep 22, 2023
@colinrotherham
Copy link
Contributor Author

@domoscargin I've added the TypeScript compiler build:types back as a watch task this morning

Ready for review again

@36degrees
Copy link
Contributor

I think this makes sense most of the time but that there are scenarios where it'd be useful to see the stats or docs update as you make changes.

How hard would it be to:

  • provide an easy way to re-enable the stats / docs (using a command line flag or environment variable)
  • hide the stats and docs in the review app when they're not being 'live updated' (but always show them on Heroku deploys)

That way you won't end up in situation where you can forget you're looking at stale stats / docs. Thoughts?

Runs before development sessions but not during
Runs before development sessions but not during
Runs before development sessions but not during
@colinrotherham
Copy link
Contributor Author

@36degrees Sounds like a nice addition, can decide the best approach today?

In readiness, I've pushed flags.hasDocs and flags.hasStats to the Review app to hide them for npm start

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 25, 2023 07:05 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 25, 2023 09:55 Inactive
Since we no longer build JSDoc, SassDoc or stats via Gulp we can turn these back on
Whilst it’s important to re-compile the Review app when the package changes, we can avoid running StyleLint unless Review app files have changes

Also makes paths consistent since we had a mixture of template strings, path joins, and duplicated some ignore paths already found in config files
We already have type checks in editors and IDEs, plus we run `lint:types` during the GitHub Actions workflow

So this check is more useful as a watch task for early feedback

Adds flag `--incremental` to use the compiler cache (10x faster) and flag `--pretty` to preserve colour output via `concurrently` CLI
The Rollup stats and webpack example don’t run Gulp so this gives us a consistent way to “reset everything” before a build
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4241 September 25, 2023 11:01 Inactive
@colinrotherham colinrotherham self-assigned this Sep 25, 2023
@colinrotherham
Copy link
Contributor Author

colinrotherham commented Sep 25, 2023

We talked about this in today's dev catch-up and will keep the speed improvements

Suggested flags to "opt in" to JSDoc, SassDoc or Rollup stats can be added in future

In the meantime we can use existing npm scripts when optional features are required:

npm run build:jsdoc --workspace @govuk-frontend/review
npm run build:sassdoc --workspace @govuk-frontend/review
npm run build:stats --workspace govuk-frontend

These will automatically appear in the Review app when available

See PR description for updates

Copy link
Contributor

@domoscargin domoscargin left a comment

Choose a reason for hiding this comment

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

This is great! Can definitely feel the difference when developing locally, and there's not as much gumph in my terminal to scroll through to find any relevant errors.

And the type checking seems really speedy too!

Base automatically changed from styles-in-package to main September 26, 2023 16:10
@colinrotherham colinrotherham merged commit 17f3ea5 into main Sep 26, 2023
47 checks passed
@colinrotherham colinrotherham deleted the dev-speed branch September 26, 2023 16:59
colinrotherham added a commit that referenced this pull request Sep 27, 2023
Skip JSDoc, SassDoc, Rollup stats during dev, add ESLint
@romaricpascal romaricpascal mentioned this pull request Dec 8, 2023
@colinrotherham colinrotherham removed their assignment Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

4 participants