Skip to content

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Sep 21, 2023
1 parent ab98a0c commit ac3878d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
[
Expand Down
5 changes: 3 additions & 2 deletions scripts/muiAliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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}`),
Expand Down
2 changes: 1 addition & 1 deletion webpackBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
};

0 comments on commit ac3878d

Please sign in to comment.