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.
default is nil
if defined:
- assets precompile will automatically run the rake task
- for development: react_component view for an
auto_load_bundle==truewill 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.
|
|
||
| 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.
#{' '} is probably accidental.
| 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.
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 |
justin808
left a comment
There was a problem hiding this comment.
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_packsrake taskauto_load_bundleconfig optiontestsforpacks generationDetail
It has been a mundane task to create entry files, e.g.:
client_entry.jsinside thepacksdirectory for a long time. The sole purpose of this file was to import a component and register it using theReactOnRails.registerAPI for usage in rails views.The PR automates this process by introducing the concept of
react on rail components. Any.jsxfile components inside theror_componentsdirectory 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.rbby settingconfig.components_directory = "new_directory_name"This change is