From 8fab7b241e08712b3156d761af85ed46d7b6fc2a Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Wed, 24 Oct 2018 16:09:49 +0200 Subject: [PATCH 01/19] [core] Add full esmodules build --- babel.config.js | 76 +++++++------------ packages/material-ui-docs/package.json | 2 +- packages/material-ui-icons/package.json | 2 +- packages/material-ui-lab/package.json | 8 +- .../material-ui-lab/scripts/copy-files.js | 42 +++++++++- packages/material-ui/package.json | 8 +- packages/material-ui/scripts/copy-files.js | 42 +++++++++- 7 files changed, 119 insertions(+), 61 deletions(-) diff --git a/babel.config.js b/babel.config.js index 49cdb85a4e57f6..a071e27eaf5f91 100644 --- a/babel.config.js +++ b/babel.config.js @@ -14,14 +14,14 @@ 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') { +if (process.env.BABEL_ENV === 'esnext') { defaultPresets = []; } else { defaultPresets = [ [ '@babel/preset-env', { - modules: ['modules', 'production-umd'].includes(process.env.BABEL_ENV) ? false : 'commonjs', + modules: ['esm', 'production-umd'].includes(process.env.BABEL_ENV) ? false : 'commonjs', }, ], ]; @@ -35,6 +35,18 @@ const defaultAlias = { '@material-ui/utils': './packages/material-ui-utils/src', }; +const productionPlugins = [ + 'transform-react-constant-elements', + 'transform-dev-warning', + ['react-remove-properties', { properties: ['data-mui-test'] }], + [ + 'transform-react-remove-prop-types', + { + mode: 'unsafe-wrap', + }, + ], +]; + module.exports = { presets: defaultPresets.concat(['@babel/preset-react']), plugins: [ @@ -45,17 +57,8 @@ module.exports = { ], ignore: [/@babel[\\|/]runtime/], env: { - test: { - sourceMaps: 'both', - plugins: [ - [ - 'babel-plugin-module-resolver', - { - root: ['./'], - alias: defaultAlias, - }, - ], - ], + cjs: { + plugins: [...productionPlugins], }, coverage: { plugins: [ @@ -123,47 +126,26 @@ module.exports = { ['transform-react-remove-prop-types', { mode: 'remove' }], ], }, - es: { - plugins: [ - 'transform-react-constant-elements', - 'transform-dev-warning', - ['react-remove-properties', { properties: ['data-mui-test'] }], - [ - 'transform-react-remove-prop-types', - { - mode: 'unsafe-wrap', - }, - ], - ], - // It's most likely a babel bug. - // We are using this ignore option in the CLI command but that has no effect. - ignore: ['**/*.test.js'], + esm: { + plugins: [...productionPlugins], + }, + esnext: { + plugins: [...productionPlugins], }, production: { - plugins: [ - 'transform-react-constant-elements', - 'transform-dev-warning', - ['react-remove-properties', { properties: ['data-mui-test'] }], - [ - 'transform-react-remove-prop-types', - { - mode: 'unsafe-wrap', - }, - ], - ], - // It's most likely a babel bug. - // We are using this ignore option in the CLI command but that has no effect. - ignore: ['**/*.test.js'], + plugins: [...productionPlugins], }, 'production-umd': { + plugins: [...productionPlugins], + }, + test: { + sourceMaps: 'both', plugins: [ - 'transform-react-constant-elements', - 'transform-dev-warning', - ['react-remove-properties', { properties: ['data-mui-test'] }], [ - 'transform-react-remove-prop-types', + 'babel-plugin-module-resolver', { - mode: 'unsafe-wrap', + root: ['./'], + alias: defaultAlias, }, ], ], diff --git a/packages/material-ui-docs/package.json b/packages/material-ui-docs/package.json index 886e8bbf58b456..07179e372a8225 100644 --- a/packages/material-ui-docs/package.json +++ b/packages/material-ui-docs/package.json @@ -25,7 +25,7 @@ "test": "exit 0", "prebuild": "rimraf build", "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", + "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:copy-files", "release": "yarn build && npm publish build" diff --git a/packages/material-ui-icons/package.json b/packages/material-ui-icons/package.json index 96cda07b7ff289..c2aa432d44b793 100644 --- a/packages/material-ui-icons/package.json +++ b/packages/material-ui-icons/package.json @@ -27,7 +27,7 @@ "src:icons": "cd ../../ && UV_THREADPOOL_SIZE=64 babel-node --config-file ../../babel.config.js packages/material-ui-icons/builder.js --output-dir packages/material-ui-icons/src --svg-dir packages/material-ui-icons/material-io-tools-icons --renameFilter ./renameFilters/material-design-icons.js", "prebuild": "rimraf material-design-icons && rimraf build", "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", + "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", "build:typings": "babel-node --config-file ../../babel.config.js ./scripts/create-typings.js", "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:typings && yarn build:copy-files", diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json index e4cee25ccf7c6c..1140b950b690ca 100644 --- a/packages/material-ui-lab/package.json +++ b/packages/material-ui-lab/package.json @@ -24,11 +24,11 @@ "scripts": { "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-lab/**/*.test.js'", "prebuild": "rimraf build", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore *.test.js", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", - "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore *.test.js", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:esnext": "cross-env NODE_ENV=production BABEL_ENV=esnext babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:es && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:esnext && yarn build:copy-files", "release": "yarn build && npm publish build" }, "peerDependencies": { diff --git a/packages/material-ui-lab/scripts/copy-files.js b/packages/material-ui-lab/scripts/copy-files.js index 355c2d9e501296..22073dbc658407 100644 --- a/packages/material-ui-lab/scripts/copy-files.js +++ b/packages/material-ui-lab/scripts/copy-files.js @@ -10,6 +10,39 @@ async function copyFile(file) { console.log(`Copied ${file} to ${buildPath}`); } +/** + * Puts a package.json into every immediate child directory of rootDir. + * That package.json contains information about esm for bundlers so that imports + * like import Typography from '@material-ui/core/Typography' are tree-shakeable. + * + * It also tests that an this import can be used in typescript by checking + * if an index.d.ts is present at that path. + * + * @param {string} rootDir + */ +function createModulePackages(srcDir, outDir) { + const directoryPackages = glob.sync('*/index.js', { cwd: srcDir }).map(path.dirname); + return Promise.all( + directoryPackages.map(directoryPackage => { + const packageJson = { + sideEffects: false, + module: path.join('..', 'esm', directoryPackage, 'index.js'), + }; + const packageJsonPath = path.join(outDir, directoryPackage, 'package.json'); + + return Promise.all([ + fse.exists(path.join(outDir, directoryPackage, 'index.d.ts')), + fse.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)), + ]).then(([typingsExist]) => { + if (!typingsExist) { + return Promise.reject(new Error(`index.d.ts for ${directoryPackage} is missing`)); + } + return Promise.resolve(packageJsonPath); + }); + }), + ); +} + function typescriptCopy(from, to) { const files = glob.sync('**/*.d.ts', { cwd: from }); const cmds = files.map(file => fse.copy(path.resolve(from, file), path.resolve(to, file))); @@ -22,7 +55,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './index.es.js', + module: './esm/index.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); @@ -46,7 +79,7 @@ async function addLicense(packageData) { */ `; await Promise.all( - ['../build/index.js', '../build/index.es.js'].map(file => + ['../build/index.js', '../build/esm/index.js'].map(file => prepend(path.resolve(__dirname, file), license), ), ); @@ -63,6 +96,11 @@ async function run() { typescriptCopy(from, path.resolve(__dirname, '../build')), typescriptCopy(from, path.resolve(__dirname, '../build/es')), ]); + + await createModulePackages( + path.resolve(__dirname, '../src'), + path.resolve(__dirname, '../build'), + ); } run(); diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index 3b5ef10f9f8411..e2468b52afd39a 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -21,12 +21,12 @@ "homepage": "https://material-ui.com/", "scripts": { "prebuild": "rimraf build", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore *.test.js", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", - "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore *.test.js", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:esnext": "cross-env NODE_ENV=production BABEL_ENV=esnext babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:umd": "cross-env BABEL_ENV=production-umd rollup -c scripts/rollup.config.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:es && yarn build:umd && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:esnext && yarn build:umd && yarn build:copy-files", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui/**/*.test.js'" }, diff --git a/packages/material-ui/scripts/copy-files.js b/packages/material-ui/scripts/copy-files.js index 639f1bc8361086..d438d591b7ef33 100644 --- a/packages/material-ui/scripts/copy-files.js +++ b/packages/material-ui/scripts/copy-files.js @@ -10,6 +10,39 @@ async function copyFile(file) { console.log(`Copied ${file} to ${buildPath}`); } +/** + * Puts a package.json into every immediate child directory of rootDir. + * That package.json contains information about esm for bundlers so that imports + * like import Typography from '@material-ui/core/Typography' are tree-shakeable. + * + * It also tests that an this import can be used in typescript by checking + * if an index.d.ts is present at that path. + * + * @param {string} rootDir + */ +function createModulePackages(srcDir, outDir) { + const directoryPackages = glob.sync('*/index.js', { cwd: srcDir }).map(path.dirname); + return Promise.all( + directoryPackages.map(directoryPackage => { + const packageJson = { + sideEffects: false, + module: path.join('..', 'esm', directoryPackage, 'index.js'), + }; + const packageJsonPath = path.join(outDir, directoryPackage, 'package.json'); + + return Promise.all([ + fse.exists(path.join(outDir, directoryPackage, 'index.d.ts')), + fse.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2)), + ]).then(([typingsExist]) => { + if (!typingsExist) { + return Promise.reject(new Error(`index.d.ts for ${directoryPackage} is missing`)); + } + return Promise.resolve(packageJsonPath); + }); + }), + ); +} + function typescriptCopy(from, to) { const files = glob.sync('**/*.d.ts', { cwd: from }); const cmds = files.map(file => fse.copy(path.resolve(from, file), path.resolve(to, file))); @@ -24,7 +57,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './index.es.js', + module: './esm/index.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); @@ -50,7 +83,7 @@ async function addLicense(packageData) { await Promise.all( [ '../build/index.js', - '../build/index.es.js', + '../build/esm/index.js', '../build/umd/material-ui.development.js', '../build/umd/material-ui.production.min.js', ].map(file => prepend(path.resolve(__dirname, file), license)), @@ -70,6 +103,11 @@ async function run() { typescriptCopy(from, path.resolve(__dirname, '../build')), typescriptCopy(from, path.resolve(__dirname, '../build/es')), ]); + + await createModulePackages( + path.resolve(__dirname, '../src'), + path.resolve(__dirname, '../build'), + ); } run(); From e5653d7099bcd628b9b0d42f785d9fbd69b9fba7 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 26 Oct 2018 01:14:11 +0200 Subject: [PATCH 02/19] [core] Add support for yarn workspaces run --- packages/material-ui-benchmark/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/material-ui-benchmark/package.json b/packages/material-ui-benchmark/package.json index ce57a65f779c24..42c57c23b497dc 100644 --- a/packages/material-ui-benchmark/package.json +++ b/packages/material-ui-benchmark/package.json @@ -14,6 +14,7 @@ "scripts": { "test": "exit 0", "benchmark": "cd ../../ && NODE_ENV=production BABEL_ENV=docs-production babel-node packages/material-ui-benchmark/src/benchmark.js", + "build": "echo \"Nothing to build in @material-ui/benchmark\"", "server": "cd ../../ && NODE_ENV=production BABEL_ENV=docs-production babel-node packages/material-ui-benchmark/src/server.js" }, "devDependencies": {}, From 3edfadb47accb2e8b750defb68a891d02654d248 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 14 Dec 2018 12:25:07 +0100 Subject: [PATCH 03/19] Revert "[core] Add support for yarn workspaces run" This reverts commit e5653d7099bcd628b9b0d42f785d9fbd69b9fba7. --- packages/material-ui-benchmark/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/material-ui-benchmark/package.json b/packages/material-ui-benchmark/package.json index 42c57c23b497dc..ce57a65f779c24 100644 --- a/packages/material-ui-benchmark/package.json +++ b/packages/material-ui-benchmark/package.json @@ -14,7 +14,6 @@ "scripts": { "test": "exit 0", "benchmark": "cd ../../ && NODE_ENV=production BABEL_ENV=docs-production babel-node packages/material-ui-benchmark/src/benchmark.js", - "build": "echo \"Nothing to build in @material-ui/benchmark\"", "server": "cd ../../ && NODE_ENV=production BABEL_ENV=docs-production babel-node packages/material-ui-benchmark/src/server.js" }, "devDependencies": {}, From 2ae77108536779539406065d245c8eefa9bc9e68 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 14 Dec 2018 12:41:10 +0100 Subject: [PATCH 04/19] [core] Update size-limit --- .size-limit.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 2cff5e24eb3d6b..6f0f4470defbd4 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -22,20 +22,20 @@ module.exports = [ name: 'The size of the @material-ui/core modules', webpack: true, path: 'packages/material-ui/build/index.js', - limit: '95.3 KB', + limit: '91.9 KB', }, { name: 'The size of the @material-ui/styles modules', webpack: true, path: 'packages/material-ui-styles/build/index.js', - limit: '15.0 KB', + limit: '14.7 KB', }, { // vs https://bundlephobia.com/result?p=react-popper name: 'The size of the @material-ui/core/Popper component', webpack: true, path: 'packages/material-ui/build/Popper/index.js', - limit: '10.7 KB', + limit: '9.8 KB', }, { name: 'The main docs bundle', @@ -47,6 +47,6 @@ module.exports = [ name: 'The docs home page', webpack: false, path: `.next/static/${buildId}/pages/index.js`, - limit: '6 KB', + limit: '5.7 KB', }, ]; From 39c17834b1aeb856c06874f17b07e7a012d1059b Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Thu, 20 Dec 2018 09:05:01 +0100 Subject: [PATCH 05/19] [core] esnext -> es --- babel.config.js | 4 ++-- packages/material-ui-lab/package.json | 4 ++-- packages/material-ui/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/babel.config.js b/babel.config.js index a071e27eaf5f91..c7b7c1ed7c9a13 100644 --- a/babel.config.js +++ b/babel.config.js @@ -14,7 +14,7 @@ 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 === 'esnext') { +if (process.env.BABEL_ENV === 'es') { defaultPresets = []; } else { defaultPresets = [ @@ -129,7 +129,7 @@ module.exports = { esm: { plugins: [...productionPlugins], }, - esnext: { + es: { plugins: [...productionPlugins], }, production: { diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json index 1140b950b690ca..b92e5e9921e575 100644 --- a/packages/material-ui-lab/package.json +++ b/packages/material-ui-lab/package.json @@ -26,9 +26,9 @@ "prebuild": "rimraf build", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", - "build:esnext": "cross-env NODE_ENV=production BABEL_ENV=esnext babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:cjs && yarn build:esm && yarn build:esnext && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", "release": "yarn build && npm publish build" }, "peerDependencies": { diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index e2468b52afd39a..fbe44c04cd5de5 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -23,10 +23,10 @@ "prebuild": "rimraf build", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", - "build:esnext": "cross-env NODE_ENV=production BABEL_ENV=esnext babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:umd": "cross-env BABEL_ENV=production-umd rollup -c scripts/rollup.config.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:cjs && yarn build:esm && yarn build:esnext && yarn build:umd && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:umd && yarn build:copy-files", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui/**/*.test.js'" }, From cdd1691fdd6556b80dcd2b5b60351f95d3d99992 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 10:59:46 +0100 Subject: [PATCH 06/19] [core] Fix incorrect bundle sizes from merge --- .size-limit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 4773fe5fa1e3d4..672494e21935aa 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -28,7 +28,7 @@ module.exports = [ name: 'The size of the @material-ui/styles modules', webpack: true, path: 'packages/material-ui-styles/build/index.js', - limit: '14.7 KB', + limit: '16.3 KB', }, { name: 'The size of the @material-ui/system modules', @@ -46,21 +46,21 @@ module.exports = [ name: 'The size of the @material-ui/core/Button component', webpack: true, path: 'packages/material-ui/build/Button/index.js', - limit: '27.0 KB', + limit: '29.6 KB', }, { // vs https://bundlephobia.com/result?p=react-modal name: 'The size of the @material-ui/core/Modal component', webpack: true, path: 'packages/material-ui/build/Modal/index.js', - limit: '27.0 KB', + limit: '28.8 KB', }, { // vs https://bundlephobia.com/result?p=react-popper name: 'The size of the @material-ui/core/Popper component', webpack: true, path: 'packages/material-ui/build/Popper/index.js', - limit: '9.8 KB', + limit: '9.9 KB', }, { // vs https://bundlephobia.com/result?p=react-responsive @@ -80,6 +80,6 @@ module.exports = [ name: 'The docs home page', webpack: false, path: `.next/static/${buildId}/pages/index.js`, - limit: '5.7 KB', + limit: '6.2 KB', }, ]; From 7f39bc0846bf4daa7435f7d9010fa3b7d6160d70 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 11:16:57 +0100 Subject: [PATCH 07/19] [core] Normalize build process --- packages/material-ui-lab/package.json | 4 ++-- packages/material-ui-styles/package.json | 8 ++++---- packages/material-ui-system/package.json | 8 ++++---- packages/material-ui-utils/package.json | 8 ++++---- packages/material-ui/package.json | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json index dba0bba27509fc..3dd9085c5e40e8 100644 --- a/packages/material-ui-lab/package.json +++ b/packages/material-ui-lab/package.json @@ -23,12 +23,12 @@ "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-lab", "scripts": { "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-lab/**/*.test.js' --exclude '**/node_modules/**'", - "prebuild": "rimraf build", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", + "prebuild": "rimraf build", "release": "yarn build && npm publish build", "typescript": "tslint -p tsconfig.json \"src/**/*.{ts,tsx}\"" }, diff --git a/packages/material-ui-styles/package.json b/packages/material-ui-styles/package.json index ab596deee79269..020f6538a0e500 100644 --- a/packages/material-ui-styles/package.json +++ b/packages/material-ui-styles/package.json @@ -22,11 +22,11 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-styles", "scripts": { - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:es && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore *.test.js", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore *.test.js", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", "prebuild": "rimraf build", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-styles/**/*.test.js' --exclude '**/node_modules/**'", diff --git a/packages/material-ui-system/package.json b/packages/material-ui-system/package.json index 86e861c19b2c51..f527483495a625 100644 --- a/packages/material-ui-system/package.json +++ b/packages/material-ui-system/package.json @@ -22,11 +22,11 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-system", "scripts": { - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:es && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore *.test.js", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore *.test.js", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", "prebuild": "rimraf build", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-system/**/*.test.js' --exclude '**/node_modules/**'" diff --git a/packages/material-ui-utils/package.json b/packages/material-ui-utils/package.json index d4b816e8ba41d3..a62b6a3358db7a 100644 --- a/packages/material-ui-utils/package.json +++ b/packages/material-ui-utils/package.json @@ -22,11 +22,11 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-utils", "scripts": { - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:es && yarn build:copy-files", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore *.test.js", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore *.test.js", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=modules babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", "prebuild": "rimraf build", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-utils/**/*.test.js' --exclude '**/node_modules/**'" diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index ff319a78f11c71..32b967806ecdad 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -21,12 +21,12 @@ "homepage": "https://material-ui.com/", "scripts": { "prebuild": "rimraf build", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:umd && yarn build:copy-files", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:umd": "cross-env BABEL_ENV=production-umd rollup -c scripts/rollup.config.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:umd && yarn build:copy-files", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui/**/*.test.js' --exclude '**/node_modules/**'", "typescript": "tslint -p tsconfig.json \"{src,test}/**/*.{ts,tsx}\"" From 6edcfb3f338f94f6d532ba22c9dcf82adaddc42c Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 11:17:25 +0100 Subject: [PATCH 08/19] [core] sort scripts alphanumberic --- packages/material-ui-lab/package.json | 2 +- packages/material-ui/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json index 3dd9085c5e40e8..d0b9fc78bf63c1 100644 --- a/packages/material-ui-lab/package.json +++ b/packages/material-ui-lab/package.json @@ -22,7 +22,6 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-lab", "scripts": { - "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-lab/**/*.test.js' --exclude '**/node_modules/**'", "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:copy-files", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", @@ -30,6 +29,7 @@ "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", "prebuild": "rimraf build", "release": "yarn build && npm publish build", + "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-lab/**/*.test.js' --exclude '**/node_modules/**'", "typescript": "tslint -p tsconfig.json \"src/**/*.{ts,tsx}\"" }, "peerDependencies": { diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index 32b967806ecdad..caa77ce7eab308 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -20,13 +20,13 @@ }, "homepage": "https://material-ui.com/", "scripts": { - "prebuild": "rimraf build", "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:umd && yarn build:copy-files", "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:umd": "cross-env BABEL_ENV=production-umd rollup -c scripts/rollup.config.js", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", + "prebuild": "rimraf build", "release": "yarn build && npm publish build", "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui/**/*.test.js' --exclude '**/node_modules/**'", "typescript": "tslint -p tsconfig.json \"{src,test}/**/*.{ts,tsx}\"" From 2db6dadc83dc41ba771aaed5fada9c09e06334c3 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 11:31:22 +0100 Subject: [PATCH 09/19] [core] Add size test for esm build --- .size-limit.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.size-limit.js b/.size-limit.js index 672494e21935aa..859ebb08974323 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -18,6 +18,12 @@ module.exports = [ path: 'packages/material-ui/build/Paper/index.js', limit: '18.7 KB', }, + { + name: 'The initial cost paid for using one component with ES modules', + webpack: true, + path: 'packages/material-ui/build/esm/Paper/index.js', + limit: '17.8 KB', + }, { name: 'The size of the @material-ui/core modules', webpack: true, From 13cfba80d73565148d6e0a899f55c93c880973ad Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 12:03:14 +0100 Subject: [PATCH 10/19] [core] Fix unresolved module entry --- packages/material-ui-styles/scripts/copy-files.js | 4 ++-- packages/material-ui-system/scripts/copy-files.js | 4 ++-- packages/material-ui-utils/scripts/copy-files.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/material-ui-styles/scripts/copy-files.js b/packages/material-ui-styles/scripts/copy-files.js index 355c2d9e501296..36759654258700 100644 --- a/packages/material-ui-styles/scripts/copy-files.js +++ b/packages/material-ui-styles/scripts/copy-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './index.es.js', + module: './esm/index.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); @@ -46,7 +46,7 @@ async function addLicense(packageData) { */ `; await Promise.all( - ['../build/index.js', '../build/index.es.js'].map(file => + ['../build/index.js', '../build/esm/index.js'].map(file => prepend(path.resolve(__dirname, file), license), ), ); diff --git a/packages/material-ui-system/scripts/copy-files.js b/packages/material-ui-system/scripts/copy-files.js index 355c2d9e501296..36759654258700 100644 --- a/packages/material-ui-system/scripts/copy-files.js +++ b/packages/material-ui-system/scripts/copy-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './index.es.js', + module: './esm/index.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); @@ -46,7 +46,7 @@ async function addLicense(packageData) { */ `; await Promise.all( - ['../build/index.js', '../build/index.es.js'].map(file => + ['../build/index.js', '../build/esm/index.js'].map(file => prepend(path.resolve(__dirname, file), license), ), ); diff --git a/packages/material-ui-utils/scripts/copy-files.js b/packages/material-ui-utils/scripts/copy-files.js index 355c2d9e501296..fd24728b3634f8 100644 --- a/packages/material-ui-utils/scripts/copy-files.js +++ b/packages/material-ui-utils/scripts/copy-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './index.es.js', + module: './esm/index.jsindex.es.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); @@ -46,7 +46,7 @@ async function addLicense(packageData) { */ `; await Promise.all( - ['../build/index.js', '../build/index.es.js'].map(file => + ['../build/index.js', '../esm/index.js'].map(file => prepend(path.resolve(__dirname, file), license), ), ); From de3e205c8b27c64237dc0c0db95a8d2ee81737ce Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 12:05:19 +0100 Subject: [PATCH 11/19] [core] revert size limit changes for cjs build --- .size-limit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 859ebb08974323..3a76fbd1c98b2b 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -52,21 +52,21 @@ module.exports = [ name: 'The size of the @material-ui/core/Button component', webpack: true, path: 'packages/material-ui/build/Button/index.js', - limit: '29.6 KB', + limit: '27.0 KB', }, { // vs https://bundlephobia.com/result?p=react-modal name: 'The size of the @material-ui/core/Modal component', webpack: true, path: 'packages/material-ui/build/Modal/index.js', - limit: '28.8 KB', + limit: '27.0 KB', }, { // vs https://bundlephobia.com/result?p=react-popper name: 'The size of the @material-ui/core/Popper component', webpack: true, path: 'packages/material-ui/build/Popper/index.js', - limit: '9.9 KB', + limit: '10.7 KB', }, { // vs https://bundlephobia.com/result?p=react-responsive From 529698229334fe1538f571939eb4ca77ea3aa5ad Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 12:29:50 +0100 Subject: [PATCH 12/19] [core] Fix increased size limit --- .size-limit.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 3a76fbd1c98b2b..c78b7d9059d2f8 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -49,23 +49,24 @@ module.exports = [ limit: '900 B', }, { + // why we use esm here: https://github.com/mui-org/material-ui/pull/13391#issuecomment-459692816 name: 'The size of the @material-ui/core/Button component', webpack: true, - path: 'packages/material-ui/build/Button/index.js', + path: 'packages/material-ui/build/esm/Button/index.js', limit: '27.0 KB', }, { // vs https://bundlephobia.com/result?p=react-modal name: 'The size of the @material-ui/core/Modal component', webpack: true, - path: 'packages/material-ui/build/Modal/index.js', + path: 'packages/material-ui/build/esm/Modal/index.js', limit: '27.0 KB', }, { // vs https://bundlephobia.com/result?p=react-popper name: 'The size of the @material-ui/core/Popper component', webpack: true, - path: 'packages/material-ui/build/Popper/index.js', + path: 'packages/material-ui/build/esm/Popper/index.js', limit: '10.7 KB', }, { From c1ff40a9d534dd35153984d05bfbb6cdb3292aaf Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 1 Feb 2019 13:55:54 +0100 Subject: [PATCH 13/19] [core] update size limits --- .size-limit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index c78b7d9059d2f8..f93bfa39e40e3a 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -53,21 +53,21 @@ module.exports = [ name: 'The size of the @material-ui/core/Button component', webpack: true, path: 'packages/material-ui/build/esm/Button/index.js', - limit: '27.0 KB', + limit: '24.8 KB', }, { // vs https://bundlephobia.com/result?p=react-modal name: 'The size of the @material-ui/core/Modal component', webpack: true, path: 'packages/material-ui/build/esm/Modal/index.js', - limit: '27.0 KB', + limit: '24.1 KB', }, { // vs https://bundlephobia.com/result?p=react-popper name: 'The size of the @material-ui/core/Popper component', webpack: true, path: 'packages/material-ui/build/esm/Popper/index.js', - limit: '10.7 KB', + limit: '9.7 KB', }, { // vs https://bundlephobia.com/result?p=react-responsive From c3d0fdc76b4c2fcc2e5279fc38a13efdb579a75e Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 2 Feb 2019 16:53:44 +0100 Subject: [PATCH 14/19] [core] Normalize build scripts in icons and docs --- packages/material-ui-docs/package.json | 12 ++++++------ packages/material-ui-icons/package.json | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/material-ui-docs/package.json b/packages/material-ui-docs/package.json index 0fa0206f815dc4..fccb46f0c3a444 100644 --- a/packages/material-ui-docs/package.json +++ b/packages/material-ui-docs/package.json @@ -22,13 +22,13 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-lab", "scripts": { - "test": "exit 0", - "prebuild": "rimraf build", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", + "build": "yarn build:cjs && yarn build:esm && yarn build:copy-files", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:copy-files", - "release": "yarn build && npm publish build" + "prebuild": "rimraf build", + "release": "yarn build && npm publish build", + "test": "exit 0" }, "peerDependencies": { "@material-ui/core": "^3.0.0", diff --git a/packages/material-ui-icons/package.json b/packages/material-ui-icons/package.json index b0ec8de75e8e3c..0beae22a029416 100644 --- a/packages/material-ui-icons/package.json +++ b/packages/material-ui-icons/package.json @@ -22,10 +22,10 @@ }, "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/material-ui-icons", "scripts": { - "build": "yarn build:es2015 && yarn build:es2015modules && yarn build:typings && yarn build:copy-files", - "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", - "build:es2015": "cross-env NODE_ENV=production babel --config-file ../../babel.config.js ./src --out-dir ./build", - "build:es2015modules": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src/index.js --out-file ./build/index.es.js", + "build": "yarn build:cjs && yarn build:esm && yarn build:es && yarn build:typings && yarn build:copy-files", + "build:cjs": "cross-env NODE_ENV=production BABEL_ENV=cjs babel --config-file ../../babel.config.js ./src --out-dir ./build --ignore \"**/*.test.js\"", + "build:esm": "cross-env NODE_ENV=production BABEL_ENV=esm babel --config-file ../../babel.config.js ./src --out-dir ./build/esm --ignore \"**/*.test.js\"", + "build:es": "cross-env NODE_ENV=production BABEL_ENV=es babel --config-file ../../babel.config.js ./src --out-dir ./build/es --ignore \"**/*.test.js\"", "build:copy-files": "babel-node --config-file ../../babel.config.js ./scripts/copy-files.js", "build:typings": "babel-node --config-file ../../babel.config.js ./scripts/create-typings.js", "prebuild": "rimraf material-design-icons && rimraf build", From c3a65d474a723fa4d53120c1b52c0c7d360fecaf Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 2 Feb 2019 16:59:27 +0100 Subject: [PATCH 15/19] fix size limit --- .size-limit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.size-limit.js b/.size-limit.js index e5dafabcb9e3fc..f5366b6804c359 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -22,7 +22,7 @@ module.exports = [ name: 'The initial cost paid for using one component with ES modules', webpack: true, path: 'packages/material-ui/build/esm/Paper/index.js', - limit: '17.8 KB', + limit: '17.9 KB', }, { name: 'The size of the @material-ui/core modules', From 5717dca6c76e079dbb098e190fbc55f192e2a0f9 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 2 Feb 2019 17:01:12 +0100 Subject: [PATCH 16/19] fix utils build --- packages/material-ui-utils/scripts/copy-files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui-utils/scripts/copy-files.js b/packages/material-ui-utils/scripts/copy-files.js index fd24728b3634f8..f3c96018a2f9a9 100644 --- a/packages/material-ui-utils/scripts/copy-files.js +++ b/packages/material-ui-utils/scripts/copy-files.js @@ -22,7 +22,7 @@ async function createPackageFile() { const newPackageData = { ...packageDataOther, main: './index.js', - module: './esm/index.jsindex.es.js', + module: './esm/index.js', private: false, }; const buildPath = path.resolve(__dirname, '../build/package.json'); From aa4bb78d14075ccd2b82a22401c2ea43dbf67206 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sat, 2 Feb 2019 17:22:10 +0100 Subject: [PATCH 17/19] [docs] fix build --- packages/material-ui-docs/scripts/copy-files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/material-ui-docs/scripts/copy-files.js b/packages/material-ui-docs/scripts/copy-files.js index 34c4520659fbf2..51841eac171da6 100644 --- a/packages/material-ui-docs/scripts/copy-files.js +++ b/packages/material-ui-docs/scripts/copy-files.js @@ -38,7 +38,7 @@ async function addLicense(packageData) { */ `; await Promise.all( - ['../build/index.js', '../build/index.es.js'].map(file => + ['../build/index.js', '../build/esm/index.js'].map(file => prepend(path.resolve(__dirname, file), license), ), ); From d70e5bdb5f2dfecbb2b8072d746350a7a9f9f9f2 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 3 Feb 2019 09:39:13 +0100 Subject: [PATCH 18/19] [core] Reduce size tolerance --- .size-limit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index f5366b6804c359..19443e4db17cd7 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -28,7 +28,7 @@ module.exports = [ name: 'The size of the @material-ui/core modules', webpack: true, path: 'packages/material-ui/build/index.js', - limit: '91.9 KB', + limit: '91.2 KB', }, { name: 'The size of the @material-ui/styles modules', @@ -53,7 +53,7 @@ module.exports = [ name: 'The size of the @material-ui/core/Button component', webpack: true, path: 'packages/material-ui/build/esm/Button/index.js', - limit: '24.8 KB', + limit: '24.6 KB', }, { // vs https://bundlephobia.com/result?p=react-modal From 831a807582c3fdc6583635013d98928590212162 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 3 Feb 2019 09:45:25 +0100 Subject: [PATCH 19/19] [core] Remove unnecessary array spread --- babel.config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/babel.config.js b/babel.config.js index e36316d6846d55..3dbdb2f8a5cd78 100644 --- a/babel.config.js +++ b/babel.config.js @@ -59,7 +59,7 @@ module.exports = { ignore: [/@babel[\\|/]runtime/], env: { cjs: { - plugins: [...productionPlugins], + plugins: productionPlugins, }, coverage: { plugins: [ @@ -128,16 +128,16 @@ module.exports = { ], }, esm: { - plugins: [...productionPlugins], + plugins: productionPlugins, }, es: { - plugins: [...productionPlugins], + plugins: productionPlugins, }, production: { - plugins: [...productionPlugins], + plugins: productionPlugins, }, 'production-umd': { - plugins: [...productionPlugins], + plugins: productionPlugins, }, test: { sourceMaps: 'both',