Skip to content

Commit

Permalink
[core] Fix ESM issues with regression tests (#37963)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
Janpot and renovate[bot] authored Aug 26, 2023
1 parent 321b200 commit 8212d3d
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 29 deletions.
37 changes: 20 additions & 17 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@ function resolveAliasPath(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 productionPlugins = [
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
];

module.exports = function getBabelConfig(api) {
const useESModules = api.env(['legacy', 'modern', 'stable', 'rollup']);
const useESModules = api.env(['regressions', 'legacy', 'modern', 'stable', 'rollup']);

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${useESModules ? '/esm' : ''}`,
),
'@mui/lab': resolveAliasPath('./packages/mui-lab/src'),
'@mui/markdown': resolveAliasPath('./packages/markdown'),
'@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 presets = [
[
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"react-dom": "^18.2.0",
"react-draggable": "^4.4.5",
"react-final-form": "^6.5.9",
"react-imask": "^6.6.3",
"react-imask": "^7.1.3",
"react-intersection-observer": "^9.5.2",
"react-is": "^18.2.0",
"react-number-format": "^5.3.0",
Expand Down
1 change: 1 addition & 0 deletions test/e2e/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
options: {
cacheDirectory: true,
configFile: path.resolve(__dirname, '../../babel.config.js'),
envName: 'regressions',
},
},
{
Expand Down
5 changes: 4 additions & 1 deletion test/regressions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
// Helps debugging and build perf.
// Bundle size is irrelevant for local serving
minimize: false,
concatenateModules: false,
},
output: {
path: path.resolve(__dirname, './build'),
Expand All @@ -32,11 +33,13 @@ module.exports = {
rules: [
{
test: /\.(js|ts|tsx)$/,
exclude: /node_modules/,
// prism.js blocks @mui/markdown/prism from being interpreted as ESM in this build.
exclude: /node_modules|prism\.js/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
configFile: path.resolve(__dirname, '../../babel.config.js'),
envName: 'regressions',
},
},
{
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@mui/lab": ["./packages/mui-lab/src"],
"@mui/lab/*": ["./packages/mui-lab/src/*"],
"@mui/markdown": ["./packages/markdown"],
"@mui/markdown/*": ["./packages/markdown/*"],
"@mui/styled-engine": ["./packages/mui-styled-engine/src"],
"@mui/styled-engine/*": ["./packages/mui-styled-engine/src/*"],
"@mui/styled-engine-sc": ["./packages/mui-styled-engine-sc/src"],
Expand Down
3 changes: 2 additions & 1 deletion webpackBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module.exports = {
resolve: {
modules: [__dirname, 'node_modules'],
alias: {
'@mui/markdown': path.resolve(__dirname, './packages/markdown'),
'@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/icons-material': path.resolve(__dirname, './packages/mui-icons-material/lib/esm'),
'@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'),
Expand Down
33 changes: 24 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1302,6 +1302,14 @@
core-js "^2.6.12"
regenerator-runtime "^0.14.0"

"@babel/runtime-corejs3@^7.22.6":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.22.10.tgz#5ecc3d32faa70009f084cc2e087d79e5f5cdcca9"
integrity sha512-IcixfV2Jl3UrqZX4c81+7lVg5++2ufYJyAFW3Aux/ZTvY6LVYYhJ9rMgnbX0zGVq6eqfVpnoatTjZdVki/GmWA==
dependencies:
core-js-pure "^3.30.2"
regenerator-runtime "^0.14.0"

"@babel/[email protected]", "@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.0", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.18.3", "@babel/runtime@^7.2.0", "@babel/runtime@^7.20.6", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.22.10", "@babel/runtime@^7.22.6", "@babel/runtime@^7.3.1", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.10.tgz#ae3e9631fd947cb7e3610d3e9d8fef5f76696682"
Expand Down Expand Up @@ -6209,6 +6217,11 @@ core-js-compat@^3.31.0:
dependencies:
browserslist "^4.21.9"

core-js-pure@^3.30.2:
version "3.32.1"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.32.1.tgz#5775b88f9062885f67b6d7edce59984e89d276f3"
integrity sha512-f52QZwkFVDPf7UEQZGHKx6NYxsxmVGJe5DIvbzOdRMJlmT6yv0KDjR8rmy3ngr/t5wU54c7Sp/qIJH0ppbhVpQ==

core-js@^2.6.11, core-js@^2.6.12:
version "2.6.12"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec"
Expand Down Expand Up @@ -9435,10 +9448,12 @@ ignore@^5.0.4, ignore@^5.1.4, ignore@^5.2.0, ignore@^5.2.4:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324"
integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==

imask@^6.6.3:
version "6.6.3"
resolved "https://registry.yarnpkg.com/imask/-/imask-6.6.3.tgz#f9619cea770b97b5ef616acb036d27cf4a1b33d8"
integrity sha512-a9MTDhm+ET4G2IRcdUGuVTXHS05WsRNPGM5CeNJnXiXuoi4zv7g0/UDFLlRF4lBBeb8EWds4C4JVwhI0nuAIug==
imask@^7.1.3:
version "7.1.3"
resolved "https://registry.yarnpkg.com/imask/-/imask-7.1.3.tgz#d07e6f50effe353630323a58baf25c2f7a83c2eb"
integrity sha512-jZCqTI5Jgukhl2ff+znBQd8BiHOTlnFYCIgggzHYDdoJsHmSSWr1BaejcYBxsjy4ZIs8Rm0HhbOxQcobcdESRQ==
dependencies:
"@babel/runtime-corejs3" "^7.22.6"

immediate@~3.0.5:
version "3.0.6"
Expand Down Expand Up @@ -13825,12 +13840,12 @@ react-final-form@^6.5.9:
dependencies:
"@babel/runtime" "^7.15.4"

react-imask@^6.6.3:
version "6.6.3"
resolved "https://registry.yarnpkg.com/react-imask/-/react-imask-6.6.3.tgz#febb3fb62e098d5cb51537e591bb2b6f7a7676ff"
integrity sha512-ZjqKXqBtc1LlFQWEj/SNuk4rQWXDdzLnDqCfNMnqdHHMqSvD1J+JuQZTuWgCCr5cLJxaXshDHW5AmhClk367Gw==
react-imask@^7.1.3:
version "7.1.3"
resolved "https://registry.yarnpkg.com/react-imask/-/react-imask-7.1.3.tgz#bb0131c643678532005f266e7df6d54b117eeaf6"
integrity sha512-anCnzdkqpDzNwe7ot76kQSvmnz4Sw7AW/QFjjLh3B87HVNv9e2oHC+1m9hQKSIui2Tqm7w68ooMgDFsCQlDMyg==
dependencies:
imask "^6.6.3"
imask "^7.1.3"
prop-types "^15.8.1"

react-intersection-observer@^9.5.2:
Expand Down

0 comments on commit 8212d3d

Please sign in to comment.