From 8212d3d5d1de0a7f052f5271f0200d9ff3d4cc69 Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Sat, 26 Aug 2023 09:02:10 +0200 Subject: [PATCH] [core] Fix ESM issues with regression tests (#37963) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- babel.config.js | 37 ++++++++++++++++-------------- docs/package.json | 2 +- test/e2e/webpack.config.js | 1 + test/regressions/webpack.config.js | 5 +++- tsconfig.json | 1 + webpackBaseConfig.js | 3 ++- yarn.lock | 33 ++++++++++++++++++-------- 7 files changed, 53 insertions(+), 29 deletions(-) diff --git a/babel.config.js b/babel.config.js index 6a0a54d455f095..4b2db95b51a9b5 100644 --- a/babel.config.js +++ b/babel.config.js @@ -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 = [ [ diff --git a/docs/package.json b/docs/package.json index 10d674c06132c8..b9f26d15bd1d6c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/test/e2e/webpack.config.js b/test/e2e/webpack.config.js index f8fcb9b0bcc200..dd10685c681072 100644 --- a/test/e2e/webpack.config.js +++ b/test/e2e/webpack.config.js @@ -31,6 +31,7 @@ module.exports = { options: { cacheDirectory: true, configFile: path.resolve(__dirname, '../../babel.config.js'), + envName: 'regressions', }, }, { diff --git a/test/regressions/webpack.config.js b/test/regressions/webpack.config.js index 0c2e6c4e25cdbc..f01402c61451df 100644 --- a/test/regressions/webpack.config.js +++ b/test/regressions/webpack.config.js @@ -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'), @@ -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', }, }, { diff --git a/tsconfig.json b/tsconfig.json index ff9e54bfb84492..7caf992444606a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"], diff --git a/webpackBaseConfig.js b/webpackBaseConfig.js index a12b5c108f60e0..0b9c59bdf248fb 100644 --- a/webpackBaseConfig.js +++ b/webpackBaseConfig.js @@ -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'), diff --git a/yarn.lock b/yarn.lock index 0663eeb04eb04b..e3bd0cc995c577 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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/runtime@7.0.0", "@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" @@ -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" @@ -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" @@ -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: