Skip to content

Commit

Permalink
[core] Use terser for minification in umd bundle (#15491)
Browse files Browse the repository at this point in the history
* Fix unresolved dependency warning

* Switch to terser

* add onwarn, test that it fails

* fix the build
  • Loading branch information
eps1lon authored and oliviertassinari committed Apr 26, 2019
1 parent 5950587 commit 90b9f3d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-size-snapshot": "^0.8.0",
"rollup-plugin-uglify": "^6.0.0",
"rollup-plugin-terser": "^4.0.4",
"sinon": "^7.0.0",
"size-limit": "^0.21.0",
"styled-components": "^4.1.1",
Expand Down
10 changes: 8 additions & 2 deletions packages/material-ui/scripts/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import nodeGlobals from 'rollup-plugin-node-globals';
import { uglify } from 'rollup-plugin-uglify';
import { terser } from 'rollup-plugin-terser';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';

const input = './src/index.js';
Expand Down Expand Up @@ -38,9 +38,14 @@ const commonjsOptions = {
},
};

function onwarn(warning) {
throw Error(warning.message);
}

export default [
{
input,
onwarn,
output: {
file: 'build/umd/material-ui.development.js',
format: 'umd',
Expand All @@ -58,6 +63,7 @@ export default [
},
{
input,
onwarn,
output: {
file: 'build/umd/material-ui.production.min.js',
format: 'umd',
Expand All @@ -72,7 +78,7 @@ export default [
nodeGlobals(), // Wait for https://github.com/cssinjs/jss/pull/893
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
sizeSnapshot({ snapshotPath: 'size-snapshot.json' }),
uglify(),
terser(),
],
},
];
2 changes: 1 addition & 1 deletion packages/material-ui/src/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Popover from '../Popover';
import MenuList from '../MenuList';
import warning from 'warning';
import ReactDOM from 'react-dom';
import { setRef } from '@material-ui/core/utils/reactHelpers';
import { setRef } from '../utils/reactHelpers';

const RTL_ORIGIN = {
vertical: 'top',
Expand Down
36 changes: 20 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1721,12 +1721,12 @@
write-file-atomic "^2.3.0"

"@material-ui/core@^3.9.3":
version "4.0.0-alpha.7"
version "4.0.0-alpha.8"
dependencies:
"@babel/runtime" "^7.2.0"
"@material-ui/styles" "^4.0.0-alpha.6"
"@material-ui/system" "^4.0.0-alpha.0"
"@material-ui/utils" "^4.0.0-alpha.4"
"@material-ui/styles" "^4.0.0-alpha.8"
"@material-ui/system" "^4.0.0-alpha.8"
"@material-ui/utils" "^4.0.0-alpha.8"
"@types/react-transition-group" "^2.0.16"
clsx "^1.0.2"
csstype "^2.5.2"
Expand All @@ -1738,7 +1738,7 @@
popper.js "^1.14.1"
prop-types "^15.7.2"
react-event-listener "^0.6.6"
react-transition-group "^2.5.3"
react-transition-group "^4.0.0"
warning "^4.0.1"

"@mrmlnc/readdir-enhanced@^2.2.1":
Expand Down Expand Up @@ -7743,11 +7743,10 @@ jest-get-type@^22.1.0:
integrity sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w==

jest-worker@^24.0.0:
version "24.4.0"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.4.0.tgz#fbc452b0120bb5c2a70cdc88fa132b48eeb11dd0"
integrity sha512-BH9X/klG9vxwoO99ZBUbZFfV8qO0XNZ5SIiCyYK2zOuJBl6YJVAeNIQjcoOVNu4HGEHeYEKsUWws8kSlSbZ9YQ==
version "24.6.0"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.6.0.tgz#7f81ceae34b7cde0c9827a6980c35b7cdc0161b3"
integrity sha512-jDwgW5W9qGNvpI1tNnvajh0a5IE/PuGLFmHk6aR/BZFz8tSgGw17GsDPXAJ6p91IvYDjOw8GpFbvvZGAK+DPQQ==
dependencies:
"@types/node" "*"
merge-stream "^1.0.1"
supports-color "^6.1.0"

Expand Down Expand Up @@ -12020,15 +12019,15 @@ rollup-plugin-size-snapshot@^0.8.0:
terser "^3.14.1"
webpack "^4.28.4"

rollup-plugin-uglify@^6.0.0:
version "6.0.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.2.tgz#681042cfdf7ea4e514971946344e1a95bc2772fe"
integrity sha512-qwz2Tryspn5QGtPUowq5oumKSxANKdrnfz7C0jm4lKxvRDsNe/hSGsB9FntUul7UeC4TsZEWKErVgE1qWSO0gw==
rollup-plugin-terser@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-4.0.4.tgz#6f661ef284fa7c27963d242601691dc3d23f994e"
integrity sha512-wPANT5XKVJJ8RDUN0+wIr7UPd0lIXBo4UdJ59VmlPCtlFsE20AM+14pe+tk7YunCsWEiuzkDBY3QIkSCjtrPXg==
dependencies:
"@babel/code-frame" "^7.0.0"
jest-worker "^24.0.0"
serialize-javascript "^1.6.1"
uglify-js "^3.4.9"
terser "^3.14.1"

rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.3.0, rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.3.3:
version "2.4.1"
Expand Down Expand Up @@ -12212,11 +12211,16 @@ [email protected]:
range-parser "~1.2.0"
statuses "~1.4.0"

[email protected], serialize-javascript@^1.4.0, serialize-javascript@^1.6.1:
[email protected], serialize-javascript@^1.4.0:
version "1.6.1"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.6.1.tgz#4d1f697ec49429a847ca6f442a2a755126c4d879"
integrity sha512-A5MOagrPFga4YaKQSWHryl7AXvbQkEqpw4NNYMTNYUNV51bA8ABHgYFpqKx+YFFrw59xMV1qGH1R4AgoNIVgCw==

serialize-javascript@^1.6.1:
version "1.7.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.7.0.tgz#d6e0dfb2a3832a8c94468e6eb1db97e55a192a65"
integrity sha512-ke8UG8ulpFOxO8f8gRYabHQe/ZntKlcig2Mp+8+URDP1D8vJZ0KUt7LYo07q25Z/+JVSgpr/cui9PIp5H6/+nA==

[email protected]:
version "1.13.2"
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1"
Expand Down Expand Up @@ -13386,7 +13390,7 @@ ua-parser-js@^0.7.18:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.19.tgz#94151be4c0a7fb1d001af7022fdaca4642659e4b"
integrity sha512-T3PVJ6uz8i0HzPxOF9SWzWAlfN/DavlpQqepn22xgve/5QecC+XMCAtmUNnY7C9StehaV6exjUCI801lOI7QlQ==

uglify-js@^3.1.4, uglify-js@^3.4.9:
uglify-js@^3.1.4:
version "3.4.10"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"
integrity sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==
Expand Down

0 comments on commit 90b9f3d

Please sign in to comment.