Skip to content

Commit

Permalink
[core] Add support for Webpack 2/Rollup tree shaking (#5545)
Browse files Browse the repository at this point in the history
* Add support Webpack 2/Rollup tree shaking

* Add custom `babel-es2015-preset`, Transpile `index.js` file with `babel`

* Move `material-ui-babel-es2015-preset` from `packages` to `tools`
  • Loading branch information
oliviertassinari authored Nov 14, 2016
2 parents 806b2ea + b717921 commit 947caf2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["es2015", "stage-1", "react"],
"presets": ["./tools/material-ui-babel-preset-es2015", "stage-1", "react"],
"plugins": [
["transform-replace-object-assign", "simple-assign"],
"transform-dev-warning"
Expand All @@ -20,7 +20,7 @@
"plugins": [
"transform-runtime",
["transform-react-remove-prop-types", {"mode": "wrap"}]
],
]
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"homepage": "http://material-ui.com/",
"scripts": {
"build": "npm run build:icon-index && npm run build:babel && npm run build:copy-files",
"build": "npm run build:icon-index && npm run build:babel && npm run build:copy-files && npm run build:index",
"build:index": "BABEL_ENV=es babel ./src/index.js --out-file ./build/index.es.js",
"build:icon-index": "babel-node ./scripts/icon-index-generator.js",
"build:babel": "NODE_ENV=release babel ./src --out-dir ./build --ignore spec.js",
"build:copy-files": "babel-node ./scripts/copy-files.js",
Expand Down
2 changes: 2 additions & 0 deletions scripts/copy-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function createPackageFile() {
version,
description,
main: './index.js',
module: './index.es.js',
'jsnext:main': './index.es.js',
keywords,
repository,
license,
Expand Down
11 changes: 11 additions & 0 deletions tools/material-ui-babel-preset-es2015.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const es2015 = require('babel-preset-es2015').buildPreset;

const ENV = process.env.BABEL_ENV;

module.exports = {
presets: [
[ es2015, {
modules: ENV === 'es' ? false : 'commonjs'
} ],
],
};

0 comments on commit 947caf2

Please sign in to comment.