Skip to content

Commit 7523c20

Browse files
authored
Merge pull request JedWatson#2003 from jochenberger/strip-proptypes-in-production
strip proptypes in production build (fixes JedWatson#1882)
2 parents 105275b + 5da115a commit 7523c20

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"babel-loader": "^7.1.1",
2424
"babel-plugin-external-helpers": "^6.22.0",
2525
"babel-plugin-istanbul": "^4.1.4",
26+
"babel-plugin-transform-react-remove-prop-types": "^0.4.8",
2627
"babel-preset-es2015": "^6.24.1",
2728
"babel-preset-react": "^6.24.1",
2829
"babel-preset-stage-0": "^6.24.1",

rollup.config.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ const globals = {
1313
react: 'React',
1414
};
1515
const external = Object.keys(globals);
16-
const babelOptions = {
17-
babelrc: false,
18-
presets: [['es2015', { modules: false }], 'stage-0', 'react'],
19-
plugins: ['external-helpers'],
16+
const babelOptions = (production) => {
17+
let result = {
18+
babelrc: false,
19+
presets: [['es2015', { modules: false }], 'stage-0', 'react'],
20+
plugins: ['external-helpers'],
21+
};
22+
if (production) {
23+
result.plugins.push('transform-react-remove-prop-types');
24+
};
25+
return result;
2026
};
2127

2228
export default [
@@ -27,7 +33,7 @@ export default [
2733
format: 'es',
2834
},
2935
external: external,
30-
plugins: [babel(babelOptions)],
36+
plugins: [babel(babelOptions(false))],
3137
},
3238
{
3339
input: 'src/index.umd.js',
@@ -38,7 +44,7 @@ export default [
3844
},
3945
globals: globals,
4046
external: external,
41-
plugins: [babel(babelOptions), resolve()],
47+
plugins: [babel(babelOptions(false)), resolve()],
4248
},
4349
{
4450
input: 'src/index.umd.js',
@@ -49,6 +55,6 @@ export default [
4955
},
5056
globals: globals,
5157
external: external,
52-
plugins: [babel(babelOptions), resolve(), uglify({}, minify)],
58+
plugins: [babel(babelOptions(true)), resolve(), uglify({}, minify)],
5359
},
5460
];

0 commit comments

Comments
 (0)