Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always builds bundle in tests #394

Closed
UberMouse opened this issue Apr 20, 2016 · 10 comments
Closed

Always builds bundle in tests #394

UberMouse opened this issue Apr 20, 2016 · 10 comments
Assignees
Labels
Milestone

Comments

@UberMouse
Copy link
Contributor

UberMouse commented Apr 20, 2016

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

@justin808
Copy link
Member

This is definitely a bug that needs fixing.

@justin808 justin808 added the bug label Apr 20, 2016
@justin808 justin808 added this to the 5.3 milestone Apr 20, 2016
@justin808 justin808 self-assigned this Apr 20, 2016
@jbhatab
Copy link
Member

jbhatab commented Apr 26, 2016

@UberMouse yeah that's weird, there is a check for this. Thinking we might fix this with the next release.

@justin808
Copy link
Member

@jbhatab did you find the cause of this one?

@robwise
Copy link
Contributor

robwise commented May 7, 2016

yeah we fixed it last weekend

@justin808
Copy link
Member

@robwise what's the PR?

@robwise
Copy link
Contributor

robwise commented May 7, 2016

#398

@UberMouse
Copy link
Contributor Author

@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

@justin808
Copy link
Member

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:

https://github.com/DigitalNZ/supplejack_website/blob/tl/react-refactor-6.0.0/config/initializers/react_on_rails.rb

  config.webpack_generated_files = %w( client-bundle.js )

https://github.com/DigitalNZ/supplejack_website/blob/tl/react-refactor-6.0.0/client/webpack.client.base.config.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.

@justin808
Copy link
Member

I'll re-open this ticket if there's evidence the issue is not yet fixed with v6.

@UberMouse
Copy link
Contributor Author

Ah I figured it would be something silly like that. That seems to have solved it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants