-
-
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
Add Automated Files System Based Pack Generation #1455
Conversation
@pulkitkkr what's remaining? |
82ef861
to
1a72b37
Compare
Needs documentation. Needs tests. Can we have the spec/dummy app show this? |
14dc032
to
7e01dd4
Compare
@pulkitkkr what's remaining? |
d2cd1d4
to
31cca27
Compare
The tests look fine. If the |
Also is |
@alexeyr-ci1 how about
which signifies that no additional work is required to ensure the right bundles load on a given Rails view. This works by automatically calling append_javascript_pack_tag and append_stylesheet_pack_tag whenever react_component and react_component_hash are used. |
# FILE SYSTEM BASED COMPONENT REGISTRY | ||
################################################################################ | ||
# components_directory is the directory that is used to automatically detect and register components for the usage on | ||
# the rails view. By Default any component inside `ror_components` directory is registered for the usage on rails view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default is nil
if defined:
- assets precompile will automatically run the rake task
- for development: react_component view for an
auto_load_bundle
==true
will confirm that the generated file inside thecomponents_directory
,generated/{component_name}
exists in thepacks
(entries) directory exists. If not, run the rake task to build, and log a message to the console that the generated files were rebuilt. If directory of generated is empty, build all of the generated. Or else just build the single generated file.
For non-development, raise an error suggesting that the rake task needs to run. This will mainly apply to a test run.
lib/tasks/generate_packs.rake
Outdated
|
||
namespace :react_on_rails do | ||
desc <<~DESC | ||
If there is a jsx file inside config.components_directory, this command generates corresponding packs and#{' '} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#{' '}
is probably accidental.
lib/tasks/generate_packs.rake
Outdated
namespace :react_on_rails do | ||
desc <<~DESC | ||
If there is a jsx file inside config.components_directory, this command generates corresponding packs and#{' '} | ||
registers the component for usage with react_component_with_bundle helper. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, is this helper added? Because I can't see it anywhere in changes. If it isn't added because it was decided to take another approach, please change this and also update the PR description.
But then do we ever want it to be false? Or at least do we want it to be false by default? Unless it's just for backward compatibility, in which case we can document that the default will be true in the next major version. |
b6ebf37
to
d7f4acf
Compare
1175779
to
752bafd
Compare
0287fa4
to
9feb90c
Compare
9272b19
to
59d5d8f
Compare
Address Docs related concerns @alexeyr |
2a74be0
to
656ec63
Compare
Previously, justin808 (Justin Gordon) wrote…
I do not favour giving in-depth details about the internal functioning, as it will make it difficult for beginners to understand. Also, To understand the internals, the reader must be familiar with the shakapacker API. Think about someone who just started using React on Rails, following the example to configure and get created. We as creators are familiar with append_javascript_pack_tag and append_stylesheet_pack_tag; It's not something that many people will be familiar with. If you still feel so, I can add details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 32 files reviewed, 56 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
docs/guides/file-system-based-automated-bundle-generation.md
line 110 at r21 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
I do not favour giving in-depth details about the internal functioning, as it will make it difficult for beginners to understand. Also, To understand the internals, the reader must be familiar with the shakapacker API. Think about someone who just started using React on Rails, following the example to configure and get created. We as creators are familiar with append_javascript_pack_tag and append_stylesheet_pack_tag; It's not something that many people will be familiar with.
If you still feel so, I can add details.
it's good to let folks know that are migrating. You can preface the explanatiion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 32 files reviewed, 55 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
docs/guides/file-system-based-automated-bundle-generation.md
line 131 at r21 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
If just client, It's recommended to use
client
in the name. Otherwise, the component withoutclient/server
in the filename gets registered for both server and client.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 9 files at r1, 3 of 16 files at r4, 9 of 25 files at r25, all commit messages.
Reviewable status: 15 of 32 files reviewed, 78 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
README.md
line 54 at r25 (raw file):
2. Tight integration with [shakapacker](https://github.com/shakacode/shakapacker) (or it's predecessor [rails/webpacker](https://github.com/rails/webpacker)). 3. Server-Side Rendering (SSR), often used for SEO crawler indexing and UX performance. 4. [Automated optimized entry-point creation and bundle inclusion when placing a component on a page. With this feature, you no longer need to configure javascript_pack_tags and stylesheet_pack_tags on your layouts based on what’s shown. “It just works!”](https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md)
back ticks
`javascript_pack_tags` and `stylesheet_pack_tags`
Code quote:
javascript_pack_tags and stylesheet_pack_tags
README.md
line 58 at r25 (raw file):
6. [Internationalization (I18n) and (localization)](https://www.shakacode.com/react-on-rails/docs/guides/i18n) 7. A supportive community. This [web search shows how live public sites are using React on Rails](https://publicwww.com/websites/%22react-on-rails%22++-undeveloped.com+depth%3Aall/). 8. [ReScript Support](https://github.com/shakacode/rescript-react-on-rails-example).
Please don't convert to numbers. Unnecessary.
docs/guides/file-system-based-automated-bundle-generation.md
line 105 at r25 (raw file):
│ └── Bar │ │ └── ... │ │ └── ror_components # configured as `components_directory`
I think we're changing that name because it's not just one directory.
docs/guides/file-system-based-automated-bundle-generation.md
line 131 at r25 (raw file):
<%= foo_component_one_data["componentHtml"] %>
The default value of the `auto_load_bundle` parameter can be specified by setting `config.auto_load_bundle` in `config/initializers/react_on_rails.rb` and thus removed from each call to `react_component`.
Code quote:
the default value of the `auto_load_bundle` parameter can be specified by setting `config.auto_load_bundle` in `config/initializers/react_on_rails.rb`.
lib/react_on_rails/configuration.rb
line 42 at r25 (raw file):
same_bundle_for_client_and_server: false, i18n_output_format: nil, components_directory: DEFAULT_COMPONENTS_DIR
components_dir_name
DEFAULT_COMPONENTS_DIR_NAME
lib/react_on_rails/configuration.rb
line 56 at r25 (raw file):
:i18n_dir, :i18n_yml_dir, :i18n_output_format, :server_render_method, :random_dom_id, :auto_load_bundle, :same_bundle_for_client_and_server, :rendering_props_extension, :components_directory
components_dir_name
lib/react_on_rails/packs_generator.rb
line 90 at r2 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
Done.
I prefer parens consistently used except where idiomatic, like put 'abc'
, @alexeyr-ci1 @pulkitkkr
lib/react_on_rails/packs_generator.rb
line 68 at r5 (raw file):
ReactOnRails.register({#{components_to_register.join(",\n")}}); /* eslint-enable */
no need for eslint clutter
lib/react_on_rails/packs_generator.rb
line 84 at r5 (raw file):
def self.generated_server_bundle_file_path generated_server_bundle_file_name = component_name defined_server_bundle_file_path.sub(".js", "-generated.js")
What if somebody used .ts
, or.jsx
or .tsx
?
How about.
- Get the file suffix
- Substring without file suffix length, then append the
-generated
and the old suffix?
lib/react_on_rails/packs_generator.rb
line 105 at r5 (raw file):
def self.source_entry_path ReactOnRails::WebpackerUtils.webpacker_source_entry_path
no need for method
inline
lib/react_on_rails/packs_generator.rb
line 161 at r5 (raw file):
source_path = ReactOnRails::WebpackerUtils.webpacker_source_path "#{source_path}/**/#{components_directory}"
"#{source_path}/**/#{components_dir_name}"
Code quote:
"#{source_path}/**/#{components_directory}"
lib/react_on_rails/packs_generator.rb
line 165 at r5 (raw file):
def self.components_directory ReactOnRails.configuration.components_directory
why have methods like this?
need to expose this for the api of packs_generator?
why not have some private methods and not have only static methods?
just have a factory method that creates an instance
lib/react_on_rails/packs_generator.rb
line 168 at r5 (raw file):
end def self.prepend_to_file_if_not_present(file, str)
a better var name for str
is text_to_prepend
see how it reads below
str
is a meaningless name
lib/react_on_rails/packs_generator.rb
line 173 at r5 (raw file):
contents = fd.read content += contents end
What is the point of ^^^^.
contents = File.read(file)
lib/react_on_rails/packs_generator.rb
line 175 at r5 (raw file):
end return if content.start_with? str
What if the import is not the first line? then put the import in twice?
plus method name says "not_present" versus "not_first"
lib/react_on_rails/packs_generator.rb
line 179 at r5 (raw file):
File.open(file, "w") do |fd| fd.write str + content end
and yet another way to write a file?
What's wrong with File.write(file, content)
?
lib/react_on_rails/packs_generator.rb
line 14 at r25 (raw file):
def self.generate return unless components_directory.present?
return unless components_dir_name.present?
Code quote:
return unless components_directory.present?
lib/react_on_rails/packs_generator.rb
line 41 at r25 (raw file):
f = File.new(output_path, "w") f.puts content f.close
Why use 3 lines
File.write(output_path, content)
lib/react_on_rails/packs_generator.rb
line 49 at r25 (raw file):
registered_component_name = component_name file_path <<~FILE_CONTENT /* eslint-disable */
Why not let people just exclude this directory from eslint?
lib/react_on_rails/packs_generator.rb
line 61 at r25 (raw file):
f = File.new(generated_server_bundle_file_path, "w") f.puts generated_server_pack_file_content f.close
One line ^^^^, not 3
lib/react_on_rails/packs_generator.rb
line 69 at r25 (raw file):
def self.generated_server_pack_file_content common_components_for_server_bundle = common_component_to_path.delete_if { |k| server_component_to_path.key? k } component_for_server_registration_to_path = common_components_for_server_bundle.merge server_component_to_path
I hate excluding parens for syntax like this.
yes, rubocop has no rule for this.
lib/react_on_rails/packs_generator.rb
line 113 at r25 (raw file):
server_bundle_file_name = ReactOnRails.configuration.server_bundle_js_file Dir.glob("#{source_entry_path}/**/#{server_bundle_file_name}").first
This is not right. There is a method that gives this exact file path.
server_js_file = ReactOnRails::Utils.server_bundle_js_file_path
lib/react_on_rails/packs_generator.rb
line 126 at r25 (raw file):
def self.relative_component_path_from_generated_pack(ror_component_path) component_file_path = Pathname.new ror_component_path generated_pack_path = Pathname.new generated_pack_path ror_component_path
no parens?
And I especially don't understand this line. It seems like a syntax error! or You're missing a comma? and parens?
generated_pack_path = Pathname.new generated_pack_path ror_component_path
lib/react_on_rails/packs_generator.rb
line 135 at r25 (raw file):
to_path = Pathname.new to # TODO: Debug Relative Path always has extra '../'
remove todo?
lib/react_on_rails/test_helper/webpack_assets_status_checker.rb
line 29 at r25 (raw file):
def stale_generated_webpack_files stale_generated_files client_files
I hate skipping the parens.
lib/react_on_rails/test_helper/webpack_assets_status_checker.rb
line 97 at r25 (raw file):
def components_search_path "#{source_path}/**/#{ReactOnRails.configuration.components_directory}"
"#{source_path}/**/#{ReactOnRails.configuration.components_dir_name}"
Code quote:
"#{source_path}/**/#{ReactOnRails.configuration.components_directory}"
lib/tasks/generate_packs.rake
line 5 at r25 (raw file):
namespace :react_on_rails do desc <<~DESC If there is a jsx file inside config.components_directory, this command generates corresponding packs.
If there is a file inside any directory matching config.components_dir_name, this command generates corresponding packs.
Note, don't mention jsx in case tsx is used.
I'm not sure what would happen with ReScript.
Code quote:
If there is a jsx file inside config.components_directory, this command generates corresponding packs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 15 of 32 files reviewed, 78 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
README.md
line 54 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
back ticks
`javascript_pack_tags` and `stylesheet_pack_tags`
Done.
README.md
line 58 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Please don't convert to numbers. Unnecessary.
Done.
docs/guides/file-system-based-automated-bundle-generation.md
line 105 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
I think we're changing that name because it's not just one directory.
Done.
docs/guides/file-system-based-automated-bundle-generation.md
line 131 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
The default value of the `auto_load_bundle` parameter can be specified by setting `config.auto_load_bundle` in `config/initializers/react_on_rails.rb` and thus removed from each call to `react_component`.
Done.
lib/react_on_rails/configuration.rb
line 42 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
components_dir_name
DEFAULT_COMPONENTS_DIR_NAME
Updated to components_subdirectory
and DEFAULT_COMPONENTS_SUBDIRECTORY
lib/react_on_rails/configuration.rb
line 56 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
components_dir_name
updated to components_subdirectory
lib/react_on_rails/packs_generator.rb
line 68 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
no need for eslint clutter
REMOVED
lib/react_on_rails/packs_generator.rb
line 161 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
"#{source_path}/**/#{components_dir_name}"
Done.
"#{source_path}/**/#{components_subdirectory}"
lib/react_on_rails/packs_generator.rb
line 168 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
a better var name for
str
istext_to_prepend
see how it reads below
str
is a meaningless name
Done.
lib/react_on_rails/packs_generator.rb
line 173 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
What is the point of ^^^^.
contents = File.read(file)
Done.
lib/react_on_rails/packs_generator.rb
line 175 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
What if the import is not the first line? then put the import in twice?
plus method name says "not_present" versus "not_first"
Done.
lib/react_on_rails/packs_generator.rb
line 179 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
and yet another way to write a file?
What's wrong with
File.write(file, content)
?
Done.
lib/react_on_rails/packs_generator.rb
line 14 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
return unless components_dir_name.present?
return unless components_subdirectory.present?
lib/react_on_rails/packs_generator.rb
line 41 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Why use 3 lines
File.write(output_path, content)
Done.
lib/react_on_rails/packs_generator.rb
line 49 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Why not let people just exclude this directory from eslint?
Done.
lib/react_on_rails/packs_generator.rb
line 61 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
One line ^^^^, not 3
Done.
lib/react_on_rails/packs_generator.rb
line 113 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
This is not right. There is a method that gives this exact file path.
server_js_file = ReactOnRails::Utils.server_bundle_js_file_path
Done.
lib/react_on_rails/packs_generator.rb
line 135 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
remove todo?
Done.
lib/react_on_rails/test_helper/webpack_assets_status_checker.rb
line 97 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
"#{source_path}/**/#{ReactOnRails.configuration.components_dir_name}"
Done.
lib/tasks/generate_packs.rake
line 5 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
If there is a file inside any directory matching config.components_dir_name, this command generates corresponding packs.
Note, don't mention jsx in case tsx is used.
I'm not sure what would happen with ReScript.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 12 files at r3, 1 of 18 files at r11, 2 of 23 files at r18, 1 of 23 files at r20, 1 of 25 files at r23, 11 of 25 files at r25, 9 of 10 files at r26, all commit messages.
Reviewable status: 31 of 32 files reviewed, 53 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, @pulkitkkr, and @tomdracz)
docs/api/view-helpers-api.md
line 30 at r26 (raw file):
- **props:** Ruby Hash which contains the properties to pass to the react object, or a JSON string. If you pass a string, we'll escape it for you. - **prerender:** enable server-side rendering of a component. Set to false when debugging! - **auto_load_bundle:** will automatically load bundle for component by calling `append_javascript_pack_tag` and `append_stylesheet_pack_tag` under the hood.
- **auto_load_bundle:** will automatically load the bundle for component by calling `append_javascript_pack_tag` and `append_stylesheet_pack_tag` under the hood.
the bundle
docs/guides/configuration.md
line 160 at r26 (raw file):
# components_subdirectory is the name of the directory that is used to automatically detect and register components # for the usage on the rails view. default is nil, you can enable the feature by updating it in the next line. config.components_subdirectory = "ror_components"
# components_subdirectory is the name of the subdirectory matched to detect and register components automatically
# The default is nil. You can enable the feature by updating it in the next line.
Please update
Code quote:
# for the usage on the rails view. default is nil, you can enable the feature by updating it in the next line.
docs/guides/file-system-based-automated-bundle-generation.md
line 19 at r26 (raw file):
### Configure Components Subdirectory `components_subdirectory` is the name of the directories that contain components that will be automatically registered and used in Rails views.
`components_subdirectory` is the name of the matched directories containing components that will be automatically registered for use by the view helpers.
Code quote:
`components_subdirectory` is the name of the directories that contain components that will be automatically registered and used in Rails views.
lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb
line 51 at r26 (raw file):
################################################################################ # components_subdirectory is the directory that is used to automatically detect and register components for the usage # on the rails view. default is nil, you can enable the feature by updating it in the next line.
`components_subdirectory` is the name of the matching directories that contain automatically registered components for use in the Rails views.
The default is nil, you can enable the feature by updating it in the next line.
Code quote:
# components_subdirectory is the directory that is used to automatically detect and register components for the usage
# on the rails view. default is nil, you can enable the feature by updating it in the next line.
lib/react_on_rails/packs_generator.rb
line 78 at r1 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
@tomdracz Do you think it's to use
FileUtils.rm_rf
?
use parens
lib/react_on_rails/packs_generator.rb
line 84 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
What if somebody used
.ts
, or.jsx
or.tsx
?How about.
- Get the file suffix
- Substring without file suffix length, then append the
-generated
and the old suffix?
@pulkitkkr what about TypeScript???
lib/react_on_rails/packs_generator.rb
line 105 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
no need for method
inline
lib/react_on_rails/packs_generator.rb
line 165 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
why have methods like this?
need to expose this for the api of packs_generator?
why not have some private methods and not have only static methods?
just have a factory method that creates an instance
lib/react_on_rails/packs_generator.rb
line 69 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
I hate excluding parens for syntax like this.
yes, rubocop has no rule for this.
@pulkitkkr please change
lib/react_on_rails/packs_generator.rb
line 113 at r25 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
Done.
You need to throw an exception if you get a URL rather than a file. See how other callers of this method handle both files and URLs.
lib/react_on_rails/packs_generator.rb
line 138 at r26 (raw file):
component_file_pathname = Pathname.new ror_component_path component_generated_pack_path = generated_pack_path(ror_component_path) generated_pack_pathname = Pathname.new component_generated_pack_path
parens?
lib/react_on_rails/packs_generator.rb
line 286 at r26 (raw file):
file_content = File.read(file) return if file_content.include? text_to_prepend
parens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 10 files at r26.
Reviewable status: all files reviewed, 52 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, @pulkitkkr, and @tomdracz)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 51 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
docs/api/view-helpers-api.md
line 30 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
- **auto_load_bundle:** will automatically load the bundle for component by calling `append_javascript_pack_tag` and `append_stylesheet_pack_tag` under the hood.
the bundle
Done.
docs/guides/configuration.md
line 160 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
# components_subdirectory is the name of the subdirectory matched to detect and register components automatically # The default is nil. You can enable the feature by updating it in the next line.
Please update
Done.
docs/guides/file-system-based-automated-bundle-generation.md
line 19 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
`components_subdirectory` is the name of the matched directories containing components that will be automatically registered for use by the view helpers.
Done.
lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb
line 51 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
`components_subdirectory` is the name of the matching directories that contain automatically registered components for use in the Rails views. The default is nil, you can enable the feature by updating it in the next line.
Done.
lib/react_on_rails/packs_generator.rb
line 90 at r2 (raw file):
Previously, justin808 (Justin Gordon) wrote…
I prefer parens consistently used except where idiomatic, like
put 'abc'
, @alexeyr-ci1 @pulkitkkr
Done.
lib/react_on_rails/packs_generator.rb
line 105 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Done
lib/react_on_rails/packs_generator.rb
line 165 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
why have methods like this?
need to expose this for the api of packs_generator?
why not have some private methods and not have only static methods?
just have a factory method that creates an instance
Done.
lib/react_on_rails/packs_generator.rb
line 69 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
@pulkitkkr please change
Done.
lib/react_on_rails/packs_generator.rb
line 126 at r25 (raw file):
idiomatic
Updated to:
component_file_pathname = Pathname.new ror_component_path
component_generated_pack_path = generated_pack_path(ror_component_path)
generated_pack_pathname = Pathname.new component_generated_pack_path
lib/react_on_rails/packs_generator.rb
line 138 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
parens?
Done.
Code quote:
component_generated_pack_path
lib/react_on_rails/packs_generator.rb
line 286 at r26 (raw file):
Previously, justin808 (Justin Gordon) wrote…
parens
Done.
lib/react_on_rails/test_helper/webpack_assets_status_checker.rb
line 29 at r25 (raw file):
Previously, justin808 (Justin Gordon) wrote…
I hate skipping the parens.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 26 of 32 files reviewed, 51 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, @justin808, and @pulkitkkr)
lib/react_on_rails/packs_generator.rb
line 84 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
@pulkitkkr what about TypeScript???
Done.
3cbe059
to
6cc8895
Compare
6cc8895
to
8c755d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 25 of 32 files reviewed, 51 unresolved discussions (waiting on @alexeyr, @alexeyr-ci1, and @justin808)
docs/guides/file-system-based-automated-bundle-generation.md
line 110 at r21 (raw file):
it's good to let folks know that are migrating. You can preface the explanatiion
lib/react_on_rails/packs_generator.rb
line 165 at r5 (raw file):
Previously, pulkitkkr (Pulkit) wrote…
Done.
Done.
lib/react_on_rails/packs_generator.rb
line 113 at r25 (raw file):
You need to throw an exception if you get a URL rather than a file. See how other callers of this method handle both files and URLs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reviewed 4 of 6 files at r27, 3 of 3 files at r28, all commit messages.
Reviewable status: all files reviewed, 36 unresolved discussions (waiting on @alexeyr and @alexeyr-ci1)
Packs get generated after calling
In our case it breaks feature tests (an issue with sass variables, but there is no such an issue while running module ReactOnRails
class PacksGenerator
def generate_packs_if_stale
# does nothing
end
end
end |
Summary
This PR adds
react_on_rails:generate_packs
rake taskauto_load_bundle
config optiontests
forpacks generation
Detail
It has been a mundane task to create entry files, e.g.:
client_entry.js
inside thepacks
directory for a long time. The sole purpose of this file was to import a component and register it using theReactOnRails.register
API for usage in rails views.The PR automates this process by introducing the concept of
react on rail components
. Any.jsx
file components inside theror_components
directory will be detected and registered automatically for the usage on Rails View using the new helperreact_component_with_bundle
.The name of the directory can be configured in
src/config/initializers/react_on_rails.rb
by settingconfig.components_directory = "new_directory_name"
This change is