From a56abffc836870555bc9995ade558d0a3661bb4a Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:21:20 +0100 Subject: [PATCH] [code-infra] Remove commonjs imports in docs (#44976) --- babel.config.js | 2 +- docs/config.d.ts | 7 - docs/{config.js => config.ts} | 15 +- docs/{next.config.mjs => next.config.ts} | 16 +- docs/package.json | 2 +- docs/pages/_app.js | 2 +- docs/scripts/reportBrokenLinks.js | 254 +++--------------- docs/scripts/reportBrokenLinksLib.js | 171 ++++++++++++ docs/src/modules/utils/{find.mjs => find.ts} | 27 +- docs/tsconfig.json | 10 +- .../test-utils/src/setupBabel.js | 2 +- .../{extractImports.js => extractImports.mjs} | 4 +- packages/markdown/{index.d.ts => index.d.mts} | 0 packages/markdown/index.js | 3 - packages/markdown/index.mjs | 1 + packages/markdown/{loader.js => loader.mjs} | 12 +- packages/markdown/package.json | 15 +- .../{parseMarkdown.js => parseMarkdown.mjs} | 8 +- ...prepareMarkdown.js => prepareMarkdown.mjs} | 12 +- packages/markdown/{prism.js => prism.cjs} | 0 packages/markdown/{prism.d.ts => prism.d.mts} | 0 packages/markdown/prism.mjs | 3 + .../{textToHash.js => textToHash.mjs} | 4 +- packages/mui-docs/package.json | 3 +- packages/mui-docs/tsconfig.json | 3 +- pnpm-lock.yaml | 108 +++++--- test/regressions/webpack.config.js | 5 +- webpackBaseConfig.js | 2 +- 28 files changed, 357 insertions(+), 334 deletions(-) delete mode 100644 docs/config.d.ts rename docs/{config.js => config.ts} (59%) rename docs/{next.config.mjs => next.config.ts} (96%) create mode 100644 docs/scripts/reportBrokenLinksLib.js rename docs/src/modules/utils/{find.mjs => find.ts} (82%) rename packages/markdown/{extractImports.js => extractImports.mjs} (76%) rename packages/markdown/{index.d.ts => index.d.mts} (100%) delete mode 100644 packages/markdown/index.js create mode 100644 packages/markdown/index.mjs rename packages/markdown/{loader.js => loader.mjs} (98%) rename packages/markdown/{parseMarkdown.js => parseMarkdown.mjs} (99%) rename packages/markdown/{prepareMarkdown.js => prepareMarkdown.mjs} (98%) rename packages/markdown/{prism.js => prism.cjs} (100%) rename packages/markdown/{prism.d.ts => prism.d.mts} (100%) create mode 100644 packages/markdown/prism.mjs rename packages/markdown/{textToHash.js => textToHash.mjs} (93%) diff --git a/babel.config.js b/babel.config.js index 0b0e796d325601..8470913d067886 100644 --- a/babel.config.js +++ b/babel.config.js @@ -149,7 +149,7 @@ module.exports = function getBabelConfig(api) { ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue. overrides: [ { - exclude: /\.test\.(js|ts|tsx)$/, + exclude: /\.test\.(m?js|ts|tsx)$/, plugins: ['@babel/plugin-transform-react-constant-elements'], }, { diff --git a/docs/config.d.ts b/docs/config.d.ts deleted file mode 100644 index 605606f1179e10..00000000000000 --- a/docs/config.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const LANGUAGES: string[]; - -export const LANGUAGES_SSR: string[]; - -export const LANGUAGES_IN_PROGRESS: string[]; - -export const LANGUAGES_IGNORE_PAGES: (pathname: string) => boolean; diff --git a/docs/config.js b/docs/config.ts similarity index 59% rename from docs/config.js rename to docs/config.ts index 3dfdb2d1a01e72..d950bbe163cb78 100644 --- a/docs/config.js +++ b/docs/config.ts @@ -1,13 +1,13 @@ // Valid languages to server-side render in production -const LANGUAGES = ['en']; +export const LANGUAGES = ['en']; // Server side rendered languages -const LANGUAGES_SSR = ['en']; +export const LANGUAGES_SSR = ['en']; // Work in progress -const LANGUAGES_IN_PROGRESS = LANGUAGES.slice(); +export const LANGUAGES_IN_PROGRESS = LANGUAGES.slice(); -const LANGUAGES_IGNORE_PAGES = (pathname) => { +export const LANGUAGES_IGNORE_PAGES = (pathname: string) => { // We don't have the bandwidth like Qt to translate our blog posts // https://www.qt.io/zh-cn/blog if (pathname === '/blog' || pathname.startsWith('/blog/')) { @@ -20,10 +20,3 @@ const LANGUAGES_IGNORE_PAGES = (pathname) => { return false; }; - -module.exports = { - LANGUAGES, - LANGUAGES_IN_PROGRESS, - LANGUAGES_SSR, - LANGUAGES_IGNORE_PAGES, -}; diff --git a/docs/next.config.mjs b/docs/next.config.ts similarity index 96% rename from docs/next.config.mjs rename to docs/next.config.ts index aaf5919d1c1f26..fa944a808b8baf 100644 --- a/docs/next.config.mjs +++ b/docs/next.config.ts @@ -5,18 +5,14 @@ import * as fs from 'fs'; // @ts-ignore import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import { createRequire } from 'module'; -import { findPages } from './src/modules/utils/find.mjs'; +import { NextConfig } from 'next'; +import { findPages } from './src/modules/utils/find'; +import { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES, LANGUAGES_IN_PROGRESS } from './config'; const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); const require = createRequire(import.meta.url); -const withDocsInfra = require('./nextConfigDocsInfra.js'); -const { - LANGUAGES, - LANGUAGES_SSR, - LANGUAGES_IGNORE_PAGES, - LANGUAGES_IN_PROGRESS, -} = require('./config.js'); +const withDocsInfra = require('./nextConfigDocsInfra'); const workspaceRoot = path.join(currentDirectory, '../'); @@ -30,7 +26,7 @@ const pkgContent = fs.readFileSync(path.resolve(workspaceRoot, 'package.json'), const pkg = JSON.parse(pkgContent); export default withDocsInfra({ - webpack: (config, options) => { + webpack: (config: NextConfig, options): NextConfig => { const plugins = config.plugins.slice(); if (process.env.DOCS_STATS_ENABLED) { @@ -276,4 +272,4 @@ export default withDocsInfra({ ]; }, }), -}); +} satisfies NextConfig); diff --git a/docs/package.json b/docs/package.json index fcabb6a62ffe6a..91d02cfc8552dc 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,7 +16,7 @@ "typescript": "tsc -p tsconfig.json && tsc -p scripts/tsconfig.json", "typescript:transpile": "echo 'Use `pnpm docs:typescript:formatted'` instead && exit 1", "typescript:transpile:dev": "echo 'Use `pnpm docs:typescript'` instead && exit 1", - "link-check": "node ./scripts/reportBrokenLinks.js" + "link-check": "tsx ./scripts/reportBrokenLinks.js" }, "dependencies": { "@babel/core": "^7.26.0", diff --git a/docs/pages/_app.js b/docs/pages/_app.js index d4883bd918e096..f22f3cdbc9fcde 100644 --- a/docs/pages/_app.js +++ b/docs/pages/_app.js @@ -39,7 +39,7 @@ import SvgBaseUiLogo, { } from 'docs/src/icons/SvgBaseUiLogo'; import './global.css'; import '../public/static/components-gallery/base-theme.css'; -import config from '../config'; +import * as config from '../config'; // Remove the license warning from demonstration purposes LicenseInfo.setLicenseKey(process.env.NEXT_PUBLIC_MUI_LICENSE); diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index 039d0db99c7ef0..564e8ae06ac21c 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -1,182 +1,14 @@ /* eslint-disable no-console */ -const path = require('path'); -const fse = require('fs-extra'); -const { createRender } = require('@mui/internal-markdown'); -const { marked } = require('marked'); -const { LANGUAGES_IGNORE_PAGES } = require('../config'); - -// Use renderer to extract all links into a markdown document -function getPageLinks(markdown) { - const hrefs = []; - - const renderer = new marked.Renderer(); - renderer.link = ({ href }) => { - if (href.startsWith('/')) { - hrefs.push(href); - } - }; - marked(markdown, { renderer }); - return hrefs; -} - -// List all .js files in a folder -function getJsFilesInFolder(folderPath) { - const files = fse.readdirSync(folderPath, { withFileTypes: true }); - return files.reduce((acc, file) => { - if (file.isDirectory()) { - const filesInFolder = getJsFilesInFolder(path.join(folderPath, file.name)); - return [...acc, ...filesInFolder]; - } - if (file.name.endsWith('.js') || file.name.endsWith('.tsx')) { - return [...acc, path.join(folderPath, file.name).replace(/\\/g, '/')]; - } - return acc; - }, []); -} - -// Returns url assuming it's "./docs/pages/x/..." becomes "mui.com/x/..." -const jsFilePathToUrl = (jsFilePath) => { - const folder = path.dirname(jsFilePath); - const file = path.basename(jsFilePath); - - const root = folder.slice(jsFilePath.indexOf('/pages') + '/pages'.length); - const suffix = path.extname(file); - let page = `/${file.slice(0, file.length - suffix.length)}/`; - - if (page === '/index/') { - page = '/'; - } - - return `${root}${page}`; -}; - -function cleanLink(link) { - const startQueryIndex = link.indexOf('?'); - const endQueryIndex = link.indexOf('#', startQueryIndex); - - if (startQueryIndex === -1) { - return link; - } - if (endQueryIndex === -1) { - return link.slice(0, startQueryIndex); - } - return `${link.slice(0, startQueryIndex)}${link.slice(endQueryIndex)}`; -} - -function getLinksAndAnchors(fileName) { - const headingHashes = {}; - const render = createRender({ - headingHashes, - options: { - ignoreLanguagePages: LANGUAGES_IGNORE_PAGES, - env: { - SOURCE_CODE_REPO: '', - }, - }, - }); - - const data = fse.readFileSync(fileName, { encoding: 'utf8' }); - render(data); - - const links = getPageLinks(data).map(cleanLink); - - return { - hashes: Object.keys(headingHashes), - links, - }; -} - -const markdownImportRegExp = /'(.*)\?(muiMarkdown|@mui\/markdown)'/g; - -const getMdFilesImported = (jsPageFile) => { - // For each JS file extract the markdown rendered if it exists - const fileContent = fse.readFileSync(jsPageFile, 'utf8'); - /** - * Content files can be represented by either: - * - 'docsx/data/advanced-components/overview.md?muiMarkdown'; (for mui-x) - * - 'docs/data/advanced-components/overview.md?muiMarkdown'; - * - './index.md?muiMarkdown'; - */ - const importPaths = fileContent.match(markdownImportRegExp); - - if (importPaths === null) { - return []; - } - return importPaths.map((importPath) => { - let cleanImportPath = importPath.replace(markdownImportRegExp, '$1'); - if (cleanImportPath.startsWith('.')) { - cleanImportPath = path.join(path.dirname(jsPageFile), cleanImportPath); - } else { - /** - * convert /Users/oliviertassinari/base-ui/docs/pages/base-ui/react-switch/index.js - * and docs-base/data/base/components/switch/switch.md - * into /Users/oliviertassinari/base-ui/docs/data/base/components/switch/switch.md - */ - const cleanImportPathArray = cleanImportPath.split('/'); - // Assume that the first folder is /docs or an alias that starts with /docs - cleanImportPathArray.shift(); - - // Truncate jsPageFile at /docs/ and append cleanImportPath - cleanImportPath = path.join( - jsPageFile.slice(0, jsPageFile.indexOf('/docs/')), - 'docs', - cleanImportPathArray.join('/'), - ); - } - - return cleanImportPath; - }); -}; - -const parseDocFolder = (folderPath, availableLinks = {}, usedLinks = {}) => { - const jsPageFiles = getJsFilesInFolder(folderPath); - - const mdFiles = jsPageFiles.flatMap((jsPageFile) => { - const pageUrl = jsFilePathToUrl(jsPageFile); - const importedMds = getMdFilesImported(jsPageFile); - - return importedMds.map((fileName) => ({ fileName, url: pageUrl })); - }); - - // Mark all the existing page as available - jsPageFiles.forEach((jsFilePath) => { - const url = jsFilePathToUrl(jsFilePath); - availableLinks[url] = true; - }); - - // For each markdown file, extract links - mdFiles.forEach(({ fileName, url }) => { - const { hashes, links } = getLinksAndAnchors(fileName); - - links.forEach((link) => { - if (usedLinks[link] === undefined) { - usedLinks[link] = [fileName]; - } else { - usedLinks[link].push(fileName); - } - }); - - hashes.forEach((hash) => { - availableLinks[`${url}#${hash}`] = true; - }); - }); -}; - -const getAnchor = (link) => { - const splittedPath = link.split('/'); - const potentialAnchor = splittedPath[splittedPath.length - 1]; - return potentialAnchor.includes('#') ? potentialAnchor : ''; -}; - -// Export useful method for doing similar checks in other repositories -module.exports = { parseDocFolder, getAnchor }; +import path from 'path'; +import fse from 'fs-extra'; +import { parseDocFolder, getAnchor } from './reportBrokenLinksLib'; /** * The remaining pat to the code is specific to this repository */ const UNSUPPORTED_PATHS = ['/api/', '/careers/', '/store/', '/x/']; -const docsSpaceRoot = path.join(__dirname, '../'); +const docsSpaceRoot = path.join(path.dirname(new URL(import.meta.url).pathname), '../'); const buffer = []; function write(text) { @@ -193,43 +25,41 @@ function getPageUrlFromLink(link) { return rep; } -if (require.main === module) { - // {[url with hash]: true} - const availableLinks = {}; - - // {[url with hash]: list of files using this link} - const usedLinks = {}; - - parseDocFolder(path.join(docsSpaceRoot, './pages/'), availableLinks, usedLinks); - - write('Broken links found by `pnpm docs:link-check` that exist:\n'); - Object.keys(usedLinks) - .filter((link) => link.startsWith('/')) - .filter((link) => !availableLinks[link]) - // these url segments are specific to Base UI and added by scripts (can not be found in markdown) - .filter((link) => - ['components-api', 'hooks-api', '#unstyled'].every((str) => !link.includes(str)), - ) - .filter((link) => UNSUPPORTED_PATHS.every((unsupportedPath) => !link.includes(unsupportedPath))) - .sort() - .forEach((linkKey) => { - // - // - // - write(`- https://mui.com${linkKey}`); - console.log(`https://mui.com${linkKey}`); - - console.log(`used in`); - usedLinks[linkKey].forEach((f) => console.log(`- ${path.relative(docsSpaceRoot, f)}`)); - console.log('available anchors on the same page:'); - console.log( - Object.keys(availableLinks) - .filter((link) => getPageUrlFromLink(link) === getPageUrlFromLink(linkKey)) - .sort() - .map(getAnchor) - .join('\n'), - ); - console.log('\n\n'); - }); - save(buffer); -} +// {[url with hash]: true} +const availableLinks = {}; + +// {[url with hash]: list of files using this link} +const usedLinks = {}; + +parseDocFolder(path.join(docsSpaceRoot, './pages/'), availableLinks, usedLinks); + +write('Broken links found by `pnpm docs:link-check` that exist:\n'); +Object.keys(usedLinks) + .filter((link) => link.startsWith('/')) + .filter((link) => !availableLinks[link]) + // these url segments are specific to Base UI and added by scripts (can not be found in markdown) + .filter((link) => + ['components-api', 'hooks-api', '#unstyled'].every((str) => !link.includes(str)), + ) + .filter((link) => UNSUPPORTED_PATHS.every((unsupportedPath) => !link.includes(unsupportedPath))) + .sort() + .forEach((linkKey) => { + // + // + // + write(`- https://mui.com${linkKey}`); + console.log(`https://mui.com${linkKey}`); + + console.log(`used in`); + usedLinks[linkKey].forEach((f) => console.log(`- ${path.relative(docsSpaceRoot, f)}`)); + console.log('available anchors on the same page:'); + console.log( + Object.keys(availableLinks) + .filter((link) => getPageUrlFromLink(link) === getPageUrlFromLink(linkKey)) + .sort() + .map(getAnchor) + .join('\n'), + ); + console.log('\n\n'); + }); +save(buffer); diff --git a/docs/scripts/reportBrokenLinksLib.js b/docs/scripts/reportBrokenLinksLib.js new file mode 100644 index 00000000000000..b316ce2073fdf3 --- /dev/null +++ b/docs/scripts/reportBrokenLinksLib.js @@ -0,0 +1,171 @@ +import path from 'path'; +import fse from 'fs-extra'; +import { createRender } from '@mui/internal-markdown'; +import { marked } from 'marked'; +import { LANGUAGES_IGNORE_PAGES } from '../config'; + +// Use renderer to extract all links into a markdown document +function getPageLinks(markdown) { + const hrefs = []; + + const renderer = new marked.Renderer(); + renderer.link = ({ href }) => { + if (href.startsWith('/')) { + hrefs.push(href); + } + }; + marked(markdown, { renderer }); + return hrefs; +} + +// List all .js files in a folder +function getJsFilesInFolder(folderPath) { + const files = fse.readdirSync(folderPath, { withFileTypes: true }); + return files.reduce((acc, file) => { + if (file.isDirectory()) { + const filesInFolder = getJsFilesInFolder(path.join(folderPath, file.name)); + return [...acc, ...filesInFolder]; + } + if (file.name.endsWith('.js') || file.name.endsWith('.tsx')) { + return [...acc, path.join(folderPath, file.name).replace(/\\/g, '/')]; + } + return acc; + }, []); +} + +// Returns url assuming it's "./docs/pages/x/..." becomes "mui.com/x/..." +const jsFilePathToUrl = (jsFilePath) => { + const folder = path.dirname(jsFilePath); + const file = path.basename(jsFilePath); + + const root = folder.slice(jsFilePath.indexOf('/pages') + '/pages'.length); + const suffix = path.extname(file); + let page = `/${file.slice(0, file.length - suffix.length)}/`; + + if (page === '/index/') { + page = '/'; + } + + return `${root}${page}`; +}; + +function cleanLink(link) { + const startQueryIndex = link.indexOf('?'); + const endQueryIndex = link.indexOf('#', startQueryIndex); + + if (startQueryIndex === -1) { + return link; + } + if (endQueryIndex === -1) { + return link.slice(0, startQueryIndex); + } + return `${link.slice(0, startQueryIndex)}${link.slice(endQueryIndex)}`; +} + +function getLinksAndAnchors(fileName) { + const headingHashes = {}; + const render = createRender({ + headingHashes, + options: { + ignoreLanguagePages: LANGUAGES_IGNORE_PAGES, + env: { + SOURCE_CODE_REPO: '', + }, + }, + }); + + const data = fse.readFileSync(fileName, { encoding: 'utf8' }); + render(data); + + const links = getPageLinks(data).map(cleanLink); + + return { + hashes: Object.keys(headingHashes), + links, + }; +} + +const markdownImportRegExp = /'(.*)\?(muiMarkdown|@mui\/markdown)'/g; + +const getMdFilesImported = (jsPageFile) => { + // For each JS file extract the markdown rendered if it exists + const fileContent = fse.readFileSync(jsPageFile, 'utf8'); + /** + * Content files can be represented by either: + * - 'docsx/data/advanced-components/overview.md?muiMarkdown'; (for mui-x) + * - 'docs/data/advanced-components/overview.md?muiMarkdown'; + * - './index.md?muiMarkdown'; + */ + const importPaths = fileContent.match(markdownImportRegExp); + + if (importPaths === null) { + return []; + } + return importPaths.map((importPath) => { + let cleanImportPath = importPath.replace(markdownImportRegExp, '$1'); + if (cleanImportPath.startsWith('.')) { + cleanImportPath = path.join(path.dirname(jsPageFile), cleanImportPath); + } else { + /** + * convert /Users/oliviertassinari/base-ui/docs/pages/base-ui/react-switch/index.js + * and docs-base/data/base/components/switch/switch.md + * into /Users/oliviertassinari/base-ui/docs/data/base/components/switch/switch.md + */ + const cleanImportPathArray = cleanImportPath.split('/'); + // Assume that the first folder is /docs or an alias that starts with /docs + cleanImportPathArray.shift(); + + // Truncate jsPageFile at /docs/ and append cleanImportPath + cleanImportPath = path.join( + jsPageFile.slice(0, jsPageFile.indexOf('/docs/')), + 'docs', + cleanImportPathArray.join('/'), + ); + } + + return cleanImportPath; + }); +}; + +const parseDocFolder = (folderPath, availableLinks = {}, usedLinks = {}) => { + const jsPageFiles = getJsFilesInFolder(folderPath); + + const mdFiles = jsPageFiles.flatMap((jsPageFile) => { + const pageUrl = jsFilePathToUrl(jsPageFile); + const importedMds = getMdFilesImported(jsPageFile); + + return importedMds.map((fileName) => ({ fileName, url: pageUrl })); + }); + + // Mark all the existing page as available + jsPageFiles.forEach((jsFilePath) => { + const url = jsFilePathToUrl(jsFilePath); + availableLinks[url] = true; + }); + + // For each markdown file, extract links + mdFiles.forEach(({ fileName, url }) => { + const { hashes, links } = getLinksAndAnchors(fileName); + + links.forEach((link) => { + if (usedLinks[link] === undefined) { + usedLinks[link] = [fileName]; + } else { + usedLinks[link].push(fileName); + } + }); + + hashes.forEach((hash) => { + availableLinks[`${url}#${hash}`] = true; + }); + }); +}; + +const getAnchor = (link) => { + const splittedPath = link.split('/'); + const potentialAnchor = splittedPath[splittedPath.length - 1]; + return potentialAnchor.includes('#') ? potentialAnchor : ''; +}; + +// Export useful method for doing similar checks in other repositories +export { parseDocFolder, getAnchor }; diff --git a/docs/src/modules/utils/find.mjs b/docs/src/modules/utils/find.ts similarity index 82% rename from docs/src/modules/utils/find.mjs rename to docs/src/modules/utils/find.ts index a5221c421cd2a7..2443570ffec0ad 100644 --- a/docs/src/modules/utils/find.mjs +++ b/docs/src/modules/utils/find.ts @@ -7,27 +7,26 @@ const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); const pageRegex = /(\.js|\.tsx)$/; const blackList = ['/.eslintrc', '/_document', '/_app']; -/** - * @typedef {object} NextJSPage - * @property {string} pathname - * @property {NextJSPage[]} [children] - */ +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. - * @param {{ front: true }} [options] - * @param {string} [directory] - * @param {NextJSPage[]} pages - * @returns {NextJSPage[]} */ // eslint-disable-next-line import/prefer-default-export export function findPages( - options = {}, - directory = path.resolve(currentDirectory, '../../../pages'), - pages = [], -) { + options: FindPagesOptions = {}, + directory: string = path.resolve(currentDirectory, '../../../pages'), + pages: NextJSPage[] = [], +): NextJSPage[] { fs.readdirSync(directory).forEach((item) => { const itemPath = path.resolve(directory, item); const pathname = itemPath @@ -47,7 +46,7 @@ export function findPages( } if (fs.statSync(itemPath).isDirectory()) { - const children = []; + const children: NextJSPage[] = []; pages.push({ pathname, children, diff --git a/docs/tsconfig.json b/docs/tsconfig.json index f72d9e329a56d7..0c74a89e15ddf7 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "allowJs": true, "isolatedModules": true, + "moduleResolution": "bundler", /* files are emitted by babel */ "noEmit": true, "noUnusedLocals": true, @@ -11,13 +12,6 @@ "esModuleInterop": true, "incremental": true }, - "include": [ - "next-env.d.ts", - "next.config.mjs", - "types", - "src", - "pages", - "data" - ], + "include": ["next-env.d.ts", "next.config.ts", "types", "src", "pages", "data"], "exclude": ["docs/.next", "docs/export", "node_modules"] } diff --git a/packages-internal/test-utils/src/setupBabel.js b/packages-internal/test-utils/src/setupBabel.js index 8b042724d2e6d2..02f5188fccc980 100644 --- a/packages-internal/test-utils/src/setupBabel.js +++ b/packages-internal/test-utils/src/setupBabel.js @@ -1,3 +1,3 @@ require('@babel/register')({ - extensions: ['.js', '.ts', '.tsx'], + extensions: ['.js', '.mjs', '.ts', '.tsx'], }); diff --git a/packages/markdown/extractImports.js b/packages/markdown/extractImports.mjs similarity index 76% rename from packages/markdown/extractImports.js rename to packages/markdown/extractImports.mjs index b578414fe63911..9d21c13b328f1d 100644 --- a/packages/markdown/extractImports.js +++ b/packages/markdown/extractImports.mjs @@ -1,8 +1,6 @@ const importModuleRegexp = /^\s*import (?:["'\s]*(?:[\w*{}\n, ]+)from\s*)?["'\s]*([^"'{}$\s]+)["'\s].*/gm; -function extractImports(code) { +export default function extractImports(code) { return (code.match(importModuleRegexp) || []).map((x) => x.replace(importModuleRegexp, '$1')); } - -module.exports = extractImports; diff --git a/packages/markdown/index.d.ts b/packages/markdown/index.d.mts similarity index 100% rename from packages/markdown/index.d.ts rename to packages/markdown/index.d.mts diff --git a/packages/markdown/index.js b/packages/markdown/index.js deleted file mode 100644 index 35b45995fa51c4..00000000000000 --- a/packages/markdown/index.js +++ /dev/null @@ -1,3 +0,0 @@ -const { createRender, getHeaders, getTitle, renderMarkdown } = require('./parseMarkdown'); - -module.exports = { createRender, getHeaders, getTitle, renderMarkdown }; diff --git a/packages/markdown/index.mjs b/packages/markdown/index.mjs new file mode 100644 index 00000000000000..8cbbdf00eadb1e --- /dev/null +++ b/packages/markdown/index.mjs @@ -0,0 +1 @@ +export { createRender, getHeaders, getTitle, renderMarkdown } from './parseMarkdown.mjs'; diff --git a/packages/markdown/loader.js b/packages/markdown/loader.mjs similarity index 98% rename from packages/markdown/loader.js rename to packages/markdown/loader.mjs index 3b05c43194d004..72b489d32da79f 100644 --- a/packages/markdown/loader.js +++ b/packages/markdown/loader.mjs @@ -1,7 +1,7 @@ -const { promises: fs, readdirSync, statSync } = require('fs'); -const path = require('path'); -const prepareMarkdown = require('./prepareMarkdown'); -const extractImports = require('./extractImports'); +import { promises as fs, readdirSync, statSync } from 'fs'; +import path from 'path'; +import prepareMarkdown from './prepareMarkdown.mjs'; +import extractImports from './extractImports.mjs'; const notEnglishMarkdownRegExp = /-([a-z]{2})\.md$/; @@ -59,7 +59,7 @@ function findComponents(packages) { /** * @type {import('webpack').loader.Loader} */ -module.exports = async function demoLoader() { +export default async function demoLoader() { const englishFilepath = this.resourcePath; const options = this.getOptions(); @@ -636,4 +636,4 @@ ${Array.from(componentModuleIDs) `; return transformed; -}; +} diff --git a/packages/markdown/package.json b/packages/markdown/package.json index b58edb6bef93aa..ce01acb9d9b103 100644 --- a/packages/markdown/package.json +++ b/packages/markdown/package.json @@ -3,12 +3,17 @@ "version": "1.0.25", "author": "MUI Team", "description": "MUI markdown parser. This is an internal package not meant for general use.", - "main": "./index.js", - "types": "./index.d.ts", + "main": "./index.mjs", + "browser": "./index.mjs", + "types": "./index.d.mts", "exports": { - ".": "./index.js", - "./loader": "./loader.js", - "./prism": "./prism.js" + ".": "./index.mjs", + "./loader": "./loader.mjs", + "./prism": { + "types": "./prism.d.mts", + "require": "./prism.cjs", + "import": "./prism.mjs" + } }, "repository": { "type": "git", diff --git a/packages/markdown/parseMarkdown.js b/packages/markdown/parseMarkdown.mjs similarity index 99% rename from packages/markdown/parseMarkdown.js rename to packages/markdown/parseMarkdown.mjs index fe90950227cf69..25a8e601e88c18 100644 --- a/packages/markdown/parseMarkdown.js +++ b/packages/markdown/parseMarkdown.mjs @@ -1,6 +1,6 @@ -const { marked } = require('marked'); -const textToHash = require('./textToHash'); -const prism = require('./prism'); +import { marked } from 'marked'; +import textToHash from './textToHash.mjs'; +import prism from './prism.mjs'; /** * Option used by `marked` the library parsing markdown. @@ -486,7 +486,7 @@ function createRender(context) { return render; } -module.exports = { +export { createRender, getContents, getDescription, diff --git a/packages/markdown/prepareMarkdown.js b/packages/markdown/prepareMarkdown.mjs similarity index 98% rename from packages/markdown/prepareMarkdown.js rename to packages/markdown/prepareMarkdown.mjs index 7f2ed16eb3d2d7..2ce18e5396c41d 100644 --- a/packages/markdown/prepareMarkdown.js +++ b/packages/markdown/prepareMarkdown.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-irregular-whitespace */ -const fs = require('fs'); -const path = require('path'); -const kebabCase = require('lodash/kebabCase'); -const { +import fs from 'fs'; +import path from 'path'; +import kebabCase from 'lodash/kebabCase.js'; +import { createRender, getContents, getDescription, @@ -10,7 +10,7 @@ const { getFeatureList, getHeaders, getTitle, -} = require('./parseMarkdown'); +} from './parseMarkdown.mjs'; const BaseUIReexportedComponents = ['ClickAwayListener', 'NoSsr', 'Portal', 'TextareaAutosize']; @@ -267,4 +267,4 @@ ${headers.hooks return { docs }; } -module.exports = prepareMarkdown; +export default prepareMarkdown; diff --git a/packages/markdown/prism.js b/packages/markdown/prism.cjs similarity index 100% rename from packages/markdown/prism.js rename to packages/markdown/prism.cjs diff --git a/packages/markdown/prism.d.ts b/packages/markdown/prism.d.mts similarity index 100% rename from packages/markdown/prism.d.ts rename to packages/markdown/prism.d.mts diff --git a/packages/markdown/prism.mjs b/packages/markdown/prism.mjs new file mode 100644 index 00000000000000..763918324c72d6 --- /dev/null +++ b/packages/markdown/prism.mjs @@ -0,0 +1,3 @@ +import prism from './prism.cjs'; + +export default prism; diff --git a/packages/markdown/textToHash.js b/packages/markdown/textToHash.mjs similarity index 93% rename from packages/markdown/textToHash.js rename to packages/markdown/textToHash.mjs index a139c910ae5ca8..d6eea926b4baa9 100644 --- a/packages/markdown/textToHash.js +++ b/packages/markdown/textToHash.mjs @@ -14,7 +14,7 @@ function makeUnique(hash, unique, i = 1) { * @param {Record} [unique] - Ensures that each output is unique in `unique` * @returns {string} that is safe to use in fragment links */ -function textToHash(text, unique = {}) { +export default function textToHash(text, unique = {}) { return makeUnique( encodeURI( text @@ -32,5 +32,3 @@ function textToHash(text, unique = {}) { unique, ); } - -module.exports = textToHash; diff --git a/packages/mui-docs/package.json b/packages/mui-docs/package.json index 0e7d90cc939fca..ecf3c0616a2843 100644 --- a/packages/mui-docs/package.json +++ b/packages/mui-docs/package.json @@ -31,7 +31,8 @@ "build:copy-files": "node ../../scripts/copyFiles.mjs ./src/translations/translations.json:./translations/translations.json ./src/translations/translations.json:./node/translations/translations.json", "prebuild": "rimraf build", "release": "pnpm build && pnpm publish", - "test": "exit 0" + "test": "exit 0", + "typescript": "tsc -p tsconfig.json" }, "dependencies": { "@babel/runtime": "^7.26.0", diff --git a/packages/mui-docs/tsconfig.json b/packages/mui-docs/tsconfig.json index 60a823f5265032..2cb48f44651747 100644 --- a/packages/mui-docs/tsconfig.json +++ b/packages/mui-docs/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../../tsconfig.json", "compilerOptions": { "skipLibCheck": true, + "moduleResolution": "bundler", "resolveJsonModule": true, - "types": ["react", "node", "csstype"] + "types": ["react", "node", "csstype", "mocha"] }, "include": ["src/**/*", "test/**/*"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a79418d219d0e0..2026094314f7c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -661,7 +661,7 @@ importers: version: 9.7.5(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@toolpad/core': specifier: ^0.12.0 - version: 0.12.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/icons-material@packages+mui-icons-material+build)(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(next@15.1.5(@babel/core@7.26.0)(@opentelemetry/api@1.8.0)(@playwright/test@1.48.2)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react-router@7.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(vite@5.4.11(@types/node@20.17.12)(terser@5.37.0)) + version: 0.12.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/icons-material@packages+mui-icons-material+build)(@mui/material-pigment-css@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(next@15.1.5(@babel/core@7.26.0)(@opentelemetry/api@1.8.0)(@playwright/test@1.48.2)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react-router@7.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(vite@5.4.11(@types/node@20.17.12)(terser@5.37.0)) autoprefixer: specifier: ^10.4.20 version: 10.4.20(postcss@8.4.49) @@ -1411,13 +1411,13 @@ importers: version: 7.26.0 '@mui/base': specifier: '*' - version: 5.0.0-beta.68(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + version: 5.0.0-beta.69(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/internal-markdown': specifier: workspace:^ version: link:../markdown '@mui/system': specifier: ^5.0.0 || ^6.0.0 - version: 6.4.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) + version: 6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) chai: specifier: ^4.4.1 version: 4.5.0 @@ -3969,6 +3969,17 @@ packages: '@types/react': optional: true + '@mui/base@5.0.0-beta.69': + resolution: {integrity: sha512-r2YyGUXpZxj8rLAlbjp1x2BnMERTZ/dMqd9cClKj2OJ7ALAuiv/9X5E9eHfRc9o/dGRuLSMq/WTjREktJVjxVA==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 + react: ^17.0.0 || ^18.0.0 || ^19.0.0 + react-dom: ^17.0.0 || ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + '@types/react': + optional: true + '@mui/core-downloads-tracker@5.15.14': resolution: {integrity: sha512-on75VMd0XqZfaQW+9pGjSNiqW+ghc5E2ZSLRBXwcXl/C4YzjfyjrLPhrEpKnR9Uym9KXBvxrhoHfPcczYHweyA==} @@ -4010,6 +4021,12 @@ packages: '@types/react': optional: true + '@mui/material-pigment-css@6.4.1': + resolution: {integrity: sha512-iVkNYBPrE/w4K6qZpDJQr5JcGmfqk4/cqDlVQSMZlwDYgw3yi+gsFdZq89end0tN9VLaMwoCBowVDPy/h202Dw==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@pigment-css/react': 0.0.29 + '@mui/material@5.15.4': resolution: {integrity: sha512-T/LGRAC+M0c+D3+y67eHwIN5bSje0TxbcJCWR0esNvU11T0QwrX3jedXItPNBwMupF2F5VWCDHBVLlFnN3+ABA==} engines: {node: '>=12.0.0'} @@ -4037,8 +4054,8 @@ packages: '@types/react': optional: true - '@mui/private-theming@6.4.0': - resolution: {integrity: sha512-rNHci8MP6NOdEWAfZ/RBMO5Rhtp1T6fUDMSmingg9F1T6wiUeodIQ+NuTHh2/pMoUSeP9GdHdgMhMmfsXxOMuw==} + '@mui/private-theming@6.4.1': + resolution: {integrity: sha512-DcT7mwK89owwgcEuiE7w458te4CIjHbYWW6Kn6PiR6eLtxBsoBYphA968uqsQAOBQDpbYxvkuFLwhgk4bxoN/Q==} engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 @@ -4089,8 +4106,8 @@ packages: '@types/react': optional: true - '@mui/system@6.4.0': - resolution: {integrity: sha512-wTDyfRlaZCo2sW2IuOsrjeE5dl0Usrs6J7DxE3GwNCVFqS5wMplM2YeNiV3DO7s53RfCqbho+gJY6xaB9KThUA==} + '@mui/system@6.4.1': + resolution: {integrity: sha512-rgQzgcsHCTtzF9MZ+sL0tOhf2ZBLazpjrujClcb4Siju5lTrK0xX4PsiropActzCemNfM+mOu+0jezAVnfRK8g==} engines: {node: '>=14.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -4133,8 +4150,8 @@ packages: '@types/react': optional: true - '@mui/utils@6.4.0': - resolution: {integrity: sha512-woOTATWNsTNR3YBh2Ixkj3l5RaxSiGoC9G8gOpYoFw1mZM77LWJeuMHFax7iIW4ahK0Cr35TF9DKtrafJmOmNQ==} + '@mui/utils@6.4.1': + resolution: {integrity: sha512-iQUDUeYh87SvR4lVojaRaYnQix8BbRV51MxaV6MBmqthecQoxwSbS5e2wnbDJUeFxY2ppV505CiqPLtd0OWkqw==} engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 || ^19.0.0 @@ -15050,7 +15067,21 @@ snapshots: '@babel/runtime': 7.26.0 '@floating-ui/react-dom': 2.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/types': 7.2.21(@types/react@19.0.6) - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) + '@popperjs/core': 2.11.8 + clsx: 2.1.1 + prop-types: 15.8.1 + react: 19.0.0 + react-dom: 19.0.0(react@19.0.0) + optionalDependencies: + '@types/react': 19.0.6 + + '@mui/base@5.0.0-beta.69(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': + dependencies: + '@babel/runtime': 7.26.0 + '@floating-ui/react-dom': 2.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@mui/types': 7.2.21(@types/react@19.0.6) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@popperjs/core': 2.11.8 clsx: 2.1.1 prop-types: 15.8.1 @@ -15078,14 +15109,14 @@ snapshots: '@emotion/styled': 11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) '@types/react': 19.0.6 - '@mui/lab@6.0.0-beta.22(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': + '@mui/lab@6.0.0-beta.22(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material-pigment-css@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 '@mui/base': 5.0.0-beta.68(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/material': link:packages/mui-material/build - '@mui/system': 6.4.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) + '@mui/system': 6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) '@mui/types': 7.2.21(@types/react@19.0.6) - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) clsx: 2.1.1 prop-types: 15.8.1 react: 19.0.0 @@ -15093,8 +15124,21 @@ snapshots: optionalDependencies: '@emotion/react': 11.13.5(@types/react@19.0.6)(react@19.0.0) '@emotion/styled': 11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) + '@mui/material-pigment-css': 6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) '@types/react': 19.0.6 + '@mui/material-pigment-css@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0)': + dependencies: + '@babel/runtime': 7.26.0 + '@mui/system': 6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) + '@pigment-css/react': 0.0.29(@types/react@19.0.6)(react@19.0.0) + transitivePeerDependencies: + - '@emotion/react' + - '@emotion/styled' + - '@types/react' + - react + optional: true + '@mui/material@5.15.4(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 @@ -15125,10 +15169,10 @@ snapshots: optionalDependencies: '@types/react': 19.0.6 - '@mui/private-theming@6.4.0(@types/react@19.0.6)(react@19.0.0)': + '@mui/private-theming@6.4.1(@types/react@19.0.6)(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) prop-types: 15.8.1 react: 19.0.0 optionalDependencies: @@ -15174,13 +15218,13 @@ snapshots: '@emotion/styled': 11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) '@types/react': 19.0.6 - '@mui/system@6.4.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0)': + '@mui/system@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 - '@mui/private-theming': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/private-theming': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/styled-engine': 6.4.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(react@19.0.0) '@mui/types': 7.2.21(@types/react@19.0.6) - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) clsx: 2.1.1 csstype: 3.1.3 prop-types: 15.8.1 @@ -15218,7 +15262,7 @@ snapshots: optionalDependencies: '@types/react': 19.0.6 - '@mui/utils@6.4.0(@types/react@19.0.6)(react@19.0.0)': + '@mui/utils@6.4.1(@types/react@19.0.6)(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 '@mui/types': 7.2.21(@types/react@19.0.6) @@ -15253,7 +15297,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-charts-vendor': 7.20.0 '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) '@react-spring/rafz': 9.7.5 @@ -15291,7 +15335,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-data-grid': 7.23.6(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@mui/system@packages+mui-system+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/x-data-grid-pro': 7.23.6(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@mui/system@packages+mui-system+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) @@ -15314,7 +15358,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-data-grid': 7.23.6(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@mui/system@packages+mui-system+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) '@mui/x-license': 7.23.6(@types/react@19.0.6)(react@19.0.0) @@ -15335,7 +15379,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) clsx: 2.1.1 prop-types: 15.8.1 @@ -15353,7 +15397,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-date-pickers': 7.23.6(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@mui/system@packages+mui-system+build)(@types/react@19.0.6)(date-fns@2.30.0)(dayjs@1.11.13)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) '@mui/x-license': 7.23.6(@types/react@19.0.6)(react@19.0.0) @@ -15375,7 +15419,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) '@types/react-transition-group': 4.4.12(@types/react@19.0.6) clsx: 2.1.1 @@ -15394,7 +15438,7 @@ snapshots: '@mui/x-internals@7.23.6(@types/react@19.0.6)(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) react: 19.0.0 transitivePeerDependencies: - '@types/react' @@ -15402,7 +15446,7 @@ snapshots: '@mui/x-license@7.23.6(@types/react@19.0.6)(react@19.0.0)': dependencies: '@babel/runtime': 7.26.0 - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) react: 19.0.0 transitivePeerDependencies: - '@types/react' @@ -15412,7 +15456,7 @@ snapshots: '@babel/runtime': 7.26.0 '@mui/material': link:packages/mui-material/build '@mui/system': link:packages/mui-system/build - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@mui/x-internals': 7.23.6(@types/react@19.0.6)(react@19.0.0) '@types/react-transition-group': 4.4.12(@types/react@19.0.6) clsx: 2.1.1 @@ -15996,8 +16040,8 @@ snapshots: '@emotion/react': 11.13.5(@types/react@19.0.6)(react@19.0.0) '@emotion/serialize': 1.3.3 '@emotion/styled': 11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) - '@mui/system': 6.4.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) - '@mui/utils': 6.4.0(@types/react@19.0.6)(react@19.0.0) + '@mui/system': 6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0) + '@mui/utils': 6.4.1(@types/react@19.0.6)(react@19.0.0) '@wyw-in-js/processor-utils': 0.5.5 '@wyw-in-js/shared': 0.5.5 '@wyw-in-js/transform': 0.5.5 @@ -16747,11 +16791,11 @@ snapshots: '@theme-ui/css': 0.17.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0)) react: 19.0.0 - '@toolpad/core@0.12.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/icons-material@packages+mui-icons-material+build)(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(next@15.1.5(@babel/core@7.26.0)(@opentelemetry/api@1.8.0)(@playwright/test@1.48.2)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react-router@7.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(vite@5.4.11(@types/node@20.17.12)(terser@5.37.0))': + '@toolpad/core@0.12.0(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/icons-material@packages+mui-icons-material+build)(@mui/material-pigment-css@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(next@15.1.5(@babel/core@7.26.0)(@opentelemetry/api@1.8.0)(@playwright/test@1.48.2)(babel-plugin-macros@3.1.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react-router@7.1.1(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react@19.0.0)(vite@5.4.11(@types/node@20.17.12)(terser@5.37.0))': dependencies: '@babel/runtime': 7.26.0 '@mui/icons-material': link:packages/mui-icons-material/build - '@mui/lab': 6.0.0-beta.22(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) + '@mui/lab': 6.0.0-beta.22(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material-pigment-css@6.4.1(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@emotion/styled@11.13.5(@emotion/react@11.13.5(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@pigment-css/react@0.0.29(@types/react@19.0.6)(react@19.0.0))(@types/react@19.0.6)(react@19.0.0))(@mui/material@packages+mui-material+build)(@types/react@19.0.6)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) '@mui/material': link:packages/mui-material/build '@mui/utils': 6.3.1(@types/react@19.0.6)(react@19.0.0) '@toolpad/utils': 0.12.0(react@19.0.0) diff --git a/test/regressions/webpack.config.js b/test/regressions/webpack.config.js index bd7c7e9fdc047c..39fd773fce7c26 100644 --- a/test/regressions/webpack.config.js +++ b/test/regressions/webpack.config.js @@ -32,9 +32,8 @@ module.exports = { module: { rules: [ { - test: /\.(js|ts|tsx)$/, - // prism.js blocks @mui/internal-markdown/prism from being interpreted as ESM in this build. - exclude: /node_modules|prism\.js/, + test: /\.(js|mjs|ts|tsx)$/, + exclude: /node_modules/, loader: 'babel-loader', options: { cacheDirectory: true, diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 5ad9c19c200a1e..84962e0a6d00c1 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -31,6 +31,6 @@ module.exports = { '@mui/internal-test-utils': path.resolve(__dirname, './packages-internal/test-utils/src'), docs: path.resolve(__dirname, './docs'), }, - extensions: ['.js', '.ts', '.tsx', '.d.ts'], + extensions: ['.js', '.mjs', '.ts', '.tsx', '.d.ts'], }, };