8000 refactor(theme-classic): migrate to tsc for build by Josh-Cena · Pull Request #7447 · facebook/docusaurus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor(theme-classic): migrate to tsc for build #7447

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

Merged
merged 2 commits into from
May 18, 2022
Merged

Conversation

Josh-Cena
Copy link
Collaborator
@Josh-Cena Josh-Cena commented May 18, 2022

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

This PR removes the Babel CLI used to build & watch the classic theme. There are three reasons.

  1. I have constantly talked about using tsconfig's paths option to replace our custom ambient modules declaration. In order to do so, we have to let tsc emit declaration anyways—we can't only use it for type-checking.
  2. This is the only place in our code base that uses Babel. Everywhere else uses SWC. Removing it enables us to remove a few dependencies.
  3. I've just fixed the watch DX issue (misc: make copyUntypedFiles work for watch mode #7445). This means that CSS gets hot reloaded, and the last reason to use Babel is gone.

Performance is a non-issue. Again, we have to run tsc anyways for type-checking. Chaining more commands only decreases performance.

I've verified that the output of tsc is still human-readable enough (despite missing a few line endings—Babel suffer from the same issue).

This means we no longer have lib and lib-next as two build outputs—everything's in one output folder, just the same as every other package.

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: maintenance This PR does not produce any behavior differences to end users when upgrading. label May 18, 2022
@Josh-Cena Josh-Cena requested review from slorber and lex111 as code owners May 18, 2022 11:30
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 18, 2022
@netlify
Copy link
netlify bot commented May 18, 2022

[V2]

Name Link
🔨 Latest commit 51ac3a4
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6284db0de1d32d0008120438
😎 Deploy Preview https://deploy-preview-7447--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link
github-actions bot commented May 18, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 74 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 86 🟢 99 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

Size Change: -332 B (0%)

Total Size: 796 kB

Filename Size Change
website/build/assets/js/main.********.js 599 kB -332 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.3 kB
website/build/assets/css/styles.********.css 106 kB
website/build/index.html 38.9 kB

compressed-size-action

@Josh-Cena
Copy link
Collaborator Author

Every time we preserve the ESM client module build output, we get a bundle size decrease! 😄

Same as the size decrease in #7437. Previously, we compiled the client modules to CJS as well, because it was really hard to do fine-grained include/exclude back then without project references. It's good to let Webpack take care of everything!

@Josh-Cena Josh-Cena merged commit b312200 into main May 18, 2022
@Josh-Cena Josh-Cena deleted the jc/remove-babel branch May 18, 2022 12:08
@slorber
Copy link
Collaborator
slorber commented May 25, 2022

nice 👍 thanks

maybe we could run Prettier on emitted theme files if anyone complains

@Josh-Cena
Copy link
Collaborator Author

We already do run Prettier; the only thing that can't be recovered is empty lines, but absence of empty lines do subtract readability.

@slorber
Copy link
Collaborator
slorber commented May 26, 2022

I see

Does not look like a big deal

We could write a little script that ads \n quite easily to top-level export and functions, should be good enough

@Josh-Cena
Copy link
8000
Collaborator Author

I think we can enable newline-after-import and run the fixer or something like that... 🤔

Gonna defer this to the future; the build script is already getting bloated without #5612

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: maintenance This PR does not produce any behavior differences to end users when upgrading.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0