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

Knip - Production mode #6676

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Knip - Production mode #6676

merged 3 commits into from
Jan 7, 2025

Conversation

andrewHEguardian
Copy link
Contributor

What are you doing in this PR?

Remove unused code found using knip in production mode, and add our entry points as the production code using the ! syntax. This reveals code used only by tests, obviously some of these are necessary (eg mocks) so we shouldn't run our GHA in production mode.

How to test

Run yarn knip --production - see files and dependencies used by tests
image

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Size Change: -24 B (0%)

Total Size: 2.19 MB

ℹ️ View Unchanged
Filename Size Change
./public/compiled-assets/javascripts/[countryGroupId]/events/router.js 90.4 kB 0 B
./public/compiled-assets/javascripts/[countryGroupId]/router.js 258 kB 0 B
./public/compiled-assets/javascripts/ausMomentMap.js 108 kB 0 B
./public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./public/compiled-assets/javascripts/digitalSubscriptionLandingPage.js 227 kB -2 B (0%)
./public/compiled-assets/javascripts/downForMaintenancePage.js 70.9 kB 0 B
./public/compiled-assets/javascripts/error404Page.js 70.8 kB 0 B
./public/compiled-assets/javascripts/error500Page.js 70.8 kB 0 B
./public/compiled-assets/javascripts/favicons.js 617 B 0 B
./public/compiled-assets/javascripts/paperSubscriptionCheckoutPage.js 166 kB -8 B (0%)
./public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 87.7 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPage.js 69.2 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./public/compiled-assets/javascripts/promotionTerms.js 73.8 kB 0 B
./public/compiled-assets/javascripts/subscriptionsLandingPage.js 73.1 kB 0 B
./public/compiled-assets/javascripts/subscriptionsRedemptionPage.js 118 kB -1 B (0%)
./public/compiled-assets/javascripts/supporterPlusLandingPage.js 300 kB -4 B (0%)
./public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 163 kB -9 B (-0.01%)
./public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 87.9 kB 0 B
./public/compiled-assets/webpack/136.js 2.17 kB 0 B
./public/compiled-assets/webpack/187.js 21.6 kB 0 B
./public/compiled-assets/webpack/344.js 2.01 kB 0 B
./public/compiled-assets/webpack/643.js 22.4 kB 0 B
./public/compiled-assets/webpack/706.js 107 kB 0 B

compressed-size-action

Copy link
Member

@tjmw tjmw left a comment

Choose a reason for hiding this comment

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

👏 Great!

@@ -1,11 +1,11 @@
const entryPoints = require('../webpack.entryPoints').common;

const flattenedEntryPoints = [...Object.keys(entryPoints)].map(
(key) => `assets/${entryPoints[key]}`,
(key) => `assets/${entryPoints[key]}!`,
Copy link
Member

Choose a reason for hiding this comment

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

So the ! here is a signal to knip that this is production code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, is it worth a comment or link?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I think a comment/link would be good 👍

@andrewHEguardian andrewHEguardian merged commit 64b6e8f into main Jan 7, 2025
19 checks passed
@andrewHEguardian andrewHEguardian deleted the ahe/knip-production branch January 7, 2025 12:29
@prout-bot
Copy link

Seen on PROD (merged by @andrewHEguardian 9 minutes and 42 seconds ago)

Sentry Release: support-client-side, support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants