-
Notifications
You must be signed in to change notification settings - Fork 49.9k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When using rollup in a project that imports the latest React 16.0.0-alpha7, the bundle ends up containing both react-development.js and react-production.min.js, and the file size is unnecessarily large.
My guess - This happening because the entry point of react was changed recently to
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}and rollup apparently cannot eliminate exports in dead branches even when replacing process.env.NODE_ENV with production.
Uglify also cannot remove the dead code, because rollup seems to hoist required stuff to the top level.
Online Demo: Try building react@next using this tool that uses rollup to report package sizes. Compare that to searching for just react.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Steps to reproduce:
- Import react in any project that uses rollup to bundle.
- Use [rollup-plugin-replace] (https://github.com/rollup/rollup-plugin-replace) to replace
process.env.NODE_ENVwith production. - Use
rollup-plugin-node-resolve,rollup-plugin-commonjsanduglifyjsplugins so that rollup understands commonjs exports and minifies stuff. - Check the bundle size, it is 47.5kB.
What is the expected behavior?
Size should be much smaller.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
The size is fine when using 15.4.2 because the entry point reads as
'use strict';
module.exports = require('./lib/React');