Skip to content

Commit 57a325f

Browse files
committed
Update changelog and docs
1 parent ecb26c8 commit 57a325f

File tree

2 files changed

+97
-25
lines changed

2 files changed

+97
-25
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Changes since the last non-beta release.
2929

3030
- **Improved Error Messages**: Error messages for version mismatches and package configuration issues now include package-manager-specific installation commands (npm, yarn, pnpm, bun). [PR #1881](https://github.com/shakacode/react_on_rails/pull/1881) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
3131

32+
#### Bug Fixes
33+
34+
- **Use as Git dependency**: All packages can now be installed as Git dependencies. This is useful for development and testing purposes. See [CONTRIBUTING.md](./CONTRIBUTING.md#git-dependencies) for documentation. [PR #1873](https://github.com/shakacode/react_on_rails/pull/1873) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
35+
3236
#### Breaking Changes
3337

3438
- **React on Rails Core Package**: Several Pro-only methods have been removed from the core package and are now exclusively available in the `react-on-rails-pro` package. If you're using any of the following methods, you'll need to migrate to React on Rails Pro:
@@ -1777,7 +1781,7 @@ such as:
17771781

17781782
- Fix several generator-related issues.
17791783

1780-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/16.1.1...master
1784+
[unreleased]: https://github.com/shakacode/react_on_rails/compare/16.1.1...master
17811785
[16.1.1]: https://github.com/shakacode/react_on_rails/compare/16.1.0...16.1.1
17821786
[16.1.0]: https://github.com/shakacode/react_on_rails/compare/16.0.0...16.1.0
17831787
[16.0.0]: https://github.com/shakacode/react_on_rails/compare/14.2.0...16.0.0

CONTRIBUTING.md

Lines changed: 92 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,59 +49,68 @@ It's critical to configure your IDE/editor to ignore certain directories. Otherw
4949
- /spec/dummy/tmp
5050
- /spec/react_on_rails/dummy-for-generators
5151

52-
# Configuring your test app to use your local fork
52+
# Example apps
5353

54-
You can test the `react-on-rails` gem using your own external test app or the gem's internal `spec/dummy` app. The `spec/dummy` app is an example of the various setup techniques you can use with the gem.
54+
The [`spec/dummy` app](https://github.com/shakacode/react_on_rails/blob/master/spec/dummy) is an example of the various setup techniques you can use with the gem.
5555

56-
```text
57-
├── test_app
58-
| └── client
59-
└── react_on_rails
60-
└── spec
61-
└── dummy
62-
```
56+
There are also two such apps for React on Rails Pro: [one using the Node renderer](https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/spec/dummy) and [one using ExecJS](https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/spec/execjs-compatible-dummy).
57+
58+
When you add a new feature, consider adding an example demonstrating it to the example apps.
59+
60+
# Testing your changes in an external application
61+
62+
You may also want to test your React on Rails changes with your own application.
63+
There are three main ways to do it: using local dependencies, Git dependencies, or tarballs.
64+
65+
## Local version
6366

64-
## Testing the Ruby Gem
67+
### Ruby
6568

66-
If you want to test the ruby parts of the gem with an application before you release a new version of the gem, you can specify the path to your local version via your test app's Gemfile:
69+
To make your Rails app use a local version of our gems, use
6770

6871
```ruby
69-
gem "react_on_rails", path: "../path-to-react-on-rails"
72+
gem "react_on_rails", path: "<React on Rails root>"
7073
```
7174

72-
Note that you will need to bundle install after making this change, but also that **you will need to restart your Rails application if you make any changes to the gem**.
75+
and/or
7376

74-
## Testing the Node package for React on Rails via Yalc
77+
```ruby
78+
gem "react_on_rails_pro", path: "<React on Rails root>/react_on_rails_pro"
79+
```
80+
81+
Note that you will need to run `bundle install` after making this change, but also that **you will need to restart your Rails application if you make any changes to the gem**.
7582

76-
In addition to testing the Ruby parts out, you can also test the Node package parts of the gem with an external application. First, be **sure** to build the NPM package:
83+
### JS
84+
85+
First, be **sure** to build the NPM package:
7786

7887
```sh
79-
cd react_on_rails/
88+
cd <React on Rails root>
8089
yarn
8190

8291
# Update the lib directory with babel compiled files
8392
yarn run build-watch
8493
```
8594

86-
You need to do this once:
95+
You need to do this once to make sure your app depends on our package:
8796

8897
```
89-
# Will send the updates to other folders
98+
cd <React on Rails root>/packages/react-on-rails
9099
yalc publish
91-
cd spec/dummy
100+
cd <your project root>
92101
yalc add react-on-rails
93102
```
94103

95104
The workflow is:
96105

97106
1. Make changes to the node package.
98-
2. **CRITICAL**: Run yalc push to send updates to all linked apps:
107+
2. **CRITICAL**: Run `yalc push` to send updates to all linked apps:
99108

100109
```
101-
cd <top dir>
110+
cd <React on Rails root>/packages/react-on-rails
102111
# Will send the updates to other folders - MUST DO THIS AFTER ANY CHANGES
103112
yalc push
104-
cd spec/dummy
113+
cd <your project root>
105114
106115
# Will update from yalc
107116
yarn
@@ -119,10 +128,69 @@ Package [email protected] added ==> /Users/justin/shakacode/react-o
119128
Don't forget you may need to run yarn after adding packages with yalc to install/update dependencies/bin scripts.
120129
```
121130

122-
#### Example: Testing NPM changes with the dummy app
131+
Of course, you can do the same with `react-on-rails-pro` and `@shakacode-tools/react-on-rails-pro-node-renderer` packages.
132+
133+
This is the approach `spec/dummy` apps use, so you can also look at their implementation.
134+
135+
### Example: Testing NPM changes with the dummy app
123136

124137
1. Add `console.log('Hello!')` to [clientStartup.ts, function render](https://github.com/shakacode/react_on_rails/blob/master/packages/react-on-rails/src/clientStartup.ts) in `/packages/react-on-rails/src/clientStartup.ts` to confirm we're getting an update to the node package client side. Do the same for function `serverRenderReactComponent` in [/packages/react-on-rails/src/serverRenderReactComponent.ts](https://github.com/shakacode/react_on_rails/blob/master/packages/react-on-rails/src/serverRenderReactComponent.ts).
125-
2. Refresh the browser if the server is already running or start the server using `foreman start` from `react_on_rails/spec/dummy` and navigate to `http://localhost:5000/`. You will now see the `Hello!` message printed in the browser's console. If you did not see that message, then review the steps above for the workflow of making changes and pushing them via yalc.
138+
2. Refresh the browser if the server is already running or start the server using `foreman start` from `react_on_rails/spec/dummy` and navigate to `http://localhost:3000/`. You will now see the `Hello!` message printed in the browser's console. If you did not see that message, then review the steps above for the workflow of making changes and pushing them via yalc.
139+
140+
## Git dependencies
141+
142+
If you push your local changes to Git, you can use them as dependencies as follows:
143+
144+
### Ruby
145+
146+
Adjust depending on the repo you pushed to and commit/branch you want to use, see [Bundler documentation](https://bundler.io/guides/git.html):
147+
148+
```ruby
149+
gem 'react_on_rails',
150+
git: 'https://github.com/shakacode/react_on_rails',
151+
branch: 'master'
152+
gem 'react_on_rails_pro',
153+
git: 'https://github.com/shakacode/react_on_rails',
154+
glob: 'react_on_rails_pro/react_on_rails_pro.gemspec',
155+
branch: 'master'
156+
```
157+
158+
### JS
159+
160+
Unfortunately, not all package managers allow depending on a single subfolder of a Git repo.
161+
The examples below are for the `master` branch of `react-on-rails` package.
162+
163+
#### Yarn Berry
164+
165+
See https://yarnpkg.com/protocol/git#workspaces-support.
166+
167+
```shell
168+
yarn add "[email protected]:shakacode/react_on_rails.git#workspace=react-on-rails&head=master"
169+
```
170+
171+
#### PNPM (starting from v9)
172+
173+
See https://github.com/pnpm/pnpm/issues/4765.
174+
175+
```shell
176+
pnpm add "github:shakacode/react_on_rails/repo#master&path:packages/react-on-rails"
177+
```
178+
179+
#### NPM
180+
181+
Explicitly doesn't want to support it: https://github.com/npm/cli/issues/6253.
182+
183+
## Tarball
184+
185+
This method works only for JS packages, not for Ruby gems.
186+
187+
Run `yarn pack` in the package you modified, copy the generated file into your app or upload it somewhere, and run
188+
189+
```shell
190+
npm install <tarball path/URL>
191+
```
192+
193+
or the equivalent command for your package manager.
126194

127195
# Development Setup for Gem and Node Package Contributors
128196

0 commit comments

Comments
 (0)