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

Switch to SWC Compiler #1719

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Switch to SWC Compiler #1719

wants to merge 11 commits into from

Conversation

Jakeii
Copy link
Member

@Jakeii Jakeii commented Jan 3, 2025

What does this change?

Migrate to use https://swc.rs for transpiling and minification instead of typescript and babel.

swc is widely used including by guardian/dotcom-rendering

Why?

SWC is much faster, and usually produces smaller bundle sizes, although in our case it's a very minor reduction in bundle size.

The numbers

Build times

Dev

# before
webpack 5.97.1 compiled successfully in 11699 ms
# after 
webpack 5.97.1 compiled successfully in 1270 ms

Prod

# before
webpack 5.97.1 compiled with 1 warning in 14376 ms
# after
webpack 5.97.1 compiled with 1 warning in 2038 ms

Bundle sizes

Including all prebid bundles

Before After
2.07 MB (699.92 KB gzipped) 20.06 MB (698.48 KB gzipped)

Including just uk prebid bundle (More demonstrative as only one bundle is ever served to a user)

Before After
612.76 KB (197.72 KB gzipped) 603.09 KB (196.91 KB gzipped)

Copy link

changeset-bot bot commented Jan 3, 2025

⚠️ No Changeset found

Latest commit: a52091f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Ad load time test results

For consented, top-above-nav took on average 4374ms to load.
For consentless, top-above-nav took on average 2774ms to load.

Test conditions:

  • 5mbps download speed
  • 1.5mbps upload speed
  • 150ms latency

@@ -35,7 +35,7 @@ const prebidVersion = () => {
const loadPrebid = async (framework: ConsentFramework): Promise<void> => {
if (shouldLoadPrebid()) {
await import(
/* webpackChunkName: "Prebid.js" */
/* webpackChunkName: "[request]" */
Copy link
Member Author

Choose a reason for hiding this comment

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

this gives us nicer names for the localised prebid chunks

@Jakeii Jakeii changed the title WIP SWC Switch to SWC Compiler Jan 10, 2025
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.

1 participant