-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(core): faster transpiler option - siteConfig.future.experimental_faster.swcJsLoader
#10435
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: +2.28 kB (+0.02%) Total Size: 11.6 MB
ℹ️ View Unchanged
|
…slorber/faster-swc-loader
slorber
added
the
Argos
Add this label to run UI visual regression tests. See argos.yml GH action.
label
Aug 23, 2024
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Argos
Add this label to run UI visual regression tests. See argos.yml GH action.
CLA Signed
Signed Facebook CLA
pr: new feature
This PR adds a new API or behavior.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Docusaurus Faster
This PR is part of the Docusaurus Faster project aiming at reducing production build times
Disclaimer
Switching from Babel to SWC might not give you a huge speed boost:
However, we still encourage you to try the new SWC loader.
In the future, we plan to use the Rust Rspack bundler with its built-in SWC loader (not needing JS <-> Rust communication) and expect it to be much faster than Babel.
Motivation: replace slow Babel with fast SWC
By default, Docusaurus uses Babel to transpile JS / TS / React code. It has served us well, but nowadays there are much faster Rust/Go alternatives doing the same job.
We already have the option to provide a custom js loader for a while now:
siteConfig.webpack.jsLoader
. This has been leveraged by our community to use swc or esbuild instead of Babel (see #4765).Including us! We have used a custom swc loader for a while on our website.
Now is a good time to add a feature flag to swap Babel for SWC.
Depending on user feedback, we could make SWC the default option in the next major version of Docusaurus.
This option requires adding the package
@docusaurus/faster
to your dependencies.About
future.experimental_faster
You might wonder why this config looks so complex/nested:
This option is the first of a series of new options to modernize the Docusaurus infrastructure and make it much faster to build.
Use Docusaurus Faster
@docusaurus/faster
to your site.@docusaurus/faster
is a new optional package created to encapsulate all the modern tools we plan to introduce in the future. People who do not want to use these new tools will not be penalized by downloading extra useless dependencies by default.You can turn on individual options through
siteConfig.future.experimental_faster
, such asswcJsLoader: true
.As a convenience, we also let you opt-in for all the options at once:
New faster options can be released in minor versions. Make sure your site works as intended after upgrading.
Test Plan
CI + dogfood on our website + E2E on init template with faster options disabled
Test links
https://deploy-preview-10435--docusaurus-2.netlify.app/