Skip to content

Commit 18e065d

Browse files
[code-infra] Remove modern bundles (#45808)
Signed-off-by: Jan Potoms <[email protected]> Co-authored-by: Sam Sycamore <[email protected]>
1 parent 204e1ca commit 18e065d

File tree

19 files changed

+37
-123
lines changed

19 files changed

+37
-123
lines changed

.browserslistrc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
[modern]
2-
last 1 chrome version
3-
last 1 edge version
4-
last 1 firefox version
5-
last 1 safari version
6-
node 14
7-
81
# Default/Fallback
92
# `npx browserslist --mobile-to-desktop "> 0.5%, last 2 versions, Firefox ESR, not dead, safari >= 15.4, iOS >= 15.4"` when the last major is released.
103
# Explicit safari versions are here based on the agreed terms in: https://github.com/mui/material-ui/issues/40958#issuecomment-1953215043

babel.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function resolveAliasPath(relativeToBabelConf) {
1919

2020
/** @type {babel.ConfigFunction} */
2121
module.exports = function getBabelConfig(api) {
22-
const useESModules = api.env(['regressions', 'modern', 'stable']);
22+
const useESModules = api.env(['regressions', 'stable']);
2323

2424
const defaultAlias = {
2525
'@mui/material': resolveAliasPath('./packages/mui-material/src'),
@@ -50,7 +50,6 @@ module.exports = function getBabelConfig(api) {
5050
browserslistEnv: api.env() || process.env.NODE_ENV,
5151
debug: process.env.MUI_BUILD_VERBOSE === 'true',
5252
modules: useESModules ? false : 'commonjs',
53-
shippedProposals: api.env('modern'),
5453
},
5554
],
5655
[

docs/data/material/guides/minimizing-bundle-size/minimizing-bundle-size.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -198,52 +198,3 @@ It will perform the following diffs:
198198
-import TextField from '@mui/material/TextField';
199199
+import { Button, TextField } from '@mui/material';
200200
```
201-
202-
## Available bundles
203-
204-
### Default bundle
205-
206-
The packages published on npm are **transpiled** with [Babel](https://github.com/babel/babel), optimized for performance with the [supported platforms](/material-ui/getting-started/supported-platforms/).
207-
208-
A [modern bundle](#modern-bundle) is also available.
209-
210-
### How to use custom bundles?
211-
212-
:::error
213-
You are strongly discouraged to:
214-
215-
- Import from any of the custom bundles directly. Do not do this:
216-
217-
```js
218-
import { Button } from '@mui/material/modern';
219-
```
220-
221-
You have no guarantee that the dependencies use the `modern` bundle, leading to module duplication in your JavaScript files.
222-
223-
- Import from any of the undocumented files or folders. Do not do this:
224-
225-
```js
226-
import { Button } from '@mui/material/esm';
227-
```
228-
229-
You have no guarantee that these imports will continue to work from one version to the next.
230-
231-
:::
232-
233-
A great way to use these bundles is to configure bundler export conditions, for example with [webpack's `resolve.conditionNames`](https://webpack.js.org/configuration/resolve/#resolveconditionnames) or [vite's `resolve.conditions`](https://vite.dev/config/shared-options#resolve-conditions):
234-
235-
```js
236-
// webpack.config.js
237-
{
238-
resolve: {
239-
conditionNames: ['mui-modern', '...'],
240-
}
241-
}
242-
243-
// vite.config.js
244-
{
245-
resolve: {
246-
conditions: ['mui-modern', 'module', 'browser', 'development|production']
247-
}
248-
}
249-
```

docs/data/material/migration/upgrade-to-v7/upgrade-to-v7.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,30 @@ Deep imports with more than one level are no longer working, at all (they were a
9393

9494
This was never officially supported, but now it will be restricted by bundlers and runtimes.
9595

96-
To use the modern bundle (which excludes legacy browser support for smaller bundle size), you'll need to configure your bundler to use the "mui-modern" exports condition:
96+
Modern bundles have also been removed, as the potential for a smaller bundle size is no longer significant.
97+
If you've configured aliases for these bundles, you must remove them now.
9798

98-
```js
99-
// webpack.config.js
100-
{
101-
resolve: {
102-
conditionNames: ['mui-modern', '...'],
103-
}
104-
}
105-
106-
// vite.config.js
107-
{
108-
resolve: {
109-
conditions: ['mui-modern', 'module', 'browser', 'development|production']
110-
}
111-
}
99+
```diff
100+
{
101+
resolve: {
102+
alias: {
103+
- '@mui/material': '@mui/material/modern',
104+
- '@mui/styled-engine': '@mui/styled-engine/modern',
105+
- '@mui/system': '@mui/system/modern',
106+
- '@mui/base': '@mui/base/modern',
107+
- '@mui/utils': '@mui/utils/modern',
108+
- '@mui/lab': '@mui/lab/modern',
109+
}
110+
}
111+
}
112112
```
113113

114+
:::info
115+
Earlier versions of this guide mention the existence of a `mui-modern` conditional exports.
116+
This has since been removed.
117+
This is a non-breaking change, and your bundler will fall back to the ESM bundle.
118+
:::
119+
114120
If you are using a Vite alias to force ESM imports for the icons package, you should remove it as it's no longer necessary:
115121

116122
```diff

packages/mui-base/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"url": "https://opencollective.com/mui-org"
2828
},
2929
"scripts": {
30-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
31-
"build:modern": "node ../../scripts/build.mjs modern",
30+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3231
"build:node": "node ../../scripts/build.mjs node",
3332
"build:stable": "node ../../scripts/build.mjs stable",
3433
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/mui/material-ui/tree/master/packages/mui-docs",
2525
"scripts": {
26-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
26+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
2727
"build:modern": "echo 'Skip modern build'",
2828
"build:node": "node ../../scripts/build.mjs node",
2929
"build:stable": "node ../../scripts/build.mjs stable",

packages/mui-joy/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"url": "https://opencollective.com/mui-org"
2626
},
2727
"scripts": {
28-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
29-
"build:modern": "node ../../scripts/build.mjs modern",
28+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3029
"build:node": "node ../../scripts/build.mjs node",
3130
"build:stable": "node ../../scripts/build.mjs stable",
3231
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-lab/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"url": "https://opencollective.com/mui-org"
2929
},
3030
"scripts": {
31-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
32-
"build:modern": "node ../../scripts/build.mjs modern",
31+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3332
"build:node": "node ../../scripts/build.mjs node",
3433
"build:stable": "node ../../scripts/build.mjs stable",
3534
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-material-nextjs/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"url": "https://opencollective.com/mui-org"
2525
},
2626
"scripts": {
27-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
28-
"build:modern": "node ../../scripts/build.mjs modern",
27+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
2928
"build:node": "node ../../scripts/build.mjs node",
3029
"build:stable": "node ../../scripts/build.mjs stable",
3130
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-material-pigment-css/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs styles.css",

packages/mui-material/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
"url": "https://opencollective.com/mui-org"
2828
},
2929
"scripts": {
30-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
31-
"build:modern": "node ../../scripts/build.mjs modern",
30+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3231
"build:node": "node ../../scripts/build.mjs node",
3332
"build:stable": "node ../../scripts/build.mjs stable",
3433
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-private-theming/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-styled-engine-sc/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-styled-engine/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-system/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs",

packages/mui-types/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
},
2323
"homepage": "https://github.com/mui/material-ui/tree/master/packages/mui-types",
2424
"scripts": {
25-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
26-
"build:modern": "node ../../scripts/build.mjs modern",
25+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
2726
"build:node": "node ../../scripts/build.mjs node",
2827
"build:stable": "node ../../scripts/build.mjs stable",
2928
"build:types": "tsx ../../scripts/buildTypes.mts",

packages/mui-utils/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
"url": "https://opencollective.com/mui-org"
2727
},
2828
"scripts": {
29-
"build": "pnpm build:modern && pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
30-
"build:modern": "node ../../scripts/build.mjs modern",
29+
"build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files",
3130
"build:node": "node ../../scripts/build.mjs node",
3231
"build:stable": "node ../../scripts/build.mjs stable",
3332
"build:copy-files": "node ../../scripts/copyFiles.mjs",

scripts/build.mjs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ import { getVersionEnvVariables, getWorkspaceRoot } from './utils.mjs';
99
const exec = promisify(childProcess.exec);
1010

1111
const validBundles = [
12-
// modern build with a rolling target using ES6 modules
13-
'modern',
1412
// build for node using commonJS modules
1513
'node',
1614
// build with a hardcoded target using ES6 modules
1715
'stable',
1816
];
1917

2018
const bundleTypes = {
21-
modern: 'module',
2219
stable: 'module',
2320
node: 'commonjs',
2421
};
@@ -60,7 +57,6 @@ async function run(argv) {
6057

6158
const relativeOutDir = {
6259
node: cjsDir,
63-
modern: './modern',
6460
stable: './esm',
6561
}[bundle];
6662

@@ -113,10 +109,9 @@ async function run(argv) {
113109
// `--extensions-.cjs --out-file-extension .cjs`
114110
await cjsCopy({ from: srcDir, to: outDir });
115111

116-
// Write a package.json file in the output directory if we are building the modern or stable bundle
112+
// Write a package.json file in the output directory if we are building the stable bundle
117113
// or if the output directory is not the root of the package.
118-
const shouldWriteBundlePackageJson =
119-
bundle === 'modern' || bundle === 'stable' || relativeOutDir !== './';
114+
const shouldWriteBundlePackageJson = bundle === 'stable' || relativeOutDir !== './';
120115
if (shouldWriteBundlePackageJson && !argv.skipEsmPkg) {
121116
const rootBundlePackageJson = path.join(outDir, 'package.json');
122117
await fs.writeFile(

scripts/copyFilesUtils.mjs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ export async function cjsCopy({ from, to }) {
104104
}
105105

106106
const srcCondition = 'mui-src';
107-
const modernCondition = 'mui-modern';
108-
const polyfillLegacyModern = false;
109-
const legacyModernPrefix = './modern';
110107

111108
function createExportFor(exportName, conditions) {
112109
if (typeof conditions === 'object' && conditions) {
@@ -126,10 +123,6 @@ function createExportFor(exportName, conditions) {
126123
types: `./esm/${baseName}.d.ts`,
127124
default: `./esm/${baseName}.js`,
128125
},
129-
[modernCondition]: {
130-
types: `./modern/${baseName}.d.ts`,
131-
default: `./modern/${baseName}.js`,
132-
},
133126
...rest,
134127
},
135128
};
@@ -177,17 +170,6 @@ export async function createPackageFile(useEsmExports = false) {
177170
}
178171
}
179172

180-
if (polyfillLegacyModern) {
181-
const exportedNames = new Set(Object.keys(packageExports));
182-
for (const exportedName of exportedNames) {
183-
const modernName = exportedName.replace(/^\./, legacyModernPrefix);
184-
const modernExport = packageExports[exportedName][modernCondition] ?? null;
185-
if (modernExport && !exportedNames.has(modernName)) {
186-
packageExports[modernName] = modernExport;
187-
}
188-
}
189-
}
190-
191173
const newPackageData = useEsmExports
192174
? {
193175
...packageDataOther,

0 commit comments

Comments
 (0)