Skip to content

Commit

Permalink
[code-infra] Avoid aliasing to the monorepo dependencies (#3137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Feb 1, 2024
1 parent 1de30d8 commit 290c0d4
Show file tree
Hide file tree
Showing 4 changed files with 580 additions and 537 deletions.
16 changes: 0 additions & 16 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,12 @@ const { version: transformRuntimeVersion } = fse.readJSONSync(
require.resolve('@babel/runtime-corejs2/package.json'),
);

const errorCodesPath = require.resolve('@mui/monorepo/docs/public/static/error-codes.json');
const missingError = process.env.MUI_EXTRACT_ERROR_CODES === 'true' ? 'write' : 'annotate';

const muiErrorMacro = require.resolve('@mui/monorepo/packages/mui-babel-macros/MuiError.macro');

module.exports = {
presets: [
// backport of https://github.com/zeit/next.js/pull/9511
['next/babel', { 'transform-runtime': { corejs: 2, version: transformRuntimeVersion } }],
],
plugins: [
[
'babel-plugin-macros',
{
muiError: {
errorCodesPath,
missingError,
},
// TODO: Figure out dependency resolution for macros so this hack isn't needed.
resolvePath: () => muiErrorMacro,
},
],
'babel-plugin-optimize-clsx',
// for IE 11 support
'@babel/plugin-transform-object-assign',
Expand Down
21 changes: 5 additions & 16 deletions docs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,8 @@ const { findPages } = require('./src/modules/utils/find');

const MONOREPO_PATH = path.resolve(currentDirectory, '../node_modules/@mui/monorepo');
const MONOREPO_PACKAGES = {
'@mui/base': path.resolve(MONOREPO_PATH, './packages/mui-base/src'),
'@mui/codemod': path.resolve(MONOREPO_PATH, './packages/mui-codemod/src'),
'@mui/docs': path.resolve(MONOREPO_PATH, './packages/mui-docs/src'),
'@mui/envinfo': path.resolve(MONOREPO_PATH, './packages/mui-envinfo'),
'@mui/icons-material': path.resolve(MONOREPO_PATH, './packages/mui-icons-material/lib'),
'@mui/joy': path.resolve(MONOREPO_PATH, './packages/mui-joy/src'),
'@mui/lab': path.resolve(MONOREPO_PATH, './packages/mui-lab/src'),
'@mui/material': path.resolve(MONOREPO_PATH, './packages/mui-material/src'),
'@mui/material-next': path.resolve(MONOREPO_PATH, './packages/mui-material-next/src'),
'@mui/material-nextjs': path.resolve(MONOREPO_PATH, './packages/mui-material-nextjs/src'),
'@mui/private-theming': path.resolve(MONOREPO_PATH, './packages/mui-private-theming/src'),
'@mui/styled-engine': path.resolve(MONOREPO_PATH, './packages/mui-styled-engine/src'),
'@mui/styled-engine-sc': path.resolve(MONOREPO_PATH, './packages/mui-styled-engine-sc/src'),
'@mui/styles': path.resolve(MONOREPO_PATH, './packages/mui-styles'),
'@mui/system': path.resolve(MONOREPO_PATH, './packages/mui-system/src'),
'@mui/types': path.resolve(MONOREPO_PATH, './packages/mui-types'),
'@mui/markdown': path.resolve(MONOREPO_PATH, './packages/markdown'),
'@mui/utils': path.resolve(MONOREPO_PATH, './packages/mui-utils/src'),
};

export default withDocsInfra({
Expand Down Expand Up @@ -88,6 +72,11 @@ export default withDocsInfra({
},
],
},
{
test: /\.+(js|jsx|mjs|ts|tsx)$/,
include: [/(@mui[\\/]monorepo)$/, /(@mui[\\/]monorepo)[\\/](?!.*node_modules)/],
use: options.defaultLoaders.babel,
},
]),
},
};
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@emotion/server": "11.11.0",
"@emotion/styled": "11.11.0",
"@mui/icons-material": "5.15.7",
"@mui/joy": "5.0.0-beta.24",
"@mui/lab": "5.0.0-alpha.163",
"@mui/material": "5.15.7",
"@mui/material-nextjs": "^5.15.7",
Expand Down Expand Up @@ -93,7 +94,6 @@
"@types/doctrine": "0.0.9",
"@types/json-schema": "7.0.15",
"@types/react-is": "18.2.4",
"babel-plugin-macros": "3.1.0",
"cpy-cli": "5.0.0",
"cross-fetch": "4.0.0",
"gm": "1.25.0",
Expand Down
Loading

0 comments on commit 290c0d4

Please sign in to comment.