Hi,
I've installed React on Rails into my project with the generator and it's been working great but now that I'm writing some integration tests with capybara I'm running into an issue where the client-bundle is rebuilt every time I run the test regardless of whether I've made any changes. I have the webpack server running with -w so it automatically rebuilds but the test helpers seem to think the bundle is out of date regardless.
Every time I run my tests I get something like this
====> React On Rails: Checking app/assets/webpack for outdated/missing bundles
Detected are the following stale generated files:
app/assets/webpack/client-bundle.js
React on Rails will ensure your JavaScript generated files are up to date, using your
top level package.json `build:client` commands.
Detected Webpack processes running to rebuild your generated files:
client: 55183 node /Users/taylor/vagrant/supplejack/supplejack_website/client/node_modules/.bin/webpack --config webpack.client.rails.config.js
If you are frequently running tests, you can run webpack in watch mode for static assets to
speed up this process. See the official documentation:
https://github.com/shakacode/react_on_rails/blob/master/docs/additional-reading/rspec-configuration.md
Building Webpack client-rendering assets...
It doesn't seem like it does a full compilation because it finishes faster than if I just start up webpack, but it's still quite slow (so it very well could be, I haven't actually timed the compile times). Any ideas?
Cheers
This is definitely a bug that needs fixing.
@UberMouse yeah that's weird, there is a check for this. Thinking we might fix this with the next release.
@jbhatab did you find the cause of this one?
yeah we fixed it last weekend
@robwise what's the PR?
@justin808 I've upgraded to 6.0.0-rc.1 per your advice in #416 and it doesn't seem to have solved this issue for me. I think I configured the upgrade correctly, but I'm not positive.
I've run my test suite three times on 5.2 and 6.0.0-rc.1 and it averaged 42 seconds on 5.2 and 44 seconds on 6.0.0-rc.1 with webpack running with the -w flag outside of the tests. Without webpack running it still averages 44 seconds so it appears it's not making use of the already built assets.
My 6.0.0 upgrade branch https://github.com/DigitalNZ/supplejack_website/tree/tl/react-refactor-6.0.0
You've got this:
https://github.com/DigitalNZ/supplejack_website/blob/tl/react-refactor-6.0.0/client/webpack.client.rails.config.js
config.output = {
filename: '[name]-bundle.js',
path: '../app/assets/webpack',
};
But you also have:
config.webpack_generated_files = %w( client-bundle.js )
entry: {
// See use of 'vendor' in the CommonsChunkPlugin inclusion below.
vendor: [
'babel-polyfill',
'jquery',
],
// This will contain the app entry points defined by webpack.hot.config and
// webpack.rails.config
app: [
'./app/bundles/SearchPage/startup/clientRegistration',
],
},
So you're having the test check look at client-bundle.js, but your webpack config builds vendor-bundle.js and app-bundle.js.
I'll re-open this ticket if there's evidence the issue is not yet fixed with v6.
Ah I figured it would be something silly like that. That seems to have solved it. Thanks!
Most helpful comment
This is definitely a bug that needs fixing.