-
Notifications
You must be signed in to change notification settings - Fork 27
[docs-infra] Automatic Type Meta Generation #489
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
Draft
dav-is
wants to merge
155
commits into
davis/add-docs-benchmarking
Choose a base branch
from
davis/add-types-generation
base: davis/add-docs-benchmarking
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+22,309
−113
Conversation
This file contains hidden or 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
Bundle size reportBundle size will be reported once CircleCI build #6648 finishes. |
Bundle size report
Check out the code infra dashboard for more information about this PR. |
…to check for existing files and directories.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
scope: docs-infra
Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305).
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.
Uses a webpack loader to take a single entrypoint parsed with the Typescript Language Service API and pass it through
typescript-api-extractor. This loads only the necessary files for a given entrypoint, and caches them in memory. This decreases the typescript parse by 90% compared to a monolithic parse (~2 seconds to ~200ms). The larger a library becomes, the more dramatic this difference becomes. Since we cache shared libraries and dependancies, when loading another entrypoint this can further decrease hot reloading time by 100-300ms.Shaping Page (implements Option D)
Docs
Read the docs on the webpack loader here.
Running the POC Demo
cd packages/docs-infrapnpm run buildcd ./docspnpm run devhttp://localhost:3000/docs-infra/hooks/use-types
Important
This is just an example component, and users of this library will be expected to create their own (likely more functional) table
Try installing
Performance
By default, we read the types from
.d.tsfiles, so generating the types metadata can be fairly quick and parse only the.d.tsfiles.Simple Function (types)
typescript-api-extractor8 Dependant Files
Complex React Function (
CodeHighlightertypes):typescript-api-extractor12 Dependant Files
When using
compilerOptions.pathsin Typescript ConfigIf using paths in the typescript config (or when
watchSourceDirectly: true), the TS compile is based on the source files instead of thed.tsfiles, which can add many dependent files (global types, each imported source file, etc). This is useful if importing files in a monorepo and don't have a separate build watcher to recompile thed.tsfiles.Simple Function (types) using
watchSourceDirectly: truetypescript-api-extractor7 Dependant Files
Complex React Function (
CodeHighlightertypes): usingwatchSourceDirectly: trueImportant
Do not use
watchSourceDirectly: trueunless you can optimize the source code's imports.As shown below, it can balloon and drastically slow down builds.
If building
d.tsfiles with a watcher, there's no need to watch the source files directly.typescript-api-extractor150 Dependant Files [warning]
In this complex case with
watchSourceDirectly: true, it can be beneficial to move the types to their owntypes.tsfile to avoid needing so many dependencies.In cases like this (more than 25 dependencies), we should warn the user that they should optimize this entrypoint, or disable
watchSourceDirectly: truefor this given entrypoint. The types metadata will still update when the library is rebuilt.Closes: #421