Skip to content
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] Ship modern bundle #22814

Merged
merged 26 commits into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6b587b7
[core] Ship modern bundle
eps1lon Sep 29, 2020
0e11b39
Fix `yarn extract-error-codes`
eps1lon Sep 30, 2020
8a75f9c
Update engines
eps1lon Sep 30, 2020
acfead4
Use esm babel helpers when using ES6 modules
eps1lon Sep 30, 2020
8994e78
Forgot op_mini
eps1lon Sep 30, 2020
da4cd9b
Use `stable` bundle as default
eps1lon Sep 30, 2020
eae0e0a
Fix issues related to assumed transpilation
eps1lon Oct 1, 2020
14bf563
Fix stable bundle targets
eps1lon Oct 1, 2020
1e7339d
Fix failing initMatchers test
eps1lon Oct 1, 2020
a242deb
Fix grid related issues in safari
eps1lon Oct 1, 2020
b592197
Proper snapshot with mobileToDesktop
eps1lon Oct 2, 2020
c544f29
Reduce noise from chunks
eps1lon Oct 2, 2020
426ad90
Update caniuse
eps1lon Oct 2, 2020
a5193c9
Use new bundle in UMD build
eps1lon Oct 2, 2020
2ae909a
Improved docs :)
eps1lon Oct 5, 2020
4a1eef2
Remove unused polyfills
eps1lon Oct 5, 2020
1722f29
Fix event targets
eps1lon Oct 5, 2020
fa336f5
Merge branch 'next' into feat/new-bundling
eps1lon Oct 6, 2020
27172be
Add note about node 10 (later 12)
eps1lon Oct 6, 2020
11cb3e5
Add changelog entry
eps1lon Oct 6, 2020
00454f3
Merge branch 'next' into feat/new-bundling
eps1lon Oct 6, 2020
840e29e
Track modern bundle
eps1lon Oct 6, 2020
950bc1f
Apply suggestions from code review
eps1lon Oct 6, 2020
a1229c0
Merge branch 'next' into feat/new-bundling
eps1lon Oct 7, 2020
92f8719
Merge branch 'next' into feat/new-bundling
eps1lon Oct 12, 2020
d565045
Merge branch 'next' into feat/new-bundling
eps1lon Oct 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 67 additions & 6 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
ie 11
edge >= 14
firefox >= 52
chrome >= 49
safari >= 10
node 8.0
[modern]
last 1 chrome version
last 1 edge version
last 1 firefox version
last 1 safari version
node 14

# Default/Fallback
# `npx browserslist --mobile-to-desktop "> 0.5%, last 2 versions, Firefox ESR, not dead, not IE 11"` when the last major is released.
# #stable-snapshot
[stable]
and_chr 84
and_ff 79
and_qq 10.4
and_uc 12.12
android 84
baidu 7.12
chrome 83
edge 83
firefox 68
ios_saf 12.0
kaios 2.5
op_mini all
op_mob 69
opera 69
safari 13
samsung 11.1

# Same as `stable` but with IE 11
[legacy]
IE 11
and_chr 84
and_ff 79
and_qq 10.4
and_uc 12.12
android 84
baidu 7.12
chrome 83
edge 83
firefox 68
ios_saf 12.0
kaios 2.5
op_mini all
op_mob 69
opera 69
safari 13
samsung 11.1

# snapshot of `npx browserslist "maintained node versions"`
[node]
node 10.0

# same as `node`
[coverage]
node 10.0

# same as `node`
[development]
node 10.0

# same as `node`
[test]
node 10.0

# same as `node`
[benchmark]
node 10.0
187 changes: 100 additions & 87 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,6 @@ const path = require('path');
const errorCodesPath = path.resolve(__dirname, './docs/public/static/error-codes.json');
const missingError = process.env.MUI_EXTRACT_ERROR_CODES === 'true' ? 'write' : 'annotate';

let defaultPresets;

// We release a ES version of Material-UI.
// It's something that matches the latest official supported features of JavaScript.
// Nothing more (stage-1, etc), nothing less (require, etc).
if (process.env.BABEL_ENV === 'es') {
defaultPresets = [];
} else {
defaultPresets = [
[
'@babel/preset-env',
{
bugfixes: true,
modules: ['esm', 'production-umd'].includes(process.env.BABEL_ENV) ? false : 'commonjs',
},
],
];
}

const defaultAlias = {
'@material-ui/core': './packages/material-ui/src',
'@material-ui/docs': './packages/material-ui-docs/src',
Expand All @@ -46,9 +27,25 @@ const productionPlugins = [
],
];

module.exports = {
presets: defaultPresets.concat(['@babel/preset-react', '@babel/preset-typescript']),
plugins: [
module.exports = function getBabelConfig(api) {
const useESModules = api.env(['legacy', 'modern', 'stable']);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading this right that legacy SHOULD use ESModules? This is almost certainly a mistake, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this stands for legacy ESM.

From microbundle readme:

	"module": "./dist/foo.module.js", // legacy ES Modules output (for bundlers)
	"exports": "./dist/foo.modern.js", // modern ES2017 output

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading this right that legacy SHOULD use ESModules? This is almost certainly a mistake, right?

Could you open an issue and fill out the template to describe the mistake? Discussions on merged PRs are oftentimes forgotten.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I thought legacy was for ancient browsers like ie11, it seems that I might be incorrect about that. Thanks for the explanation, sorry for the mis-informed question. Have a nice day.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

legacy is for IE11. But IE11 does not understand ES modules nor CommonJS modules i.e. the code always needs a bundler anyway at which point we might as well ship ES modules to help tree-shaking.


const presets = [
[
'@babel/preset-env',
{
bugfixes: true,
browserslistEnv: process.env.BABEL_ENV || process.env.NODE_ENV,
debug: process.env.MUI_BUILD_VERBOSE === 'true',
modules: useESModules ? false : 'commonjs',
shippedProposals: api.env('modern'),
},
],
'@babel/preset-react',
'@babel/preset-typescript',
];

const plugins = [
[
'babel-plugin-macros',
{
Expand All @@ -59,77 +56,93 @@ module.exports = {
},
],
'babel-plugin-optimize-clsx',
// Need the following 3 proposals for all targets in .browserslistrc.
// With our usage the transpiled loose mode is equivalent to spec mode.
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-proposal-object-rest-spread', { loose: true }],
// any package needs to declare 7.4.4 as a runtime dependency. default is ^7.0.0
['@babel/plugin-transform-runtime', { version: '^7.4.4' }],
// for IE 11 support
'@babel/plugin-transform-object-assign',
],
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
cjs: {
plugins: productionPlugins,
},
coverage: {
plugins: [
'babel-plugin-istanbul',
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
[
'@babel/plugin-transform-runtime',
{
useESModules,
// any package needs to declare 7.4.4 as a runtime dependency. default is ^7.0.0
version: '^7.4.4',
},
],
];

if (process.env.NODE_ENV === 'production') {
plugins.push(...productionPlugins);
}
if (process.env.NODE_ENV === 'test') {
plugins.push([
'babel-plugin-module-resolver',
{
alias: defaultAlias,
root: ['./'],
},
]);
}

return {
presets,
plugins,
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
coverage: {
plugins: [
'babel-plugin-istanbul',
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
],
],
],
},
development: {
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
modules: './modules',
},
development: {
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
modules: './modules',
},
},
},
],
],
],
},
esm: {
plugins: [...productionPlugins, ['@babel/plugin-transform-runtime', { useESModules: true }]],
},
es: {
plugins: [...productionPlugins, ['@babel/plugin-transform-runtime', { useESModules: true }]],
},
production: {
plugins: [...productionPlugins, ['@babel/plugin-transform-runtime', { useESModules: true }]],
},
'production-umd': {
plugins: [...productionPlugins, ['@babel/plugin-transform-runtime', { useESModules: true }]],
},
test: {
sourceMaps: 'both',
plugins: [
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
},
legacy: {
plugins: [
// IE 11 support
'@babel/plugin-transform-object-assign',
],
],
},
benchmark: {
plugins: [
...productionPlugins,
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
},
test: {
sourceMaps: 'both',
plugins: [
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
],
],
],
},
benchmark: {
plugins: [
...productionPlugins,
[
'babel-plugin-module-resolver',
{
root: ['./'],
alias: defaultAlias,
},
],
],
},
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@
## Browser

Material-UI supports the latest, stable releases of all major browsers and platforms.
It also supports Internet Explorer 11.
You don't need to provide any JavaScript polyfill as it manages unsupported browser features internally and in isolation.

| IE | Edge | Firefox | Chrome | Safari | Googlebot |
| :-- | :---- | :------ | :----- | :----- | :-------- |
| 11 | >= 14 | >= 52 | >= 49 | >= 10 | ✅ |
<!-- #stable-snapshot -->

| Edge | Firefox | Chrome | Safari |
| :---- | :------ | :----- | :----- |
| >= 83 | >= 68 | >= 83 | >= 13 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure about the flexbox bug but I'll look again through the codebase for older polyfills. They should be part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or let's go over them when going over built-ins


If you need to support IE 11, check out our [legacy bundle](/guides/minimizing-bundle-size#legacy-bundle).
eps1lon marked this conversation as resolved.
Show resolved Hide resolved

Because Googlebot uses a web rendering service (WRS) to index the page content, it's critical that Material-UI supports it.
[WRS regularly updates the rendering engine it uses](https://webmasters.googleblog.com/2019/05/the-new-evergreen-googlebot.html).
You can expect Material-UI's components to render without major issues.

## Server

Because Material-UI supports server-side rendering, it needs to support the latest, stable releases of [Node.js](https://github.com/nodejs/node).
Where possible, the [LTS versions that are in maintenance](https://github.com/nodejs/Release#lts-schedule1) are supported. We recommend using **node v10.x** or newer. However we still support **node v8.x**. The support of **node v8.x** will be stopped in Material-UI Version 5.
<!-- #stable-snapshot -->

We support [Node.js](https://github.com/nodejs/node) starting with version 10 for server-side rendering.
Where possible, the [LTS versions that are in maintenance](https://github.com/nodejs/Release#lts-schedule1) are supported.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicitly mention node v10? Also, have you considered starting at v12?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicitly mention node v10?

Definitely.

Also, have you considered starting at v12?

Will probably be node 12 on release. I think it makes sense to require node 12 even if we release a bit before LTS end. Otherwise we're stuck with it for the lifetime of v5.

The stable bundle will change when releasing @material-ui/core@latest. It's just a snapshot of the current state of the browserslist query.

I'll emphasise this more in the PR, add maintained node versions as a hint for node and also need to add an entry in migration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Where possible, the [LTS versions that are in maintenance](https://github.com/nodejs/Release#lts-schedule1) are supported.
Where possible, the [LTS versions that are in maintenance](https://github.com/nodejs/Release#release-schedule) are supported.

Realised this link hash no longer exists


### CSS prefixing

Expand Down
19 changes: 19 additions & 0 deletions docs/src/pages/guides/migration-v4/migration-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,25 @@ yarn add @material-ui/core@next

## Handling breaking changes

### Supported browsers and node versions

The targets of the default bundle have changed.
The exact versions will be pinned on release from the browserslist query `"> 0.5%, last 2 versions, Firefox ESR, not dead, not IE 11, maintained node versions"`.

The default bundle now supports:

<!-- #stable-snapshot -->

- Node 10 (up from 8)
- Chrome 83 (up from 49)
- Edge 83 (up from 14)
- Firefox 68 (up from 52)
- Safari 13 (up from 10)
- and more (see [.browserslistrc (`stable` entry)](https://github.com/mui-org/material-ui/blob/HEAD/.browserslistrc#L11))

It no longer supports IE 11.
If you need to support IE 11, check out our [legacy bundle](/guides/minimizing-bundle-size#legacy-bundle).
eps1lon marked this conversation as resolved.
Show resolved Hide resolved

### non-ref-forwarding class components

Support for non-ref-forwarding class components in the `component` prop or as an immediate `children` has been dropped. If you were using `unstable_createStrictModeTheme` or didn't see any warnings related to `findDOMNode` in `React.StrictMode` then you don't need to do anything.
Expand Down
Loading