Skip to content
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

[code-infra] Update monorepo #16112

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/config.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-imports
export * from '@mui/monorepo/docs/config';
6 changes: 0 additions & 6 deletions docs/constants.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const SOURCE_CODE_REPO = 'https://github.com/mui/mui-x';
export const SOURCE_GITHUB_BRANCH = 'master'; // #default-branch-switch
28 changes: 10 additions & 18 deletions docs/next.config.mjs → docs/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import * as url from 'url';
import * as fs from 'fs';
import { createRequire } from 'module';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
// const withTM from 'next-transpile-modules')(['@mui/monorepo'];
// @ts-expect-error This expected error should be gone once we update the monorepo
import withDocsInfra from '@mui/monorepo/docs/nextConfigDocsInfra.js';
import { findPages } from './src/modules/utils/find.mjs';
import {
LANGUAGES,
LANGUAGES_SSR,
LANGUAGES_IGNORE_PAGES,
LANGUAGES_IN_PROGRESS,
} from './config.js';
import constants from './constants.js';
// eslint-disable-next-line no-restricted-imports
import withDocsInfra from '@mui/monorepo/docs/nextConfigDocsInfra';
import { findPages } from './src/modules/utils/find';
import { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES, LANGUAGES_IN_PROGRESS } from './config';
import { SOURCE_CODE_REPO, SOURCE_GITHUB_BRANCH } from './constants';

const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const require = createRequire(import.meta.url);
Expand All @@ -23,6 +18,7 @@ const WORKSPACE_ROOT = path.resolve(currentDirectory, '../');
const MONOREPO_PATH = path.resolve(WORKSPACE_ROOT, './node_modules/@mui/monorepo');
const MONOREPO_ALIASES = {
'@mui/docs': path.resolve(MONOREPO_PATH, './packages/mui-docs/src'),
'@mui/internal-markdown': path.resolve(MONOREPO_PATH, './packages/markdown'),
};

const WORKSPACE_ALIASES = {
Expand All @@ -43,11 +39,7 @@ const WORKSPACE_ALIASES = {
'@mui/x-license': path.resolve(WORKSPACE_ROOT, './packages/x-license/src'),
};

/**
* @param {string} pkgPath
* @returns {{version: string}}
*/
function loadPkg(pkgPath) {
function loadPkg(pkgPath: string): { version: string } {
const pkgContent = fs.readFileSync(path.resolve(WORKSPACE_ROOT, pkgPath, 'package.json'), 'utf8');
return JSON.parse(pkgContent);
}
Expand All @@ -60,7 +52,7 @@ const treeViewPkg = loadPkg('./packages/x-tree-view');

let localSettings = {};
try {
// eslint-disable-next-line import/no-unresolved
// eslint-disable-next-line import/extensions
localSettings = require('./next.config.local.js');
} catch (_) {
// Ignore
Expand All @@ -77,8 +69,8 @@ export default withDocsInfra({
env: {
// docs-infra
LIB_VERSION: pkg.version,
SOURCE_CODE_REPO: constants.SOURCE_CODE_REPO,
SOURCE_GITHUB_BRANCH: constants.SOURCE_GITHUB_BRANCH,
SOURCE_CODE_REPO,
SOURCE_GITHUB_BRANCH,
GITHUB_TEMPLATE_DOCS_FEEDBACK: '6.docs-feedback.yml',
// MUI X related
DATA_GRID_VERSION: dataGridPkg.version,
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
import getProductInfoFromUrl from 'docs/src/modules/utils/getProductInfoFromUrl';
import { DocsProvider } from '@mui/docs/DocsProvider';
import { mapTranslations } from '@mui/docs/i18n';
import config from '../config';
import * as config from '../config';

// Remove the license warning from demonstration purposes
LicenseInfo.setLicenseKey(process.env.NEXT_PUBLIC_MUI_LICENSE);
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/reportBrokenLinks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const path = require('path');
const fse = require('fs-extra');
const { parseDocFolder, getAnchor } = require('@mui/monorepo/docs/scripts/reportBrokenLinks');
const { parseDocFolder, getAnchor } = require('@mui/monorepo/docs/scripts/reportBrokenLinksLib');

const docsSpaceRoot = path.join(__dirname, '../');

Expand Down
17 changes: 13 additions & 4 deletions docs/src/modules/utils/find.mjs → docs/src/modules/utils/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const jsRegex = /\.js$/;
const blackList = ['/.eslintrc', '/_document', '/_app'];

interface NextJSPage {
pathname: string;
children?: NextJSPage[];
}

interface FindPagesOptions {
front?: boolean;
}

// Returns the Next.js pages available in a nested format.
// The output is in the next.js format.
// Each pathname is a route you can navigate to.
export function findPages(
options = {},
directory = path.resolve(currentDirectory, '../../../pages'),
pages = [],
options: FindPagesOptions = {},
directory: string = path.resolve(currentDirectory, '../../../pages'),
pages: NextJSPage[] = [],
) {
fs.readdirSync(directory).forEach((item) => {
const itemPath = path.resolve(directory, item);
Expand Down Expand Up @@ -41,7 +50,7 @@ export function findPages(
}

if (fs.statSync(itemPath).isDirectory()) {
const children = [];
const children: NextJSPage[] = [];
pages.push({
pathname,
children,
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"docs:create-playground": "pnpm --filter docs create-playground",
"docs:api": "NODE_OPTIONS=--max-old-space-size=4096 pnpm docs:api:build && pnpm docs:api:buildX",
"docs:api:build": "tsx ./scripts/buildApiDocs/index.ts",
"docs:api:buildX": "cross-env BABEL_ENV=development babel-node -i \"/node_modules/(?!@mui)/\" -x .ts,.tsx,.js ./docs/scripts/api/buildApi.ts",
"docs:link-check": "cross-env BABEL_ENV=development babel-node -i \"/node_modules/(?!@mui)/\" --extensions \".tsx,.ts,.js\" ./docs/scripts/reportBrokenLinks.js",
"docs:api:buildX": "tsx ./docs/scripts/api/buildApi.ts",
"docs:link-check": "tsx ./docs/scripts/reportBrokenLinks.js",
"docs:build": "pnpm --filter docs build",
"docs:typescript:formatted": "pnpm --filter docs typescript:transpile",
"docs:populate:demos": "pnpm --filter docs populate:demos",
Expand Down Expand Up @@ -95,7 +95,7 @@
"@mui/internal-markdown": "^1.0.24",
"@mui/internal-test-utils": "^1.0.25",
"@mui/material": "^5.16.13",
"@mui/monorepo": "github:mui/material-ui#5d892caa7325fdc8679862f83804c541954fecbc",
"@mui/monorepo": "github:mui/material-ui#6619f7c9797cfa7775c53e038b17d2e818262f16",
"@mui/utils": "^5.16.13",
"@next/eslint-plugin-next": "15.1.3",
"@octokit/plugin-retry": "^7.1.2",
Expand Down Expand Up @@ -198,7 +198,9 @@
},
"resolutions": {
"react-is": "^19.0.0",
"@types/node": "^20.17.11"
"@types/node": "^20.17.11",
"@mui/internal-markdown": "https://pkg.csb.dev/mui/material-ui/commit/6619f7c9/@mui/internal-markdown",
"@mui/docs": "https://pkg.csb.dev/mui/material-ui/commit/6619f7c9/@mui/docs"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
54 changes: 29 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webpackBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
docs: path.resolve(__dirname, './node_modules/@mui/monorepo/docs'),
docsx: path.resolve(__dirname, './docs'),
},
extensions: ['.js', '.ts', '.tsx', '.d.ts'],
extensions: ['.js', '.mjs', '.ts', '.tsx', '.d.ts'],
},
output: {
path: path.join(__dirname, 'build'),
Expand All @@ -39,7 +39,7 @@ module.exports = {
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
test: /\.(js|mjs|ts|tsx)$/,
exclude: /node_modules\/.*\/node_modules\/(?!@mui)/,
loader: 'babel-loader',
options: {
Expand Down
Loading