Thanks for the response and links, Justin.
I tried both the tree-shaking plugins and lodash plugin and did not see any reductions in generated code size (though I may have done something incorrectly, due to lack of experience with babel and webpack).
Here’s the code from my altered webpack.client.rails.config.js
:
config.module.loaders.push(
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
plugins: [
'lodash'
'transform-es2015-template-literals',
'transform-es2015-literals',
'transform-es2015-function-name',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoped-functions',
'transform-es2015-classes',
'transform-es2015-object-super',
'transform-es2015-shorthand-properties',
'transform-es2015-computed-properties',
'transform-es2015-for-of',
'transform-es2015-sticky-regex',
'transform-es2015-unicode-regex',
'check-es2015-constants',
'transform-es2015-spread',
'transform-es2015-parameters',
'transform-es2015-destructuring',
'transform-es2015-block-scoping',
'transform-es2015-typeof-symbol',
['transform-regenerator', { async: false, asyncGenerators: false }]
]
}
},
{
test: require.resolve('react'),
loader: 'imports?shim=es5-shim/es5-shim&sham=es5-shim/es5-sham',
},
{
test: require.resolve('jquery-ujs'),
loader: 'imports?jQuery=jquery',
}
);
Removing the sample HelloWorld app resulted in some significant size reductions, though the bundles are still very large (see attached).
1.9 MB for app, and 1.5 MB for vendor. With a minified production build, these numbers shrink further to a combined total of about 707 KB and 567 KB, respectively. Are these numbers normal? They still seem extremely high. For example, the company I work for uses ExtJs (a very large js framework) and we have 1000s of LOC of our own app code, and it totals out at less than this combined total of ~1.2 MB.
Thanks for your assistance here. There are some things I really like about react_on_rails vs react-rails, so it would be a shame to have switch back (or go some other route entirely), but these js bundle sizes are a deal-breaker for me.