-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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] Bundle UMD with rollup #11360
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"build/umd/material-ui.development.js": { | ||
"bundled": 1060251, | ||
"minified": 387201, | ||
"gzipped": 98971 | ||
}, | ||
"build/umd/material-ui.production.min.js": { | ||
"bundled": 891133, | ||
"minified": 346152, | ||
"gzipped": 89531 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import nodeResolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import babel from 'rollup-plugin-babel'; | ||
import replace from 'rollup-plugin-replace'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; | ||
|
||
const input = './src/index.js'; | ||
|
||
const name = 'material-ui'; | ||
|
||
const globals = { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}; | ||
|
||
const getBabelOptions = () => ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something is off. Some babel plugins declared in .babelrc aren't applied. For instance, we still have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, current babelrc is a mess to be honest. It's better to specify targets in browserlist file and completely separate environments with only NODE_ENV. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its done by rollup plugin replace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's why sizes of bundles are different |
||
exclude: /node_modules/, | ||
// We are using @babel/plugin-transform-runtime | ||
runtimeHelpers: true, | ||
}); | ||
|
||
const getCommonjsOptions = () => ({ | ||
include: /node_modules/, | ||
}); | ||
|
||
export default [ | ||
{ | ||
input, | ||
output: { file: `build/umd/${name}.development.js`, format: 'umd', name, globals }, | ||
external: Object.keys(globals), | ||
plugins: [ | ||
nodeResolve(), | ||
babel(getBabelOptions()), | ||
commonjs(getCommonjsOptions()), | ||
sizeSnapshot(), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), | ||
], | ||
}, | ||
|
||
{ | ||
input, | ||
output: { file: `build/umd/${name}.production.min.js`, format: 'umd', name, globals }, | ||
external: Object.keys(globals), | ||
plugins: [ | ||
nodeResolve(), | ||
babel(getBabelOptions()), | ||
commonjs(getCommonjsOptions()), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), | ||
sizeSnapshot(), | ||
uglify(), | ||
], | ||
}, | ||
]; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already using https://github.com/ai/size-limit. I believe it's answering the same problem. Shouldn't we use a single tool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size limit creates limits. My tool is about showing different sizes.
For it's more important to see these values than moving limits over and over again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have a mode where it only outputs in the console and doesn't write in the filesystem? I'm wondering about constantly having to commit the snapshot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the point to show users these numbers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figured out that I can live with that 👍