-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Only define aliases once for TypeScript and once for Webpack + Babel #35197
Changes from all commits
a2d3a00
2be4949
71e2187
fbc0d82
3919518
766651b
c0b7b84
3b3fbe3
02f3b48
6ad4199
0bde12f
88bf1d0
ebd74cf
78b17d7
176d98a
ab98a0c
ac3878d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ | |
"include": ["./src/**/*.ts*"], | ||
"exclude": ["src/**/*.spec.ts*", "src/**/*.test.ts*"], | ||
"references": [ | ||
{ "path": "../mui-utils/tsconfig.build.json" }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to fix the |
||
{ "path": "../mui-base/tsconfig.build.json" }, | ||
{ "path": "../mui-material/tsconfig.build.json" }, | ||
{ "path": "../mui-system/tsconfig.build.json" } | ||
{ "path": "../mui-material/tsconfig.build.json" } | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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, useESIcons = 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': resolveAliasPath(`packages/mui-base/${type}`), | ||
'@mui/docs': resolveAliasPath(`packages/mui-docs/${type}`), | ||
'@mui/icons-material': resolveAliasPath( | ||
`packages/mui-icons-material/lib${useESIcons ? '/esm' : ''}`, | ||
), | ||
'@mui/joy': resolveAliasPath(`packages/mui-joy/${type}`), | ||
'@mui/lab': resolveAliasPath(`packages/mui-lab/${type}`), | ||
'@mui/markdown': resolveAliasPath('packages/markdown'), | ||
'@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'), | ||
}; | ||
} | ||
|
||
module.exports = getMuiAliases; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
@@ -133,36 +134,22 @@ module.exports = function setKarmaConfig(config) { | |
envName: 'stable', | ||
}, | ||
}, | ||
// transpile 3rd party packages with dependencies in this repository | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests are passing without it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need it again for the tree view 😆 |
||
// 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(\/|\\)(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|@mui(\/|\\)x-tree-view)/, | ||
include: /node_modules(\/|\\)@mui(\/|\\)x-tree-view/, | ||
use: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We miss notistack here no? https://mui.com/material-ui/react-snackbar/#notistack. Ah, same for data grid, and all MUI X components no? This logic is meant to help us test fixes for these components, make sure if we break something in Material UI for MUI X, we know it as soon as we work on the PR, not once Material UI is released and MUI X updates it dependencies. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But we don't have any test using those components right? |
||
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`. | ||
// 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', | ||
}, | ||
alias: getMuiAliases({ type: 'src', isRelative: true }), | ||
transformFunctions: ['require'], | ||
}, | ||
], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It now uses the TypeScript aliases
https://nextjs.org/docs/advanced-features/module-path-aliases