Skip to content

chore(clerk-js): Migrate to rspack for building - #4106

Merged
dstaley merged 24 commits into
mainfrom
brk.feat/rspaack
Oct 31, 2024
Merged

chore(clerk-js): Migrate to rspack for building#4106
dstaley merged 24 commits into
mainfrom
brk.feat/rspaack

Conversation

@brkalow

@brkalow brkalow commented Sep 5, 2024

Copy link
Copy Markdown
Member

Description

This PR switches from Webpack to Rspack, resulting in a 10x build time improvement.

  • Migrates to rspack for building
  • Simplifies bundle analysis command
  • Removes webpack dependencies

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-bot Bot commented Sep 5, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b82938

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@clerk/clerk-js Patch
@clerk/elements Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch
@clerk/ui Patch

Not sure what this means? Click here to learn what changesets are.

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

@dstaley
dstaley marked this pull request as ready for review October 29, 2024 22:28
Comment thread packages/clerk-js/package.json Outdated
"watch": "rspack build --config rspack.config.js --env production --watch"
},
"browserslist": "last 2 versions, ios_saf > 12, Safari > 12, > 1%, not dead, not ie > 0",
"browserslist": "last 2 years",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is essentially Chrome >108, Safari >16.2, and Firefox >107.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we still need ios_saf > 12, Safari > 12 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I remember us having to fix issues for older iOS versions, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have one customer who was using v4 on versions as old as Safari 12. After discussing it with the team I believe we're going to implement a specific build for that customer and serve it via the Cloudflare Worker.

Prior to this PR, this browserslist config had no impact on the final build. I confirmed by setting it to Safari 9 (which did not support arrow functions () => {}) and confirmed that the resulting JavaScript files still contained arrow functions.

Ultimately, I think this meant that our older browser support wasn't tool enforced; it was solely a result of the APIs and JS language features we used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think, for now, I'm going to set the browserslist property to last 2 years, Safari > 12, iOS > 12. We can explore dropping the Safari support in a future PR once we've implemented custom builds for customers who need it.

maxChunks: 1,
}),
],
optimization: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was added because the LimitChunkCountPlugin doesn't reliably result in a single file.


import { Form } from '../common/form';
import { usePathnameWithoutCatchAll } from '../utils/path-inference/next';
import { removeOptionalCatchAllSegment } from '../utils/path-inference/utils';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The previous version was Next specific, which required that Elements depend on Next.js, resulting in it being included in the clerk-js bundle. This change instead uses the host router without specifically calling useRouter.

Comment thread verdaccio.install.yaml
publish: $all
proxy: npmjs
log: { type: stdout, format: pretty, level: http }
max_body_size: 20mb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The default max_body_size is 10mb. The tarball of clerk-js built by Rspack is over 15mb, so this was increased to prevent a 413 error during integration tests.

Comment thread .changeset/bright-ducks-enjoy.md Outdated
Comment thread packages/clerk-js/package.json Outdated
"watch": "rspack build --config rspack.config.js --env production --watch"
},
"browserslist": "last 2 versions, ios_saf > 12, Safari > 12, > 1%, not dead, not ie > 0",
"browserslist": "last 2 years",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I remember us having to fix issues for older iOS versions, right?

Comment thread packages/clerk-js/rspack.config.js

@jacekradko jacekradko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@dstaley
dstaley merged commit 8506fdd into main Oct 31, 2024
@dstaley
dstaley deleted the brk.feat/rspaack branch October 31, 2024 21:00
wobsoriano pushed a commit that referenced this pull request Feb 8, 2025
Co-authored-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
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.

6 participants