-
-
Notifications
You must be signed in to change notification settings - Fork 631
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
Support for multiple server file bundles #343
Conversation
… - to be reviewed)
…ravel/react_on_rails into multiple_server_file_bundles
Please take a look at the PR: there's still some testing, clean-up and documentation work to do, but we would like to have a first round of feedback on:
Looking forward to seeing this bit of functionality supported, we (and probably a lot of others) will benefit from this mechanism. |
Looks like a great start. Let me know if you have questions. Reviewed 4 of 8 files at r1, 22 of 22 files at r3. README.md, line 225 [r3] (raw file): app/helpers/react_on_rails_helper.rb, line 87 [r3] (raw file):
lib/generators/react_on_rails/base_generator.rb, line 150 [r3] (raw file): lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt, line 18 [r3] (raw file): lib/react_on_rails/configuration.rb, line 13 [r3] (raw file): files += @configuration.server_bundle_js_files That's what I normally do, but either would work. Use parens if you use a method call. lib/react_on_rails/configuration.rb, line 43 [r3] (raw file): def normalize_server_bundle_js_files
@configuration.server_bundle_js_files = @configuration.server_bundle_js_files.map do |server_bundle_js_file|
if server_bundle_js_file.include?(File::SEPARATOR)
puts "[DEPRECATION] ReactOnRails: remove path from server_bundle_js_files in configuration. "\
"All generated files must go in #{@configuration.generated_assets_dir}"
server_bundle_js_file = File.basename(server_bundle_js_file)
else
server_bundle_js_file
end
end
end lib/react_on_rails/server_rendering_pool.rb, line 16 [r3] (raw file): @js_context_pools =
ReactOnRails.configuration.server_bundle_js_files.each_with_object({}) do |server_bundle_js_file, hash|
hash[server_bundle_js_file] = ConnectionPool.new(options) do
create_js_context(server_bundle_js_file)
end
end lib/react_on_rails/server_rendering_pool.rb, line 74 [r3] (raw file): js_context_pool_for_file lib/react_on_rails/server_rendering_pool.rb, line 95 [r3] (raw file): Normally, you'd have your default server_js_file used, but there is a case where you don't have any server js file. lib/react_on_rails/utils.rb, line 22 [r3] (raw file): spec/dummy/client/webpack.server.js, line 7 [r3] (raw file): entry: {
// See use of 'vendor' in the CommonsChunkPlugin inclusion below.
vendor: [
'babel-polyfill',
'es5-shim/es5-shim',
'es5-shim/es5-sham',
'jquery',
],
// This will contain the app entry points defined by webpack.hot.config and webpack.rails.config
app: [
'./app/bundles/comments/startup/clientRegistration',
],
}, spec/dummy/client/webpack.server.js, line 11 [r3] (raw file): spec/dummy/client/webpack.server.rails.build.config.js, line 15 [r3] (raw file): spec/dummy/client/app/startup/alternative-server.jsx, line 1 [r3] (raw file): Or else we really need to refactor this. Comments from the review on Reviewable.io |
@jopdeklein @lucke84 We need to make sure the docs provide a really solid use case for why we need different bundles. I would think we maybe able to accomplish the same end result by passing in a prop from rails and having a few conditionals in the code. In the case of client side bundles, there are clear reasons on why you'd separate the bundles:
I don't see any of these applying to the server side. Also see #287. Could that be a simpler solution. Basically, before we add this feature, we need to be 100% sure that the extra complexity of this is useful. Furthermore, we'll eventually move to using #183 for server rendering. CC: @alexfedoseev @jbhatab @robwise @thewoolleyman |
#287 is indeed something useful but if you need separate bundles in a more consistent way, it'll end up having the developers using this gem to hack a lot in order to achieve something that can work out of the box. At the same time, I agree on the fact this feature would introduce some complexity which has to be justified by a real-life, common need. Later on today we'll add a more structured comment to explain a proper use case. For now, I'm just about to update the PR with a couple changes to address part of your feedback (see specific comments on each item). Review status: all files reviewed at latest revision, 14 unresolved discussions, some commit checks broke. lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt, line 18 [r3] (raw file): Anyhow, what would you recommend?
lib/react_on_rails/configuration.rb, line 13 [r3] (raw file): lib/react_on_rails/configuration.rb, line 43 [r3] (raw file): lib/react_on_rails/server_rendering_pool.rb, line 16 [r3] (raw file): lib/react_on_rails/server_rendering_pool.rb, line 95 [r3] (raw file): Comments from the review on Reviewable.io |
Review status: 20 of 24 files reviewed at latest revision, 14 unresolved discussions. README.md, line 225 [r3] (raw file): spec/dummy/client/webpack.server.js, line 7 [r3] (raw file):
Either way we have to discuss the need for different bundles, we'll try to sketch our scenario and we can debate whether our approach is the simplest and most useful, perhaps there are simpler paths to what we want to accomplish. Comments from the review on Reviewable.io |
@jopdeklein Think about one big bundle and injecting a little JS code either before or after we render the components, create the stores. Per #287... |
Given our discussion for #287, should we keep this PR open now? We can close and always re-open later if needed. @jopdeklein |
@jopdeklein @lucke84 Please see #345. I plan to merge later today. I think this should meet your needs. |
@lucke84 @jopdeklein Can we close this one? |
@justin808 we're currently using our branch in production in order to fix a critical issue we were facing. We are not looking to deviate too far from your track, so I'll first try whether we can make it work with your proposal of a separate server bundle with a top level switch. If this works it should indeed be simpler than our bundle switching approach. |
@jopdeklein you probably don't mean a separate bundle, I'm guessing. You should be able to require whichever file you need dynamically. Use |
@justin808 You're right, I meant we have a separate I implemented your suggestions yesterday and it seems to work fine, and @lucke84 and I agree this is a simpler approach - feel free to close this PR. |
Adds support for multiple server bundle js files, as a follow-up of this conversation: #317
This change is