[docs-infra] Extract shared App component from _app into @mui/docs#47933
Open
brijeshb42 wants to merge 1 commit intomui:masterfrom
Open
[docs-infra] Extract shared App component from _app into @mui/docs#47933brijeshb42 wants to merge 1 commit intomui:masterfrom
brijeshb42 wants to merge 1 commit intomui:masterfrom
Conversation
Netlify deploy previewhttps://deploy-preview-47933--material-ui.netlify.app/ Bundle size report
|
de42f91 to
aedfd8c
Compare
aedfd8c to
b6c2edb
Compare
Create a configurable <DocsApp> component in @mui/docs/DocsApp that
encapsulates the common provider tree and boilerplate previously
duplicated between material-ui and mui-x _app files.
New module: packages/mui-docs/src/DocsApp/
- DocsApp.tsx: Configurable component rendering the full provider tree
(DocsProvider → CodeCopyProvider → CodeStylingProvider →
CodeVariantProvider → PageContext → DemoContext → ThemeWrapper →
StyledEngineProvider → AnalyticsProvider → children + GoogleAnalytics).
Accepts props for config, serviceWorkerPath, pageContextValue,
demoContextValue, adConfig, ThemeWrapper, and onInit.
- createGetInitialProps.ts: Factory for MyApp.getInitialProps,
parameterized by translationsContext (webpack require.context).
Follows the same pattern as @mui/docs/Document's createGetInitialProps.
- reportWebVitals.ts: Shared reportWebVitals function.
- printConsoleBanner.ts: Exported function for the MUI ASCII banner.
- serviceWorker.ts: registerServiceWorker(swPath) parameterized by path.
- loadDependencies.ts: Material Icons CSS font loading via fg-loadcss.
Moved into DocsApp/ (only used by DocsApp, no external consumers):
- AnalyticsProvider.tsx (from src/AnalyticsProvider/)
- GoogleAnalytics.tsx (from src/GoogleAnalytics/)
- StyledEngineProvider.tsx (from src/StyledEngineProvider/)
Converted _app.js → _app.tsx and _document.js → _document.tsx in both
material-ui and mui-x docs, adding proper TypeScript annotations.
Type fixes in PageContext:
- Added productCategoryId to MuiPageContext interface (was passed at
runtime but missing from the type).
- Relaxed ProductVersion to { text; current?; href? } to match actual
usage (versions are either current or have an href link, not both
required).
Added docs/types/webpack.d.ts declaring require.context() on
NodeJS.Require to support the TypeScript conversion.
b6c2edb to
e7b5a04
Compare
1 task
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create a configurable
<DocsApp>component in@mui/docs/DocsAppthat encapsulates the common provider tree and boilerplate previously duplicated between material-ui and mui-x_appfiles.New module: packages/mui-docs/src/DocsApp/
DocsApp.tsx: Configurable component rendering the full provider tree (DocsProvider → CodeCopyProvider → CodeStylingProvider → CodeVariantProvider → PageContext → DemoContext → ThemeWrapper → StyledEngineProvider → AnalyticsProvider → children + GoogleAnalytics). Accepts props for config, serviceWorkerPath, pageContextValue, demoContextValue, adConfig, ThemeWrapper, and onInit.createGetInitialProps.ts: Factory for MyApp.getInitialProps, parameterized by translationsContext (webpackrequire.context). Follows the same pattern as @mui/docs/Document's createGetInitialProps.reportWebVitals.ts: Shared reportWebVitals function.printConsoleBanner.ts: Exported function for the MUI ASCII banner.serviceWorker.ts: registerServiceWorker(swPath) parameterized by path.loadDependencies.ts: Material Icons CSS font loading via fg-loadcss.Moved into DocsApp/ (only used by DocsApp, no external consumers):
AnalyticsProvider.tsx(from src/AnalyticsProvider/)GoogleAnalytics.tsx(from src/GoogleAnalytics/)StyledEngineProvider.tsx(from src/StyledEngineProvider/)Converted
_app.js,_document.js,codeVariantandcodeStylingto typescript.Type fixes in PageContext:
Added
docs/types/webpack.d.ts declaring require.context() on NodeJS.Require to support the TypeScript conversion.