From a2d3a00e7502f2c66e85f61d1ecab9a569bce6ea Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Mon, 18 Apr 2022 11:24:52 +0200 Subject: [PATCH 01/13] disable indexation --- docs/pages/_document.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/pages/_document.js b/docs/pages/_document.js index 5957241cd2b34a..0a7d4488ea4256 100644 --- a/docs/pages/_document.js +++ b/docs/pages/_document.js @@ -64,10 +64,7 @@ export default class MyDocument extends Document { rel="canonical" href={`https://mui.com${userLanguage === 'en' ? '' : `/${userLanguage}`}${canonicalAs}`} /> - {/* TODO remove post migration */} - {!FEATURE_TOGGLE.enable_redirects && canonicalAs.startsWith('/material-ui/') ? ( - - ) : null} + {/* Preconnect allows the browser to setup early connections before an HTTP request From fbc0d828994a5486e503d0d18501f7063674661b Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Wed, 5 Oct 2022 19:31:45 -0300 Subject: [PATCH 02/13] [docs] Add redirects for MUI X v6 (#34296) Signed-off-by: Matheus Wichman Signed-off-by: Olivier Tassinari Co-authored-by: Olivier Tassinari --- docs/public/_redirects | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/public/_redirects b/docs/public/_redirects index f6194a2a145c04..9e302b39cebad3 100644 --- a/docs/public/_redirects +++ b/docs/public/_redirects @@ -402,14 +402,16 @@ https://v4.material-ui.com/* https://v4.mui.com/:splat 301! ## MUI X ## Unlike the store that expect to be hosted under a subfolder, ## MUI X is configured to be hosted at the root. -/static/x/* https://material-ui-x.netlify.app/static/x/:splat 200 -/x/_next/* https://material-ui-x.netlify.app/_next/:splat 200 -/x/* https://material-ui-x.netlify.app/x/:splat 200 -/r/x-* https://material-ui-x.netlify.app/r/x-:splat 200 -/:lang/x/* https://material-ui-x.netlify.app/:lang/x/:splat 200 +/static/x/* https://docs-next--material-ui-x.netlify.app/static/x/:splat 200 +/x/_next/* https://docs-next--material-ui-x.netlify.app/_next/:splat 200 +/x/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 +/r/x-* https://docs-next--material-ui-x.netlify.app/r/x-:splat 200 +/:lang/x/* https://docs-next--material-ui-x.netlify.app/:lang/x/:splat 200 ## MUI Toolpad /static/toolpad/* https://mui-toolpad-docs.netlify.app/static/toolpad/:splat 200 /toolpad/_next/* https://mui-toolpad-docs.netlify.app/_next/:splat 200 /toolpad/* https://mui-toolpad-docs.netlify.app/toolpad/:splat 200 /r/toolpad-* https://mui-toolpad-docs.netlify.app/r/toolpad-:splat 200 + +/* https://mui.com/:splat 301! From 39195181d30bb8df89e8ddeda02449c3eaaf383f Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Thu, 6 Oct 2022 01:39:31 +0200 Subject: [PATCH 03/13] [docs] Handle static files --- docs/public/_redirects | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/public/_redirects b/docs/public/_redirects index 9e302b39cebad3..b3ffb080ec8461 100644 --- a/docs/public/_redirects +++ b/docs/public/_redirects @@ -403,6 +403,7 @@ https://v4.material-ui.com/* https://v4.mui.com/:splat 301! ## Unlike the store that expect to be hosted under a subfolder, ## MUI X is configured to be hosted at the root. /static/x/* https://docs-next--material-ui-x.netlify.app/static/x/:splat 200 +/static/* https://mui.com/static/:splat 200 /x/_next/* https://docs-next--material-ui-x.netlify.app/_next/:splat 200 /x/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 /r/x-* https://docs-next--material-ui-x.netlify.app/r/x-:splat 200 From 766651b5e2792a109e9e61ca36e5758184b92088 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 15:30:42 +0100 Subject: [PATCH 04/13] [core] Use TypeScript aliases instead of Babel aliases for the doc --- docs/babel.config.js | 28 ---------------------------- tsconfig.json | 10 ++++++++++ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/docs/babel.config.js b/docs/babel.config.js index 8a20224a2c361d..4dc3df80918951 100644 --- a/docs/babel.config.js +++ b/docs/babel.config.js @@ -3,27 +3,6 @@ const path = require('path'); const errorCodesPath = path.resolve(__dirname, './public/static/error-codes.json'); -const alias = { - '@mui/material': '../packages/mui-material/src', - '@mui/docs': '../packages/mui-docs/src', - '@mui/icons-material': '../packages/mui-icons-material/lib', - '@mui/lab': '../packages/mui-lab/src', - '@mui/styles': '../packages/mui-styles/src', - '@mui/styled-engine-sc': '../packages/mui-styled-engine-sc/src', - // Swap the comments on the next two lines for using the styled-components as style engine - '@mui/styled-engine': '../packages/mui-styled-engine/src', - // '@mui/styled-engine': '../packages/mui-styled-engine-sc/src', - '@mui/system': '../packages/mui-system/src', - '@mui/private-theming': '../packages/mui-private-theming/src', - '@mui/utils': '../packages/mui-utils/src', - '@mui/base': '../packages/mui-base/src', - '@mui/material-next': '../packages/mui-material-next/src', - '@mui/joy': '../packages/mui-joy/src', - docs: './', - modules: '../modules', - pages: './pages', -}; - const { version: transformRuntimeVersion } = fse.readJSONSync( require.resolve('@babel/runtime-corejs2/package.json'), ); @@ -55,13 +34,6 @@ module.exports = { 'babel-plugin-optimize-clsx', // for IE11 support '@babel/plugin-transform-object-assign', - [ - 'babel-plugin-module-resolver', - { - alias, - transformFunctions: ['require', 'require.context'], - }, - ], ], ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue. env: { diff --git a/tsconfig.json b/tsconfig.json index a368a5fccb98b2..0d227a94896aa8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,8 +19,11 @@ "@mui/lab": ["./packages/mui-lab/src"], "@mui/lab/*": ["./packages/mui-lab/src/*"], "@mui/markdown": ["./docs/packages/markdown"], + // Swap the comments on the next four lines for using the styled-components as style engine "@mui/styled-engine": ["./packages/mui-styled-engine/src"], "@mui/styled-engine/*": ["./packages/mui-styled-engine/src/*"], + // "@mui/styled-engine": ["./packages/mui-styled-engine-sc/src"], + // "@mui/styled-engine/*": ["./packages/mui-styled-engine-sc/src/*"], "@mui/styled-engine-sc": ["./packages/mui-styled-engine-sc/src"], "@mui/styled-engine-sc/*": ["./packages/mui-styled-engine-sc/src/*"], "@mui/styles": ["./packages/mui-styles/src"], @@ -29,16 +32,23 @@ "@mui/system/*": ["./packages/mui-system/src/*"], "@mui/private-theming": ["./packages/mui-private-theming/src"], "@mui/private-theming/*": ["./packages/mui-private-theming/src/*"], + "@mui/utils": ["./packages/mui-utils/src"], + "@mui/utils/*": ["./packages/mui-utils/src/*"], "@mui/types": ["./packages/mui-types"], "@mui/base": ["./packages/mui-base/src"], "@mui/base/*": ["./packages/mui-base/src/*"], "@mui/docs": ["./packages/mui-docs/src"], "@mui/docs/*": ["./packages/mui-docs/src/*"], + "@mui/icons-material": ["./packages/mui-icons-material/lib"], + "@mui/icons-material/*": ["./packages/mui-icons-material/lib/*"], "@mui/material-next": ["./packages/mui-material-next/src"], "@mui/material-next/*": ["./packages/mui-material-next/src/*"], "@mui/joy": ["./packages/mui-joy/src"], "@mui/joy/*": ["./packages/mui-joy/src/*"], + "docs/*": ["./docs/*"], + "pages/*": ["./docs/pages"], "test/*": ["./test/*"], + "modules/*": ["./modules/*"], "typescript-to-proptypes": ["./packages/typescript-to-proptypes/src"] }, // Otherwise we get react-native typings which conflict with dom.lib. From c0b7b84d690e0a8a6107e753fe8f25333de0a793 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 16:12:21 +0100 Subject: [PATCH 05/13] Enable composite build --- docs/next.config.js | 23 --------------------- packages/mui-base/tsconfig.build.json | 3 ++- packages/mui-lab/tsconfig.build.json | 14 +++++++------ packages/mui-system/tsconfig.build.json | 3 ++- packages/mui-utils/src/integerPropType.d.ts | 4 ++++ packages/mui-utils/tsconfig.build.json | 1 + 6 files changed, 17 insertions(+), 31 deletions(-) create mode 100644 packages/mui-utils/src/integerPropType.d.ts diff --git a/docs/next.config.js b/docs/next.config.js index 116fe8d5211d1f..7984e36cfc16e0 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -107,29 +107,6 @@ module.exports = withDocsInfra({ // on the server we use the transpiled commonJS build, on client ES6 modules // babel needs to figure out in what context to parse the file sourceType: 'unambiguous', - plugins: [ - [ - 'babel-plugin-module-resolver', - { - alias: { - // all packages in this monorepo - '@mui/material': '../packages/mui-material/src', - '@mui/docs': '../packages/mui-docs/src', - '@mui/icons-material': '../packages/mui-icons-material/lib', - '@mui/lab': '../packages/mui-lab/src', - '@mui/styled-engine': '../packages/mui-styled-engine/src', - '@mui/styles': '../packages/mui-styles/src', - '@mui/system': '../packages/mui-system/src', - '@mui/private-theming': '../packages/mui-private-theming/src', - '@mui/utils': '../packages/mui-utils/src', - '@mui/base': '../packages/mui-base/src', - '@mui/material-next': '../packages/mui-material-next/src', - '@mui/joy': '../packages/mui-joy/src', - }, - // transformFunctions: ['require'], - }, - ], - ], }, }, }, diff --git a/packages/mui-base/tsconfig.build.json b/packages/mui-base/tsconfig.build.json index a45de38c5d2fd4..501142bc852849 100644 --- a/packages/mui-base/tsconfig.build.json +++ b/packages/mui-base/tsconfig.build.json @@ -11,5 +11,6 @@ "rootDir": "./src" }, "include": ["src/**/*.ts*"], - "exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"] + "exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"], + "references": [{ "path": "../mui-utils/tsconfig.build.json" }] } diff --git a/packages/mui-lab/tsconfig.build.json b/packages/mui-lab/tsconfig.build.json index 01364fe7009e03..bf392635a23881 100644 --- a/packages/mui-lab/tsconfig.build.json +++ b/packages/mui-lab/tsconfig.build.json @@ -3,16 +3,18 @@ // Actual .ts source files are transpiled via babel "extends": "./tsconfig.json", "compilerOptions": { - "noEmit": false, + "composite": true, "declaration": true, - "rootDir": "./src", - "outDir": "./build", - "emitDeclarationOnly": true + "noEmit": false, + "emitDeclarationOnly": true, + "outDir": "build", + "rootDir": "./src" }, "include": ["src/**/*.ts*"], "exclude": ["src/**/*.d.ts", "src/**/*.test.*", "./**/*.spec.*", "**/test-utils.tsx"], "references": [ - { "path": "../mui-material/tsconfig.build.json" }, - { "path": "../mui-system/tsconfig.build.json" } + { "path": "../mui-utils/tsconfig.build.json" }, + { "path": "../mui-system/tsconfig.build.json" }, + { "path": "../mui-material/tsconfig.build.json" } ] } diff --git a/packages/mui-system/tsconfig.build.json b/packages/mui-system/tsconfig.build.json index d591edd03a441a..0145c5da24109e 100644 --- a/packages/mui-system/tsconfig.build.json +++ b/packages/mui-system/tsconfig.build.json @@ -11,5 +11,6 @@ "rootDir": "./src" }, "include": ["src/**/*.ts*"], - "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"] + "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"], + "references": [{ "path": "../mui-utils/tsconfig.build.json" }] } diff --git a/packages/mui-utils/src/integerPropType.d.ts b/packages/mui-utils/src/integerPropType.d.ts new file mode 100644 index 00000000000000..ba30bb09d6f53c --- /dev/null +++ b/packages/mui-utils/src/integerPropType.d.ts @@ -0,0 +1,4 @@ +import { Requireable } from 'prop-types'; + +declare const integerPropType: Requireable; +export default integerPropType; diff --git a/packages/mui-utils/tsconfig.build.json b/packages/mui-utils/tsconfig.build.json index f10360d400e902..649cf77258fe4d 100644 --- a/packages/mui-utils/tsconfig.build.json +++ b/packages/mui-utils/tsconfig.build.json @@ -3,6 +3,7 @@ // Actual .ts source files are transpiled via babel "extends": "./tsconfig", "compilerOptions": { + "composite": true, "declaration": true, "noEmit": false, "emitDeclarationOnly": true, From 3b3fbe34d8d38d55a9b16ce72674cb6cb399f21a Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 16:24:56 +0100 Subject: [PATCH 06/13] Work --- tsconfig.json | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 0d227a94896aa8..03953d78b092a0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,12 +13,25 @@ "allowSyntheticDefaultImports": true, "noErrorTruncation": false, "allowJs": true, + "composite": true, "paths": { - "@mui/material": ["./packages/mui-material/src"], - "@mui/material/*": ["./packages/mui-material/src/*"], + "@mui/base": ["./packages/mui-base/src"], + "@mui/base/*": ["./packages/mui-base/src/*"], + "@mui/docs": ["./packages/mui-docs/src"], + "@mui/docs/*": ["./packages/mui-docs/src/*"], + "@mui/icons-material": ["./packages/mui-icons-material/lib"], + "@mui/icons-material/*": ["./packages/mui-icons-material/lib/*"], + "@mui/joy": ["./packages/mui-joy/src"], + "@mui/joy/*": ["./packages/mui-joy/src/*"], "@mui/lab": ["./packages/mui-lab/src"], "@mui/lab/*": ["./packages/mui-lab/src/*"], "@mui/markdown": ["./docs/packages/markdown"], + "@mui/material": ["./packages/mui-material/src"], + "@mui/material/*": ["./packages/mui-material/src/*"], + "@mui/material-next": ["./packages/mui-material-next/src"], + "@mui/material-next/*": ["./packages/mui-material-next/src/*"], + "@mui/private-theming": ["./packages/mui-private-theming/src"], + "@mui/private-theming/*": ["./packages/mui-private-theming/src/*"], // Swap the comments on the next four lines for using the styled-components as style engine "@mui/styled-engine": ["./packages/mui-styled-engine/src"], "@mui/styled-engine/*": ["./packages/mui-styled-engine/src/*"], @@ -30,29 +43,26 @@ "@mui/styles/*": ["./packages/mui-styles/src/*"], "@mui/system": ["./packages/mui-system/src"], "@mui/system/*": ["./packages/mui-system/src/*"], - "@mui/private-theming": ["./packages/mui-private-theming/src"], - "@mui/private-theming/*": ["./packages/mui-private-theming/src/*"], + "@mui/types": ["./packages/mui-types"], "@mui/utils": ["./packages/mui-utils/src"], "@mui/utils/*": ["./packages/mui-utils/src/*"], - "@mui/types": ["./packages/mui-types"], - "@mui/base": ["./packages/mui-base/src"], - "@mui/base/*": ["./packages/mui-base/src/*"], - "@mui/docs": ["./packages/mui-docs/src"], - "@mui/docs/*": ["./packages/mui-docs/src/*"], - "@mui/icons-material": ["./packages/mui-icons-material/lib"], - "@mui/icons-material/*": ["./packages/mui-icons-material/lib/*"], - "@mui/material-next": ["./packages/mui-material-next/src"], - "@mui/material-next/*": ["./packages/mui-material-next/src/*"], - "@mui/joy": ["./packages/mui-joy/src"], - "@mui/joy/*": ["./packages/mui-joy/src/*"], "docs/*": ["./docs/*"], + "modules/*": ["./modules/*"], "pages/*": ["./docs/pages"], "test/*": ["./test/*"], - "modules/*": ["./modules/*"], "typescript-to-proptypes": ["./packages/typescript-to-proptypes/src"] }, // Otherwise we get react-native typings which conflict with dom.lib. "types": ["node", "react", "react-is/next"] }, - "exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"] + "exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"], + "references": [ + { "path": "../mui-base/tsconfig.build.json" }, + { "path": "../mui-joy/tsconfig.build.json" }, + { "path": "../mui-lab/tsconfig.build.json" }, + { "path": "../mui-material/tsconfig.build.json" }, + { "path": "../mui-material-next/tsconfig.build.json" }, + { "path": "../mui-system/tsconfig.build.json" }, + { "path": "../mui-utils/tsconfig.build.json" }, + ] } From 02f3b48fe0431eafc454a79f879302fb2edc3ad4 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 16:56:26 +0100 Subject: [PATCH 07/13] Work --- docs/next.config.js | 17 +------- docs/package.json | 1 - docs/tsconfig.json | 2 +- packages/mui-joy/tsconfig.build.json | 5 ++- .../mui-material-next/tsconfig.build.json | 4 +- packages/mui-material/tsconfig.build.json | 5 ++- scripts/transpileDependenciesWithMUIUsage.js | 34 +++++++++++++++ test/karma.conf.js | 41 ++----------------- tsconfig.json | 10 ----- 9 files changed, 49 insertions(+), 70 deletions(-) create mode 100644 scripts/transpileDependenciesWithMUIUsage.js diff --git a/docs/next.config.js b/docs/next.config.js index 7984e36cfc16e0..d3e0c6715228c3 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -4,6 +4,7 @@ const pkg = require('../package.json'); const withDocsInfra = require('./nextConfigDocsInfra'); const { findPages } = require('./src/modules/utils/find'); const { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES } = require('./src/modules/constants'); +const transpileDependenciesWithMUIUsage = require('../scripts/transpileDependenciesWithMUIUsage') const workspaceRoot = path.join(__dirname, '../'); @@ -95,21 +96,7 @@ module.exports = withDocsInfra({ }, ], }, - // transpile 3rd party packages with dependencies in this repository - { - test: /\.(js|mjs|jsx)$/, - resourceQuery: { not: [/raw/] }, - include: - /node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers)/, - use: { - loader: 'babel-loader', - options: { - // on the server we use the transpiled commonJS build, on client ES6 modules - // babel needs to figure out in what context to parse the file - sourceType: 'unambiguous', - }, - }, - }, + transpileDependenciesWithMUIUsage, // required to transpile ../packages/ { test: /\.(js|mjs|tsx|ts)$/, diff --git a/docs/package.json b/docs/package.json index bdede6aaaf424e..aef66809ef24c6 100644 --- a/docs/package.json +++ b/docs/package.json @@ -64,7 +64,6 @@ "ast-types": "^0.14.2", "autoprefixer": "^10.4.13", "autosuggest-highlight": "^3.3.4", - "babel-plugin-module-resolver": "^4.1.0", "babel-plugin-optimize-clsx": "^2.6.2", "babel-plugin-react-remove-properties": "^0.3.0", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", diff --git a/docs/tsconfig.json b/docs/tsconfig.json index b3282c841557ef..cc63e46fc74447 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -11,7 +11,7 @@ "skipLibCheck": true, "esModuleInterop": true, "types": ["react"], - "incremental": true + "incremental": true, }, "exclude": ["node_modules"] } diff --git a/packages/mui-joy/tsconfig.build.json b/packages/mui-joy/tsconfig.build.json index c3b70f2c3afd4c..f7a1e2cbf5e6fd 100644 --- a/packages/mui-joy/tsconfig.build.json +++ b/packages/mui-joy/tsconfig.build.json @@ -13,7 +13,8 @@ "include": ["./src/**/*.ts*"], "exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"], "references": [ - { "path": "../mui-base/tsconfig.build.json" }, - { "path": "../mui-system/tsconfig.build.json" } + { "path": "../mui-utils/tsconfig.build.json" }, + { "path": "../mui-system/tsconfig.build.json" }, + { "path": "../mui-base/tsconfig.build.json" } ] } diff --git a/packages/mui-material-next/tsconfig.build.json b/packages/mui-material-next/tsconfig.build.json index 3002c8ea68e3e5..886acba0a39c0e 100644 --- a/packages/mui-material-next/tsconfig.build.json +++ b/packages/mui-material-next/tsconfig.build.json @@ -13,8 +13,8 @@ "include": ["./src/**/*.ts*"], "exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"], "references": [ + { "path": "../mui-utils/tsconfig.build.json" }, { "path": "../mui-base/tsconfig.build.json" }, - { "path": "../mui-material/tsconfig.build.json" }, - { "path": "../mui-system/tsconfig.build.json" } + { "path": "../mui-material/tsconfig.build.json" } ] } diff --git a/packages/mui-material/tsconfig.build.json b/packages/mui-material/tsconfig.build.json index c3b70f2c3afd4c..f7a1e2cbf5e6fd 100644 --- a/packages/mui-material/tsconfig.build.json +++ b/packages/mui-material/tsconfig.build.json @@ -13,7 +13,8 @@ "include": ["./src/**/*.ts*"], "exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"], "references": [ - { "path": "../mui-base/tsconfig.build.json" }, - { "path": "../mui-system/tsconfig.build.json" } + { "path": "../mui-utils/tsconfig.build.json" }, + { "path": "../mui-system/tsconfig.build.json" }, + { "path": "../mui-base/tsconfig.build.json" } ] } diff --git a/scripts/transpileDependenciesWithMUIUsage.js b/scripts/transpileDependenciesWithMUIUsage.js new file mode 100644 index 00000000000000..1578cbd5a802c1 --- /dev/null +++ b/scripts/transpileDependenciesWithMUIUsage.js @@ -0,0 +1,34 @@ +// Transpile dependencies outside this repository with dependencies in this repository +module.exports = { + test: /\.(js|mjs|jsx)$/, + resourceQuery: { not: [/raw/] }, + include: + /node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers)/, + use: { + loader: 'babel-loader', + options: { + // on the server we use the transpiled commonJS build, on client ES6 modules + // babel needs to figure out in what context to parse the file + sourceType: 'unambiguous', + plugins: [ + [ + 'babel-plugin-module-resolver', + { + alias: { + // All the packages of this repo used in the dependencies outside this repo + '@mui/material': '../packages/mui-material/src', + '@mui/icons-material': '../packages/mui-icons-material/lib', + '@mui/styled-engine': '../packages/mui-styled-engine/src', + '@mui/styles': '../packages/mui-styles/src', + '@mui/system': '../packages/mui-system/src', + '@mui/utils': '../packages/mui-utils/src', + '@mui/base': '../packages/mui-base/src', + '@mui/joy': '../packages/mui-joy/src', + }, + // transformFunctions: ['require'], + }, + ] + ] + }, + }, +} diff --git a/test/karma.conf.js b/test/karma.conf.js index 7ce26ebb41a963..c9fbfee9cc515e 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -133,43 +133,10 @@ module.exports = function setKarmaConfig(config) { envName: 'stable', }, }, - // transpile 3rd party packages with dependencies in this repository - { - test: /\.(js|mjs|jsx)$/, - include: - /node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers)/, - use: { - loader: 'babel-loader', - options: { - // We have to apply `babel-plugin-module-resolve` to the files in `@mui/x-date-pickers`. - // Otherwise we can't import `@mui/material` from `@mui/x-date-pickers` in `yarn test:karma`. - sourceType: 'unambiguous', - plugins: [ - [ - 'babel-plugin-module-resolver', - { - alias: { - // all packages in this monorepo - '@mui/material': './packages/mui-material/src', - '@mui/docs': './packages/mui-docs/src', - '@mui/icons-material': './packages/mui-icons-material/lib', - '@mui/lab': './packages/mui-lab/src', - '@mui/styled-engine': './packages/mui-styled-engine/src', - '@mui/styles': './packages/mui-styles/src', - '@mui/system': './packages/mui-system/src', - '@mui/private-theming': './packages/mui-private-theming/src', - '@mui/utils': './packages/mui-utils/src', - '@mui/base': './packages/mui-base/src', - '@mui/material-next': './packages/mui-material-next/src', - '@mui/joy': './packages/mui-joy/src', - }, - transformFunctions: ['require'], - }, - ], - ], - }, - }, - }, + + + + { test: /\.(js|mjs|ts|tsx)$/, use: { diff --git a/tsconfig.json b/tsconfig.json index 03953d78b092a0..5d58521b6172f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,6 @@ "allowSyntheticDefaultImports": true, "noErrorTruncation": false, "allowJs": true, - "composite": true, "paths": { "@mui/base": ["./packages/mui-base/src"], "@mui/base/*": ["./packages/mui-base/src/*"], @@ -56,13 +55,4 @@ "types": ["node", "react", "react-is/next"] }, "exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"], - "references": [ - { "path": "../mui-base/tsconfig.build.json" }, - { "path": "../mui-joy/tsconfig.build.json" }, - { "path": "../mui-lab/tsconfig.build.json" }, - { "path": "../mui-material/tsconfig.build.json" }, - { "path": "../mui-material-next/tsconfig.build.json" }, - { "path": "../mui-system/tsconfig.build.json" }, - { "path": "../mui-utils/tsconfig.build.json" }, - ] } From 6ad41992814deaca7e6032ade1777c309e6a9a2b Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 17:16:34 +0100 Subject: [PATCH 08/13] Remove more aliases --- docs/next.config.js | 26 +++++++++++++-- docs/tsconfig.json | 2 +- scripts/muiAliases.js | 32 ++++++++++++++++++ scripts/sizeSnapshot/webpack.config.js | 15 ++------- scripts/transpileDependenciesWithMUIUsage.js | 34 -------------------- test/karma.conf.js | 4 --- tsconfig.json | 2 +- webpackBaseConfig.js | 19 ++--------- 8 files changed, 62 insertions(+), 72 deletions(-) create mode 100644 scripts/muiAliases.js delete mode 100644 scripts/transpileDependenciesWithMUIUsage.js diff --git a/docs/next.config.js b/docs/next.config.js index d3e0c6715228c3..f66409210e28da 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -4,7 +4,7 @@ const pkg = require('../package.json'); const withDocsInfra = require('./nextConfigDocsInfra'); const { findPages } = require('./src/modules/utils/find'); const { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES } = require('./src/modules/constants'); -const transpileDependenciesWithMUIUsage = require('../scripts/transpileDependenciesWithMUIUsage') +const muiAliases = require('../scripts/muiAliases'); const workspaceRoot = path.join(__dirname, '../'); @@ -96,7 +96,29 @@ module.exports = withDocsInfra({ }, ], }, - transpileDependenciesWithMUIUsage, + // Transpile dependencies outside this repository with dependencies in this repository + { + test: /\.(js|mjs|jsx)$/, + resourceQuery: { not: [/raw/] }, + include: + /node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers)/, + use: { + loader: 'babel-loader', + options: { + // on the server we use the transpiled commonJS build, on client ES6 modules + // babel needs to figure out in what context to parse the file + sourceType: 'unambiguous', + plugins: [ + [ + 'babel-plugin-module-resolver', + { + alias: muiAliases, + }, + ], + ], + }, + }, + }, // required to transpile ../packages/ { test: /\.(js|mjs|tsx|ts)$/, diff --git a/docs/tsconfig.json b/docs/tsconfig.json index cc63e46fc74447..b3282c841557ef 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -11,7 +11,7 @@ "skipLibCheck": true, "esModuleInterop": true, "types": ["react"], - "incremental": true, + "incremental": true }, "exclude": ["node_modules"] } diff --git a/scripts/muiAliases.js b/scripts/muiAliases.js new file mode 100644 index 00000000000000..5dbca716af3c17 --- /dev/null +++ b/scripts/muiAliases.js @@ -0,0 +1,32 @@ +const path = require('path'); + +const workspaceRoot = path.join(__dirname, '..'); + +/** + * @param {'build' | 'src'} type Define if the target should be the built version or the source. + */ +function getMuiAliases(type) { + return { + '@mui/base': path.join(workspaceRoot, 'packages/mui-base', type), + '@mui/docs': path.join(workspaceRoot, 'packages/mui-docs', type), + '@mui/icons-material': path.join( + workspaceRoot, + 'packages/mui-icons-material', + type === 'src' ? 'lib' : 'build', + ), + '@mui/joy': path.join(workspaceRoot, 'packages/mui-joy', type), + '@mui/lab': path.join(workspaceRoot, 'packages/mui-lab', type), + '@mui/material': path.join(workspaceRoot, 'packages/mui-material', type), + '@mui/material-next': path.join(workspaceRoot, 'packages/mui-material-next', type), + '@mui/private-theming': path.join(workspaceRoot, 'packages/mui-private-theming', type), + '@mui/styled-engine': path.join(workspaceRoot, 'packages/mui-styled-engine', type), + '@mui/styled-engine-sc': path.join(workspaceRoot, 'packages/mui-styles-sc', type), + '@mui/styles': path.join(workspaceRoot, 'packages/mui-styles', type), + '@mui/system': path.join(workspaceRoot, 'packages/mui-system', type), + '@mui/utils': path.join(workspaceRoot, 'packages/mui-utils', type), + docs: path.join(workspaceRoot, 'docs'), + 'typescript-to-proptypes': path.join(workspaceRoot, 'packages/typescript-to-proptypes/src'), + }; +} + +module.exports = getMuiAliases; diff --git a/scripts/sizeSnapshot/webpack.config.js b/scripts/sizeSnapshot/webpack.config.js index fe935fd850052a..59770a8d48d86b 100644 --- a/scripts/sizeSnapshot/webpack.config.js +++ b/scripts/sizeSnapshot/webpack.config.js @@ -3,6 +3,7 @@ const CompressionPlugin = require('compression-webpack-plugin'); const glob = require('fast-glob'); const TerserPlugin = require('terser-webpack-plugin'); const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); +const getMuiAliases = require('../muiAliases'); const workspaceRoot = path.join(__dirname, '..', '..'); @@ -208,19 +209,7 @@ function createWebpackConfig(entry, environment) { }), ], resolve: { - alias: { - '@mui/material': path.join(workspaceRoot, 'packages/mui-material/build'), - '@mui/lab': path.join(workspaceRoot, 'packages/mui-lab/build'), - '@mui/styled-engine': path.join(workspaceRoot, 'packages/mui-styled-engine/build'), - '@mui/styled-engine-sc': path.join(workspaceRoot, 'packages/mui-styles-sc/build'), - '@mui/styles': path.join(workspaceRoot, 'packages/mui-styles/build'), - '@mui/system': path.join(workspaceRoot, 'packages/mui-system/build'), - '@mui/private-theming': path.join(workspaceRoot, 'packages/mui-private-theming/build'), - '@mui/utils': path.join(workspaceRoot, 'packages/mui-utils/build'), - '@mui/base': path.join(workspaceRoot, 'packages/mui-base/build'), - '@mui/material-next': path.join(workspaceRoot, 'packages/mui-material-next/build'), - '@mui/joy': path.join(workspaceRoot, 'packages/mui-joy/build'), - }, + alias: getMuiAliases('build'), }, entry: { [entry.id]: path.join(workspaceRoot, entry.path) }, // TODO: 'browserslist:modern' diff --git a/scripts/transpileDependenciesWithMUIUsage.js b/scripts/transpileDependenciesWithMUIUsage.js deleted file mode 100644 index 1578cbd5a802c1..00000000000000 --- a/scripts/transpileDependenciesWithMUIUsage.js +++ /dev/null @@ -1,34 +0,0 @@ -// Transpile dependencies outside this repository with dependencies in this repository -module.exports = { - test: /\.(js|mjs|jsx)$/, - resourceQuery: { not: [/raw/] }, - include: - /node_modules(\/|\\)(notistack|@mui(\/|\\)x-data-grid|@mui(\/|\\)x-data-grid-pro|@mui(\/|\\)x-license-pro|@mui(\/|\\)x-data-grid-generator|@mui(\/|\\)x-date-pickers-pro|@mui(\/|\\)x-date-pickers)/, - use: { - loader: 'babel-loader', - options: { - // on the server we use the transpiled commonJS build, on client ES6 modules - // babel needs to figure out in what context to parse the file - sourceType: 'unambiguous', - plugins: [ - [ - 'babel-plugin-module-resolver', - { - alias: { - // All the packages of this repo used in the dependencies outside this repo - '@mui/material': '../packages/mui-material/src', - '@mui/icons-material': '../packages/mui-icons-material/lib', - '@mui/styled-engine': '../packages/mui-styled-engine/src', - '@mui/styles': '../packages/mui-styles/src', - '@mui/system': '../packages/mui-system/src', - '@mui/utils': '../packages/mui-utils/src', - '@mui/base': '../packages/mui-base/src', - '@mui/joy': '../packages/mui-joy/src', - }, - // transformFunctions: ['require'], - }, - ] - ] - }, - }, -} diff --git a/test/karma.conf.js b/test/karma.conf.js index c9fbfee9cc515e..1fbcb48027ee31 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -133,10 +133,6 @@ module.exports = function setKarmaConfig(config) { envName: 'stable', }, }, - - - - { test: /\.(js|mjs|ts|tsx)$/, use: { diff --git a/tsconfig.json b/tsconfig.json index 5d58521b6172f4..da96d3c2fc570d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -54,5 +54,5 @@ // Otherwise we get react-native typings which conflict with dom.lib. "types": ["node", "react", "react-is/next"] }, - "exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"], + "exclude": ["**/.*/", "**/build", "**/node_modules", "docs/export"] } diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index a12b5c108f60e0..0ac91ced67b343 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -1,4 +1,5 @@ const path = require('path'); +const getMuiAliases = require('./scripts/muiAliases'); // WARNING: Use this module only as an inspiration. // Cherry-pick the parts you need and inline them in the webpack.config you need. @@ -8,23 +9,7 @@ module.exports = { context: path.resolve(__dirname), resolve: { modules: [__dirname, 'node_modules'], - alias: { - '@mui/material': path.resolve(__dirname, './packages/mui-material/src'), - '@mui/docs': path.resolve(__dirname, './packages/mui-docs/src'), - '@mui/icons-material': path.resolve(__dirname, './packages/mui-icons-material/lib'), - '@mui/lab': path.resolve(__dirname, './packages/mui-lab/src'), - '@mui/styled-engine': path.resolve(__dirname, './packages/mui-styled-engine/src'), - '@mui/styled-engine-sc': path.resolve(__dirname, './packages/mui-styled-engine-sc/src'), - '@mui/styles': path.resolve(__dirname, './packages/mui-styles/src'), - '@mui/system': path.resolve(__dirname, './packages/mui-system/src'), - '@mui/private-theming': path.resolve(__dirname, './packages/mui-private-theming/src'), - '@mui/base': path.resolve(__dirname, './packages/mui-base/src'), - '@mui/utils': path.resolve(__dirname, './packages/mui-utils/src'), - '@mui/material-next': path.resolve(__dirname, './packages/mui-material-next/src'), - '@mui/joy': path.resolve(__dirname, './packages/mui-joy/src'), - 'typescript-to-proptypes': path.resolve(__dirname, './packages/typescript-to-proptypes/src'), - docs: path.resolve(__dirname, './docs'), - }, + alias: getMuiAliases('src'), extensions: ['.js', '.ts', '.tsx', '.d.ts'], }, }; From 0bde12f6e5e2c945697cad28e4eaa758e7f80bc3 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 18 Nov 2022 17:40:54 +0100 Subject: [PATCH 09/13] Work --- babel.config.js | 36 ++++++----------------------- docs/next.config.js | 4 ++-- scripts/muiAliases.js | 53 ++++++++++++++++++++++++++----------------- 3 files changed, 41 insertions(+), 52 deletions(-) diff --git a/babel.config.js b/babel.config.js index 6a0a54d455f095..1be9c11c8607b4 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,28 +1,10 @@ const path = require('path'); +const getMuiAliases = require('./scripts/muiAliases'); const errorCodesPath = path.resolve(__dirname, './docs/public/static/error-codes.json'); const missingError = process.env.MUI_EXTRACT_ERROR_CODES === 'true' ? 'write' : 'annotate'; -function resolveAliasPath(relativeToBabelConf) { - const resolvedPath = path.relative(process.cwd(), path.resolve(__dirname, relativeToBabelConf)); - return `./${resolvedPath.replace('\\', '/')}`; -} - -const defaultAlias = { - '@mui/material': resolveAliasPath('./packages/mui-material/src'), - '@mui/docs': resolveAliasPath('./packages/mui-docs/src'), - '@mui/icons-material': resolveAliasPath('./packages/mui-icons-material/lib'), - '@mui/lab': resolveAliasPath('./packages/mui-lab/src'), - '@mui/styled-engine': resolveAliasPath('./packages/mui-styled-engine/src'), - '@mui/styled-engine-sc': resolveAliasPath('./packages/mui-styled-engine-sc/src'), - '@mui/styles': resolveAliasPath('./packages/mui-styles/src'), - '@mui/system': resolveAliasPath('./packages/mui-system/src'), - '@mui/private-theming': resolveAliasPath('./packages/mui-private-theming/src'), - '@mui/base': resolveAliasPath('./packages/mui-base/src'), - '@mui/utils': resolveAliasPath('./packages/mui-utils/src'), - '@mui/material-next': resolveAliasPath('./packages/mui-material-next/src'), - '@mui/joy': resolveAliasPath('./packages/mui-joy/src'), -}; +const muiAliases = getMuiAliases('src', true); const productionPlugins = [ ['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }], @@ -91,8 +73,8 @@ module.exports = function getBabelConfig(api) { plugins.push([ 'babel-plugin-module-resolver', { - alias: defaultAlias, root: ['./'], + alias: muiAliases, }, ]); } @@ -118,7 +100,7 @@ module.exports = function getBabelConfig(api) { 'babel-plugin-module-resolver', { root: ['./'], - alias: defaultAlias, + alias: muiAliases, }, ], ], @@ -128,12 +110,8 @@ module.exports = function getBabelConfig(api) { [ 'babel-plugin-module-resolver', { - alias: { - ...defaultAlias, - modules: './modules', - 'typescript-to-proptypes': './packages/typescript-to-proptypes/src', - }, root: ['./'], + alias: muiAliases, }, ], ], @@ -151,7 +129,7 @@ module.exports = function getBabelConfig(api) { 'babel-plugin-module-resolver', { root: ['./'], - alias: defaultAlias, + alias: muiAliases, }, ], ], @@ -162,7 +140,7 @@ module.exports = function getBabelConfig(api) { [ 'babel-plugin-module-resolver', { - alias: defaultAlias, + alias: muiAliases, }, ], ], diff --git a/docs/next.config.js b/docs/next.config.js index f66409210e28da..a8808e8148dc8c 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -4,7 +4,7 @@ const pkg = require('../package.json'); const withDocsInfra = require('./nextConfigDocsInfra'); const { findPages } = require('./src/modules/utils/find'); const { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES } = require('./src/modules/constants'); -const muiAliases = require('../scripts/muiAliases'); +const getMuiAliases = require('../scripts/muiAliases'); const workspaceRoot = path.join(__dirname, '../'); @@ -112,7 +112,7 @@ module.exports = withDocsInfra({ [ 'babel-plugin-module-resolver', { - alias: muiAliases, + alias: getMuiAliases('src'), }, ], ], diff --git a/scripts/muiAliases.js b/scripts/muiAliases.js index 5dbca716af3c17..838ec7cbd8ff25 100644 --- a/scripts/muiAliases.js +++ b/scripts/muiAliases.js @@ -1,31 +1,42 @@ const path = require('path'); -const workspaceRoot = path.join(__dirname, '..'); - /** * @param {'build' | 'src'} type Define if the target should be the built version or the source. + * @param {boolean} isRelative If `true` the path will be relative to the repository root. */ -function getMuiAliases(type) { +function getMuiAliases(type, isRelative = false) { + const workspaceRoot = path.join(__dirname, '..'); + + const resolveAliasPath = (aliasPath) => { + const fullPath = path.join(workspaceRoot, aliasPath); + + if (!isRelative) { + return fullPath; + } + + const resolvedPath = path.relative(process.cwd(), fullPath); + return `./${resolvedPath.replace('\\', '/')}`; + }; + return { - '@mui/base': path.join(workspaceRoot, 'packages/mui-base', type), - '@mui/docs': path.join(workspaceRoot, 'packages/mui-docs', type), - '@mui/icons-material': path.join( - workspaceRoot, - 'packages/mui-icons-material', - type === 'src' ? 'lib' : 'build', + '@mui/base': resolveAliasPath(`packages/mui-base/${type}`), + '@mui/docs': resolveAliasPath(`packages/mui-docs/${type}`), + '@mui/icons-material': resolveAliasPath( + `packages/mui-icons-material/${type === 'src' ? 'lib' : 'build'}`, ), - '@mui/joy': path.join(workspaceRoot, 'packages/mui-joy', type), - '@mui/lab': path.join(workspaceRoot, 'packages/mui-lab', type), - '@mui/material': path.join(workspaceRoot, 'packages/mui-material', type), - '@mui/material-next': path.join(workspaceRoot, 'packages/mui-material-next', type), - '@mui/private-theming': path.join(workspaceRoot, 'packages/mui-private-theming', type), - '@mui/styled-engine': path.join(workspaceRoot, 'packages/mui-styled-engine', type), - '@mui/styled-engine-sc': path.join(workspaceRoot, 'packages/mui-styles-sc', type), - '@mui/styles': path.join(workspaceRoot, 'packages/mui-styles', type), - '@mui/system': path.join(workspaceRoot, 'packages/mui-system', type), - '@mui/utils': path.join(workspaceRoot, 'packages/mui-utils', type), - docs: path.join(workspaceRoot, 'docs'), - 'typescript-to-proptypes': path.join(workspaceRoot, 'packages/typescript-to-proptypes/src'), + '@mui/joy': resolveAliasPath(`packages/mui-joy/${type}`), + '@mui/lab': resolveAliasPath(`packages/mui-lab/${type}`), + '@mui/material': resolveAliasPath(`packages/mui-material/${type}`), + '@mui/material-next': resolveAliasPath(`packages/mui-material-next/${type}`), + '@mui/private-theming': resolveAliasPath(`packages/mui-private-theming/${type}`), + '@mui/styled-engine': resolveAliasPath(`packages/mui-styled-engine/${type}`), + '@mui/styled-engine-sc': resolveAliasPath(`packages/mui-styled-engine-sc/${type}`), + '@mui/styles': resolveAliasPath(`packages/mui-styles/${type}`), + '@mui/system': resolveAliasPath(`packages/mui-system/${type}`), + '@mui/utils': resolveAliasPath(`packages/mui-utils/${type}`), + docs: resolveAliasPath('docs'), + modules: resolveAliasPath('modules'), + 'typescript-to-proptypes': resolveAliasPath('packages/typescript-to-proptypes/src'), }; } From 78b17d79031032af7523089e02b0b03888fb6cb6 Mon Sep 17 00:00:00 2001 From: delangle Date: Thu, 21 Sep 2023 11:38:52 +0200 Subject: [PATCH 10/13] Work --- babel.config.js | 2 +- docs/next.config.js | 2 +- docs/public/_redirects | 11 +++++------ docs/src/components/productCore/CoreProducts.tsx | 2 +- .../src/components/productDesignKit/DesignKitHero.tsx | 3 +-- examples/base-ui-cra/src/App.js | 4 ++-- scripts/muiAliases.js | 7 ++++--- scripts/sizeSnapshot/webpack.config.js | 4 ++-- webpackBaseConfig.js | 2 +- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/babel.config.js b/babel.config.js index 7d3bf232d510c5..5643b9f93f5e16 100644 --- a/babel.config.js +++ b/babel.config.js @@ -9,7 +9,7 @@ const productionPlugins = [ ]; module.exports = function getBabelConfig(api) { - const muiAliases = getMuiAliases('src', true); + const muiAliases = getMuiAliases({ type: 'src', isRelative: true }); const useESModules = api.env(['regressions', 'legacy', 'modern', 'stable', 'rollup']); const presets = [ diff --git a/docs/next.config.js b/docs/next.config.js index bda98f57dcccaf..4bd942475e6f71 100644 --- a/docs/next.config.js +++ b/docs/next.config.js @@ -132,7 +132,7 @@ module.exports = withDocsInfra({ [ 'babel-plugin-module-resolver', { - alias: getMuiAliases('src'), + alias: getMuiAliases({ type: 'src' }), }, ], ], diff --git a/docs/public/_redirects b/docs/public/_redirects index 0dbeed026dba76..9b45e8509f1fc6 100644 --- a/docs/public/_redirects +++ b/docs/public/_redirects @@ -508,12 +508,11 @@ https://v4.material-ui.com/* https://v4.mui.com/:splat 301! ## MUI X ## Unlike the store that expect to be hosted under a subfolder, ## MUI X is configured to be hosted at the root. -/static/x/* https://docs-next--material-ui-x.netlify.app/static/x/:splat 200 -/static/* https://mui.com/static/:splat 200 -/x/_next/* https://docs-next--material-ui-x.netlify.app/_next/:splat 200 -/x/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 -/r/x-* https://docs-next--material-ui-x.netlify.app/r/x-:splat 200 -/:lang/x/* https://docs-next--material-ui-x.netlify.app/:lang/x/:splat 200 +/static/x/* https://material-ui-x.netlify.app/static/x/:splat 200 +/x/_next/* https://material-ui-x.netlify.app/_next/:splat 200 +/x/* https://material-ui-x.netlify.app/x/:splat 200 +/r/x-* https://material-ui-x.netlify.app/r/x-:splat 200 +/:lang/x/* https://material-ui-x.netlify.app/:lang/x/:splat 200 ## MUI Toolpad /static/toolpad/* https://mui-toolpad-docs.netlify.app/static/toolpad/:splat 200 diff --git a/docs/src/components/productCore/CoreProducts.tsx b/docs/src/components/productCore/CoreProducts.tsx index e970179872a5cc..46b551a737e937 100644 --- a/docs/src/components/productCore/CoreProducts.tsx +++ b/docs/src/components/productCore/CoreProducts.tsx @@ -27,7 +27,7 @@ const content = [ // logo: title: 'Base UI', description: - "A library of unstyled React UI components and hooks. With Base UI, you gain complete control over your app's CSS and accessibility features.", + 'A library of unstyled React UI components and hooks. With Base UI, you gain complete control over your app\'s CSS and accessibility features.', link: '/base-ui/', }, { diff --git a/docs/src/components/productDesignKit/DesignKitHero.tsx b/docs/src/components/productDesignKit/DesignKitHero.tsx index 295a62bc583d70..8651c294cca2cf 100644 --- a/docs/src/components/productDesignKit/DesignKitHero.tsx +++ b/docs/src/components/productDesignKit/DesignKitHero.tsx @@ -34,8 +34,7 @@ export default function TemplateHero() { }), })} > - Design - kits + Design kits Material UI diff --git a/examples/base-ui-cra/src/App.js b/examples/base-ui-cra/src/App.js index 6c936be8aceebf..ac2c5fbb40c00c 100644 --- a/examples/base-ui-cra/src/App.js +++ b/examples/base-ui-cra/src/App.js @@ -6,8 +6,8 @@ export default function App() {

Base UI + Create React App scaffold (JavaScript)

- Base UI is a library of unstyled React UI components - and hooks. + Base UI is a library of + unstyled React UI components and hooks.
Create React App is a framework for quickly diff --git a/scripts/muiAliases.js b/scripts/muiAliases.js index e3c89edb634447..d33b53702a5fa4 100644 --- a/scripts/muiAliases.js +++ b/scripts/muiAliases.js @@ -1,10 +1,11 @@ const path = require('path'); /** - * @param {'build' | 'src'} type Define if the target should be the built version or the source. - * @param {boolean} isRelative If `true` the path will be relative to the repository root. + * @param {object} params The parameters of the function. + * @param {'build' | 'src'} params.type Define if the target should be the built version or the source. + * @param {boolean | undefined} params.isRelative If `true` the path will be relative to the repository root. */ -function getMuiAliases(type, isRelative = false) { +function getMuiAliases({ type, isRelative = false }) { const workspaceRoot = path.join(__dirname, '..'); const resolveAliasPath = (aliasPath) => { diff --git a/scripts/sizeSnapshot/webpack.config.js b/scripts/sizeSnapshot/webpack.config.js index 59770a8d48d86b..628c5d943dd7d6 100644 --- a/scripts/sizeSnapshot/webpack.config.js +++ b/scripts/sizeSnapshot/webpack.config.js @@ -176,7 +176,7 @@ function createWebpackConfig(entry, environment) { const configuration = { // ideally this would be computed from the bundles peer dependencies // Ensure that `react` as well as `react/*` are considered externals but not `react*` - externals: /^(date-fns|dayjs|luxon|moment|react|react-dom)(\/.*)?$/, + externals: /^(react|react-dom)(\/.*)?$/, mode: 'production', optimization: { concatenateModules, @@ -209,7 +209,7 @@ function createWebpackConfig(entry, environment) { }), ], resolve: { - alias: getMuiAliases('build'), + alias: getMuiAliases({ type: 'build' }), }, entry: { [entry.id]: path.join(workspaceRoot, entry.path) }, // TODO: 'browserslist:modern' diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 0ac91ced67b343..3aac6f21668aef 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -9,7 +9,7 @@ module.exports = { context: path.resolve(__dirname), resolve: { modules: [__dirname, 'node_modules'], - alias: getMuiAliases('src'), + alias: getMuiAliases({ type: 'src' }), extensions: ['.js', '.ts', '.tsx', '.d.ts'], }, }; From 176d98a69e983150ef4eb272b76f9b9cbc1dfc92 Mon Sep 17 00:00:00 2001 From: delangle Date: Thu, 21 Sep 2023 11:56:31 +0200 Subject: [PATCH 11/13] Work --- test/karma.conf.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/karma.conf.js b/test/karma.conf.js index b0dc232a68b2ee..576b85908bf726 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -133,6 +133,43 @@ module.exports = function setKarmaConfig(config) { envName: 'stable', }, }, + // Transpile dependencies outside this repository with dependencies in this repository + // TODO: Remove when the lab will stop exporting components from `@mui/x-tree-view` + { + test: /\.(js|mjs|jsx)$/, + include: /node_modules(\/|\\)@mui(\/|\\)x-tree-view/, + use: { + loader: 'babel-loader', + options: { + // We have to apply `babel-plugin-module-resolve` to the files in `@mui/x-tree-view`. + // Otherwise, we can't import `@mui/material` from `@mui/x-tree-view` in `yarn test:karma`. + sourceType: 'unambiguous', + plugins: [ + [ + 'babel-plugin-module-resolver', + { + alias: { + // all packages in this monorepo + '@mui/material': './packages/mui-material/src', + '@mui/docs': './packages/mui-docs/src', + '@mui/icons-material': './packages/mui-icons-material/lib', + '@mui/lab': './packages/mui-lab/src', + '@mui/styled-engine': './packages/mui-styled-engine/src', + '@mui/styles': './packages/mui-styles/src', + '@mui/system': './packages/mui-system/src', + '@mui/private-theming': './packages/mui-private-theming/src', + '@mui/utils': './packages/mui-utils/src', + '@mui/base': './packages/mui-base/src', + '@mui/material-next': './packages/mui-material-next/src', + '@mui/joy': './packages/mui-joy/src', + }, + transformFunctions: ['require'], + }, + ], + ], + }, + }, + }, { test: /\.(js|mjs|ts|tsx)$/, use: { From ab98a0cbd57cad5798a74351583c11ff9433ca41 Mon Sep 17 00:00:00 2001 From: delangle Date: Thu, 21 Sep 2023 11:59:03 +0200 Subject: [PATCH 12/13] Work --- test/karma.conf.js | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/test/karma.conf.js b/test/karma.conf.js index 576b85908bf726..e7721be2e35ea0 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,6 +1,7 @@ const path = require('path'); const playwright = require('playwright'); const webpack = require('webpack'); +const getMuiAliases = require('../scripts/muiAliases'); const CI = Boolean(process.env.CI); // renovate PRs are based off of upstream branches. @@ -148,21 +149,7 @@ module.exports = function setKarmaConfig(config) { [ 'babel-plugin-module-resolver', { - alias: { - // all packages in this monorepo - '@mui/material': './packages/mui-material/src', - '@mui/docs': './packages/mui-docs/src', - '@mui/icons-material': './packages/mui-icons-material/lib', - '@mui/lab': './packages/mui-lab/src', - '@mui/styled-engine': './packages/mui-styled-engine/src', - '@mui/styles': './packages/mui-styles/src', - '@mui/system': './packages/mui-system/src', - '@mui/private-theming': './packages/mui-private-theming/src', - '@mui/utils': './packages/mui-utils/src', - '@mui/base': './packages/mui-base/src', - '@mui/material-next': './packages/mui-material-next/src', - '@mui/joy': './packages/mui-joy/src', - }, + alias: getMuiAliases({ type: 'src', isRelative: true }), transformFunctions: ['require'], }, ], From ac3878de80f17beff444cf3b01d19b8ac162b34d Mon Sep 17 00:00:00 2001 From: delangle Date: Thu, 21 Sep 2023 13:31:30 +0200 Subject: [PATCH 13/13] Work --- babel.config.js | 2 +- scripts/muiAliases.js | 5 +++-- webpackBaseConfig.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/babel.config.js b/babel.config.js index 5643b9f93f5e16..68a4460b4a757b 100644 --- a/babel.config.js +++ b/babel.config.js @@ -9,8 +9,8 @@ const productionPlugins = [ ]; module.exports = function getBabelConfig(api) { - const muiAliases = getMuiAliases({ type: 'src', isRelative: true }); const useESModules = api.env(['regressions', 'legacy', 'modern', 'stable', 'rollup']); + const muiAliases = getMuiAliases({ type: 'src', isRelative: true, useESIcons: useESModules }); const presets = [ [ diff --git a/scripts/muiAliases.js b/scripts/muiAliases.js index d33b53702a5fa4..7fb2889ac3b4bd 100644 --- a/scripts/muiAliases.js +++ b/scripts/muiAliases.js @@ -4,8 +4,9 @@ const path = require('path'); * @param {object} params The parameters of the function. * @param {'build' | 'src'} params.type Define if the target should be the built version or the source. * @param {boolean | undefined} params.isRelative If `true` the path will be relative to the repository root. + * @param {boolean | undefined} params.useESIcons If `true` will use the ES version of `@mui/icons-material`. */ -function getMuiAliases({ type, isRelative = false }) { +function getMuiAliases({ type, isRelative = false, useESIcons = false }) { const workspaceRoot = path.join(__dirname, '..'); const resolveAliasPath = (aliasPath) => { @@ -23,7 +24,7 @@ function getMuiAliases({ type, isRelative = false }) { '@mui/base': resolveAliasPath(`packages/mui-base/${type}`), '@mui/docs': resolveAliasPath(`packages/mui-docs/${type}`), '@mui/icons-material': resolveAliasPath( - `packages/mui-icons-material/${type === 'src' ? 'lib' : 'build'}`, + `packages/mui-icons-material/lib${useESIcons ? '/esm' : ''}`, ), '@mui/joy': resolveAliasPath(`packages/mui-joy/${type}`), '@mui/lab': resolveAliasPath(`packages/mui-lab/${type}`), diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index 3aac6f21668aef..a136cd4c3ca07d 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -9,7 +9,7 @@ module.exports = { context: path.resolve(__dirname), resolve: { modules: [__dirname, 'node_modules'], - alias: getMuiAliases({ type: 'src' }), + alias: getMuiAliases({ type: 'src', useESIcons: true }), extensions: ['.js', '.ts', '.tsx', '.d.ts'], }, };