Skip to content

Commit

Permalink
Update code base based on sp7 (#1285)
Browse files Browse the repository at this point in the history
* Remove the function to correct misconfiguration in webpacker.yml

* Update the codebase based on Shakapacker

* Update dependencies

* Update tests

* Update ujs

* Fix webpackConfig import

* Update Changelog

* Update missing shakapacker spelling change

* Remove bundle config

* Remove unneeded test for `data-reactroot`

This is an internal attribute of React and it is removed since React 16.
Despite this, it gets added in some cases, specially when we use the
bundled react with Sprocket. We don't need to depend our tests on the
existance of such attributes

* Update yarn.lock in dummy app
  • Loading branch information
ahangarha authored Jul 22, 2023
1 parent f02d973 commit a4bd5b3
Show file tree
Hide file tree
Showing 45 changed files with 1,706 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end

appraise 'shakapacker' do
gem 'rails', '~> 7.0.x'
gem 'shakapacker', '6.6.0'
gem 'shakapacker', '7.0.2'
end

appraise 'base' do
Expand Down
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ Changes since last non-beta release.
_Please add entries here for your pull requests that are not yet released._

### Breaking Changes
- Remove support & testing for Webpacker 3/4.
- Add support & testing for Shakapacker v6
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack))
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all.
- All in one PR! #1274
- Remove support & testing for Webpacker 3 and 4 #1274
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack)) #1274
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all. #1274

### Added
- Add support & testing for Shakapacker 7 #1274 and #1285

#### Changed
- The `react:component` generator now generates a function component by default #1271
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For version 2.7 documentation checkout [2.7-stable](https://github.com/reactjs/r
## Summary
React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits:
* Automatically renders React server-side and client-side
* Supports [Shakapacker](https://github.com/shakacode/shakapacker) v6.x
* Supports [Shakapacker](https://github.com/shakacode/shakapacker) v7
* Supports Sprockets 4.x, 3.x
* Lets you use [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html), [ES6](http://es6-features.org/), [TypeScript](https://www.typescriptlang.org/), [CoffeeScript](http://coffeescript.org/)

Expand Down Expand Up @@ -92,20 +92,20 @@ _Alternatively, get started with [Sprockets](#use-with-asset-pipeline)_
Prevent installing default javascript dependencies by using `--skip-javascript` option:

```bash
$ rails new my-app --skip-javascript
$ cd my-app
rails new my-app --skip-javascript
cd my-app
```

2. Install `shakapacker`:
```bash
$ bundle add shakapacker --strict
$ rails webpacker:install
bundle add shakapacker --strict
rails shakapacker:install
```

3. Install `react` and some other required npm packages:
```bash
$ yarn add react react-dom @babel/preset-react prop-types \
css-loader style-loader mini-css-extract-plugin css-minimizer-webpack-plugin
yarn add react react-dom @babel/preset-react prop-types \
css-loader style-loader mini-css-extract-plugin css-minimizer-webpack-plugin
```

Also update the Babel configuration in the `package.json` file:
Expand Down Expand Up @@ -169,7 +169,7 @@ Output: greeting: Hello from react-rails", inspect webpage in your browser to se
In order to run dev server with HMR feature you need to parallely run:

```bash
$ ./bin/webpacker-dev-server
$ ./bin/shakapacker-dev-server
```

Note: On Rails 6 you need to specify `webpack-dev-server` host. To this end, update `config/initializers/content_security_policy.rb` and uncomment relevant lines.
Expand Down Expand Up @@ -780,7 +780,7 @@ For example, to change the [ES6 Component template](https://github.com/reactjs/r

### 2.7 to 3.0
- Keep your `react_ujs` up to date: `yarn upgrade`
- **Drop support for Webpacker:** Before any ReactRails upgrade, make sure upgrading from Webpacker to Shakapacker 6.x.
- **Drop support for Webpacker:** Before any ReactRails upgrade, make sure upgrading from Webpacker to Shakapacker 7. For more information check out Shakapacker
- **SSR:** ReactRails 3.x requires separate compilations for server & client bundles. See [Webpack config](https://github.com/reactjs/react-rails/tree/master/test/dummy/config/webpack) directory in the dummy app to addapt the new implementation.

### 2.3 to 2.4
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/base.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ GEM
racc (~> 1.4)
nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4)
nokogiri (1.13.8-x86_64-linux)
racc (~> 1.4)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/shakapacker.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
source "http://rubygems.org"

gem "rails", "~> 7.0.x"
gem "shakapacker", "6.6.0"
gem "shakapacker", "7.0.2"

gemspec path: "../"
4 changes: 2 additions & 2 deletions gemfiles/shakapacker.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ GEM
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
shakapacker (6.6.0)
shakapacker (7.0.2)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
Expand Down Expand Up @@ -276,7 +276,7 @@ DEPENDENCIES
rails (~> 7.0.x)
react-rails!
selenium-webdriver
shakapacker (= 6.6.0)
shakapacker (= 7.0.2)
test-unit (~> 2.5)
webdrivers

Expand Down
2 changes: 1 addition & 1 deletion lib/assets/javascripts/react_ujs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a4bd5b3

Please sign in to comment.