react_on_rails 11.3.0 → 12.0.0.pre.beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +320 -0
  3. data/.eslintignore +2 -1
  4. data/.eslintrc +23 -1
  5. data/.github/FUNDING.yml +1 -0
  6. data/.gitignore +3 -1
  7. data/.prettierignore +10 -1
  8. data/.prettierrc +3 -0
  9. data/.rubocop.yml +37 -11
  10. data/.travis.yml +9 -22
  11. data/CHANGELOG.md +65 -6
  12. data/CONTRIBUTING.md +60 -71
  13. data/Gemfile +3 -4
  14. data/{COMM-LICENSE → REACT-ON-RAILS-PRO-LICENSE} +6 -9
  15. data/README.md +129 -92
  16. data/Rakefile +0 -7
  17. data/SUMMARY.md +7 -11
  18. data/book.json +5 -5
  19. data/docs/additional-reading/asset-pipeline.md +8 -16
  20. data/docs/additional-reading/react-helmet.md +30 -10
  21. data/docs/additional-reading/react-router.md +52 -75
  22. data/docs/additional-reading/server-rendering-tips.md +12 -7
  23. data/docs/api/javascript-api.md +3 -3
  24. data/docs/api/redux-store-api.md +4 -2
  25. data/docs/api/view-helpers-api.md +6 -7
  26. data/docs/basics/configuration.md +83 -69
  27. data/docs/basics/deployment.md +2 -4
  28. data/docs/basics/heroku-deployment.md +24 -0
  29. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +49 -0
  30. data/docs/basics/i18n.md +45 -23
  31. data/docs/basics/installation-into-an-existing-rails-app.md +4 -9
  32. data/docs/basics/react-server-rendering.md +1 -1
  33. data/docs/basics/recommended-project-structure.md +5 -22
  34. data/docs/basics/{generator-functions-and-railscontext.md → render-functions-and-railscontext.md} +59 -21
  35. data/docs/basics/rspec-configuration.md +27 -16
  36. data/docs/basics/upgrading-react-on-rails.md +58 -2
  37. data/docs/basics/webpack-configuration.md +18 -8
  38. data/docs/contributor-info/errors-with-hooks.md +45 -0
  39. data/docs/contributor-info/pull-requests.md +44 -0
  40. data/docs/misc/doctrine.md +1 -1
  41. data/docs/{misc-pending → outdated}/code-splitting.md +12 -8
  42. data/docs/{basics → outdated}/how-react-on-rails-works.md +8 -4
  43. data/docs/{misc-pending → outdated}/manual-installation-overview.md +5 -5
  44. data/docs/{additional-reading → outdated}/rails-assets-relative-paths.md +3 -3
  45. data/docs/{misc-pending → outdated}/rails-assets.md +2 -12
  46. data/docs/{misc → outdated}/rails3.md +0 -0
  47. data/docs/tutorial.md +94 -68
  48. data/jest.config.js +4 -0
  49. data/lib/generators/react_on_rails/base_generator.rb +2 -2
  50. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  51. data/lib/generators/react_on_rails/generator_helper.rb +4 -6
  52. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +3 -1
  53. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-hmr +26 -0
  54. data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +20 -40
  55. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +4 -1
  56. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +4 -8
  57. data/lib/generators/react_on_rails/templates/redux/base/app/javascript/bundles/HelloWorld/store/helloWorldStore.js +1 -3
  58. data/lib/react_on_rails.rb +3 -1
  59. data/lib/react_on_rails/configuration.rb +58 -28
  60. data/lib/react_on_rails/error.rb +2 -0
  61. data/lib/react_on_rails/helper.rb +41 -91
  62. data/lib/react_on_rails/json_parse_error.rb +2 -0
  63. data/lib/react_on_rails/locales/base.rb +150 -0
  64. data/lib/react_on_rails/locales/to_js.rb +37 -0
  65. data/lib/react_on_rails/locales/to_json.rb +27 -0
  66. data/lib/react_on_rails/prerender_error.rb +11 -15
  67. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +41 -46
  68. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +7 -8
  69. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +17 -0
  70. data/lib/react_on_rails/utils.rb +14 -19
  71. data/lib/react_on_rails/version.rb +1 -1
  72. data/lib/react_on_rails/version_checker.rb +1 -0
  73. data/lib/react_on_rails/webpacker_utils.rb +19 -2
  74. data/lib/tasks/assets.rake +33 -46
  75. data/lib/tasks/locale.rake +4 -2
  76. data/package-scripts.yml +11 -8
  77. data/package.json +29 -28
  78. data/rakelib/dummy_apps.rake +1 -9
  79. data/rakelib/example_type.rb +3 -1
  80. data/rakelib/examples.rake +3 -0
  81. data/rakelib/lint.rake +2 -7
  82. data/rakelib/node_package.rake +2 -2
  83. data/rakelib/release.rake +0 -6
  84. data/rakelib/run_rspec.rake +5 -18
  85. data/react_on_rails.gemspec +4 -5
  86. data/tsconfig.json +14 -0
  87. data/webpackConfigLoader.js +3 -2
  88. data/yarn.lock +4333 -2209
  89. metadata +46 -57
  90. data/Gemfile.rails32 +0 -73
  91. data/docs/additional-reading/babel.md +0 -5
  92. data/docs/additional-reading/heroku-deployment.md +0 -92
  93. data/docs/additional-reading/hot-reloading-rails-development-asset-pipeline.md +0 -47
  94. data/docs/api/ruby-api-hot-reload-view-helpers.md +0 -44
  95. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +0 -12
  96. data/lib/react_on_rails/assets_precompile.rb +0 -153
  97. data/lib/react_on_rails/locales_to_js.rb +0 -138
@@ -8,7 +8,7 @@ require "active_support/core_ext/string"
8
8
 
9
9
  module ReactOnRails
10
10
  module Utils
11
- TRUNCATION_FILLER = "\n... TRUNCATED ...\n".freeze
11
+ TRUNCATION_FILLER = "\n... TRUNCATED ...\n"
12
12
 
13
13
  # https://forum.shakacode.com/t/yak-of-the-week-ruby-2-4-pathname-empty-changed-to-look-at-file-size/901
14
14
  # return object if truthy, else return nil
@@ -24,13 +24,12 @@ module ReactOnRails
24
24
  # Pass in the msg and color as a symbol.
25
25
  def self.wrap_message(msg, color = :red)
26
26
  wrapper_line = ("=" * 80).to_s
27
- # rubocop:disable Layout/IndentHeredoc
28
- fenced_msg = <<-MSG
29
- #{wrapper_line}
30
- #{msg.strip}
31
- #{wrapper_line}
27
+ fenced_msg = <<~MSG
28
+ #{wrapper_line}
29
+ #{msg.strip}
30
+ #{wrapper_line}
32
31
  MSG
33
- # rubocop:enable Layout/IndentHeredoc
32
+
34
33
  Rainbow(fenced_msg).color(color)
35
34
  end
36
35
 
@@ -48,14 +47,13 @@ module ReactOnRails
48
47
  unless status.success?
49
48
  stdout_msg = stdout.present? ? "\nstdout:\n#{stdout.strip}\n" : ""
50
49
  stderr_msg = stderr.present? ? "\nstderr:\n#{stderr.strip}\n" : ""
51
- # rubocop:disable Layout/IndentHeredoc
52
- msg = <<-MSG
53
- React on Rails FATAL ERROR!
54
- #{failure_message}
55
- cmd: #{cmd}
56
- exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
50
+ msg = <<~MSG
51
+ React on Rails FATAL ERROR!
52
+ #{failure_message}
53
+ cmd: #{cmd}
54
+ exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
57
55
  MSG
58
- # rubocop:enable Layout/IndentHeredoc
56
+
59
57
  puts wrap_message(msg)
60
58
 
61
59
  # Rspec catches exit without! in the exit callbacks
@@ -72,11 +70,8 @@ exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
72
70
  # Either:
73
71
  # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
74
72
  # 2. Using a different bundle (different Webpack config), so file is not hashed, and
75
- # bundle_js_path will throw.
76
- # 3. Not using webpacker, and bundle_js_path always returns
77
-
78
- # Note, server bundle should not be in the manifest
79
- # If using webpacker gem per https://github.com/rails/webpacker/issues/571
73
+ # bundle_js_path will throw so the default path is used without a hash.
74
+ # 3. Not using webpacker, and this method returns the bundle_js_file_path
80
75
  return @server_bundle_path if @server_bundle_path && !Rails.env.development?
81
76
 
82
77
  bundle_name = ReactOnRails.configuration.server_bundle_js_file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "11.3.0".freeze
4
+ VERSION = "12.0.0-beta.4"
5
5
  end
@@ -5,6 +5,7 @@ module ReactOnRails
5
5
  # against each otherat runtime.
6
6
  class VersionChecker
7
7
  attr_reader :node_package_version
8
+
8
9
  MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/.freeze
9
10
 
10
11
  def self.build
@@ -1,16 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ReactOnRails
2
4
  module WebpackerUtils
3
5
  def self.using_webpacker?
4
6
  ReactOnRails::Utils.gem_available?("webpacker")
5
7
  end
6
8
 
9
+ def self.webpacker_webpack_production_config_exists?
10
+ webpacker_webpack_config_abs_path = File.join(Rails.root,
11
+ "config/webpack/production.js")
12
+ File.exist?(webpacker_webpack_config_abs_path)
13
+ end
14
+
7
15
  def self.dev_server_running?
8
16
  return false unless using_webpacker?
9
17
 
10
18
  Webpacker.dev_server.running?
11
19
  end
12
20
 
13
- # This returns either a URL for the webpack-dev-server or a file path
21
+ # This returns either a URL for the webpack-dev-server, non-server bundle or
22
+ # the hashed server bundle if using the same bundle for the client.
23
+ # Otherwise returns a file path.
14
24
  def self.bundle_js_uri_from_webpacker(bundle_name)
15
25
  # Note Webpacker 3.4.3 manifest lookup is inside of the public_output_path
16
26
  # [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js")
@@ -18,7 +28,14 @@ module ReactOnRails
18
28
  # Next line will throw if the file or manifest does not exist
19
29
  hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name)
20
30
 
21
- if Webpacker.dev_server.running?
31
+ # support for hashing the server-bundle and having that built
32
+ # by a webpack watch process and not served by the webpack-dev-server, then we
33
+ # need an extra config value "same_bundle_for_client_and_server" where a value of false
34
+ # would mean that the bundle is created by a separate webpack watch process.
35
+ is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file
36
+
37
+ if Webpacker.dev_server.running? && (!is_server_bundle ||
38
+ ReactOnRails.configuration.same_bundle_for_client_and_server)
22
39
  "#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}#{hashed_bundle_name}"
23
40
  else
24
41
  File.expand_path(File.join("public", hashed_bundle_name)).to_s
@@ -1,69 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "react_on_rails/assets_precompile"
4
- require "active_support"
3
+ # Important: The default assets:precompile is modified ONLY if the rails/webpacker webpack config
4
+ # does not exist!
5
5
 
6
- if defined?(Sprockets)
7
- namespace :react_on_rails do
8
- namespace :assets do
9
- desc "Creates non-digested symlinks for the assets in the public asset dir"
10
- task symlink_non_digested_assets: :"assets:environment" do
11
- ReactOnRails::AssetsPrecompile.new.symlink_non_digested_assets
12
- end
6
+ require "active_support"
13
7
 
14
- desc "Cleans all broken symlinks for the assets in the public asset dir"
15
- task delete_broken_symlinks: :"assets:environment" do
16
- ReactOnRails::AssetsPrecompile.new.delete_broken_symlinks
17
- end
8
+ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
9
+ ENV["NODE_ENV"] ||= "development"
18
10
 
19
- # In this task, set prerequisites for the assets:precompile task
20
- desc <<-DESC.strip_heredoc
21
- Create webpack assets before calling assets:environment
22
- The webpack task must run before assets:environment task.
23
- Otherwise Sprockets cannot find the files that webpack produces.
24
- This is the secret sauce for how a Heroku deployment knows to create the webpack generated JavaScript files.
25
- DESC
26
- task compile_environment: :webpack do
27
- Rake::Task["assets:environment"].invoke
28
- end
11
+ unless ReactOnRails::WebpackerUtils.webpacker_webpack_production_config_exists?
12
+ # Ensure that rails/webpacker does not call bin/webpack if we're providing
13
+ # the build command.
14
+ ENV["WEBPACKER_PRECOMPILE"] = "false"
29
15
 
30
- desc "Delete assets created with webpack, in the generated assetst directory (/app/assets/webpack)"
31
- task clobber: :environment do
32
- ReactOnRails::AssetsPrecompile.new.clobber
33
- end
16
+ if Rake::Task.task_defined?("assets:precompile")
17
+ Rake::Task["assets:precompile"].enhance do
18
+ Rake::Task["react_on_rails:assets:webpack"].invoke
19
+ puts "Invoking task webpacker:clean from React on Rails"
20
+ Rake::Task["webpacker:clean"].invoke
34
21
  end
22
+ else
23
+ Rake::Task.define_task("assets:precompile" => ["react_on_rails:assets:webpack",
24
+ "webpacker:clean"])
35
25
  end
36
-
37
- # These tasks run as pre-requisites of assets:precompile.
38
- # Note, it's not possible to refer to ReactOnRails configuration values at this point.
39
- Rake::Task["assets:precompile"]
40
- .clear_prerequisites
41
- .enhance([:environment, "react_on_rails:assets:compile_environment"])
42
- .enhance do
43
- Rake::Task["react_on_rails:assets:symlink_non_digested_assets"].invoke
44
- Rake::Task["react_on_rails:assets:delete_broken_symlinks"].invoke
45
- end
46
26
  end
47
27
 
48
28
  # Sprockets independent tasks
49
29
  namespace :react_on_rails do
50
30
  namespace :assets do
51
31
  desc <<-DESC.strip_heredoc
52
- Compile assets with webpack
53
- Uses command defined with ReactOnRails.configuration.build_production_command
54
-
55
- sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
32
+ Compile assets with webpack
33
+ Uses command defined with ReactOnRails.configuration.build_production_command
34
+ sh "#{ReactOnRails::Utils.prepend_cd_node_modules_directory('<ReactOnRails.configuration.build_production_command>')}"
35
+ Note: This command is not automatically added to assets:precompile if the rails/webpacker
36
+ configuration file config/webpack/production.js exists.
56
37
  DESC
57
38
  task webpack: :locale do
58
- if Rake::Task.task_defined?("webpacker:compile")
59
- # TODO: Eventually, this will need reconsideration if we use any of the Webpacker compilation
60
- Rake::Task["webpacker:compile"].clear
61
- end
62
-
63
39
  if ReactOnRails.configuration.build_production_command.present?
64
40
  sh ReactOnRails::Utils.prepend_cd_node_modules_directory(
65
41
  ReactOnRails.configuration.build_production_command
66
42
  ).to_s
43
+ else
44
+ msg = <<~MSG
45
+ React on Rails is aborting webpack compilation from task react_on_rails:assets:webpack
46
+ because you do not have the `config.build_production_command` defined.
47
+
48
+ Note, this task may have run as part of `assets:precompile`. If file
49
+ config/webpack/production.js does not exist, React on Rails will modify
50
+ the default `asset:precompile` to run task `react_on_rails:assets:webpack`.
51
+ MSG
52
+ puts Rainbow(msg).red
53
+ exit!(1)
67
54
  end
68
55
  end
69
56
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "react_on_rails/locales_to_js"
3
+ require "react_on_rails/locales/base"
4
+ require "react_on_rails/locales/to_js"
5
+ require "react_on_rails/locales/to_json"
4
6
  require "active_support"
5
7
 
6
8
  namespace :react_on_rails do
@@ -10,6 +12,6 @@ namespace :react_on_rails do
10
12
  the "ReactOnRails.configuration.i18n_dir".
11
13
  DESC
12
14
  task locale: :environment do
13
- ReactOnRails::LocalesToJs.new
15
+ ReactOnRails::Locales.compile
14
16
  end
15
17
  end
@@ -1,12 +1,12 @@
1
1
  scripts:
2
2
  lint:
3
- description: Run all linters (eslint, flow)
3
+ description: Run all linters (eslint, tsc)
4
4
  script: concurrently --prefix "[{name}]" --names "ESLINT" -c "blue,yellow,magenta,orange" "nps eslint"
5
5
 
6
6
  eslint:
7
7
  default:
8
8
  description: Run eslint.
9
- script: eslint . --ext ".js,.jsx"
9
+ script: eslint . --ext ".js,.jsx,.ts"
10
10
  fix:
11
11
  description: Run eslint and auto-fix.
12
12
  script: nps "eslint --fix"
@@ -17,30 +17,33 @@ scripts:
17
17
  format:
18
18
  default:
19
19
  description: Format files using prettier.
20
- script: concurrently --prefix "[{name}]" --names "js,json" -c "yellow,magenta,green" "nps format.js" "nps format.json"
20
+ script: concurrently --prefix "[{name}]" --names "ts,js,json" -c "yellow,magenta,green" "nps format.js" "nps format.json"
21
21
  listDifferent:
22
22
  description: Check that all files were formatted using prettier.
23
23
  script: |
24
24
  concurrently \
25
25
  --prefix "[{name}]" \
26
- --names "js,css,json" \
27
- -c "yellow,magenta,green" \
26
+ --names "ts,js,json" \
27
+ -c "yellow,magenta" \
28
28
  "nps format.js.listDifferent" \
29
29
  "nps format.json.listDifferent"
30
30
  js:
31
31
  default:
32
32
  description: Run prettier-eslint on JS.
33
- script: prettier "packages/**/*.@(js|jsx)" "spec/dummy/client/app/**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --write
33
+ #script: prettier "packages/**/*.@(js|jsx)" "spec/dummy/client/app/**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --write
34
+ script: prettier "**/*.@(js|jsx)" --write
34
35
  listDifferent:
35
36
  description: Check if any JS files would change by running prettier-eslint.
36
- script: prettier "**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --list-different
37
+ # script: prettier "**/*.@(js|jsx)" "webpack.config.babel.js" "webpack/**/*.js" --list-different
38
+ script: prettier "**/*.@(js|jsx)" --list-different
37
39
  json:
38
40
  default:
39
41
  description: Run prettier on JSON files.
40
42
  script: rm -rf packages/vm-renderer/tests/tmp && prettier "**/*.json" --write
41
43
  listDifferent:
42
44
  description: Check if any JSON files would change by running prettier-eslint.
43
- script: prettier "**/*.json" "../spec/**/*.json" --list-different
45
+ script: prettier "**/*.json" --list-different
46
+
44
47
  renderer:
45
48
  description: Starts the node renderer.
46
49
  script: node renderer.js
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "11.3.0",
3
+ "version": "12.0.0-beta.4",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
@@ -9,70 +9,75 @@
9
9
  "devDependencies": {
10
10
  "@babel/cli": "^7.0.0",
11
11
  "@babel/core": "^7.0.0",
12
- "@babel/plugin-transform-flow-strip-types": "^7.0.0",
13
12
  "@babel/plugin-transform-runtime": "^7.0.0",
13
+ "@babel/plugin-transform-typescript": "^7.8.7",
14
14
  "@babel/preset-env": "^7.0.0",
15
15
  "@babel/preset-react": "^7.0.0",
16
16
  "@babel/types": "^7.0.0",
17
+ "@types/jest": "^25.1.4",
18
+ "@types/node": "^13.9.0",
19
+ "@types/react": "^16.9.23",
20
+ "@types/react-dom": "^16.9.5",
21
+ "@types/turbolinks": "^5.2.0",
22
+ "@typescript-eslint/eslint-plugin": "^2.23.0",
23
+ "@typescript-eslint/parser": "^2.23.0",
17
24
  "babel-loader": "^8.0.2",
18
- "babel-tape-runner": "^3.0.0",
19
25
  "babelify": "^10.0.0",
20
26
  "blue-tape": "^1.0.0",
21
27
  "create-react-class": "^15.6.0",
22
- "eslint": "^5.7.0",
23
- "eslint-config-prettier": "^3.1.0",
28
+ "eslint": "^6.8.0",
29
+ "eslint-config-prettier": "^6.10.1",
24
30
  "eslint-config-shakacode": "^16.0.1",
25
31
  "eslint-plugin-import": "^2.6.1",
26
32
  "eslint-plugin-jsx-a11y": "^6.1.2",
27
33
  "eslint-plugin-prettier": "^3.0.0",
28
34
  "eslint-plugin-react": "^7.1.0",
29
- "flow-bin": "^0.83.0",
35
+ "jest": "^25.1.0",
30
36
  "jsdom": "^11.1.0",
31
37
  "nps": "^5.9.3",
32
- "prettier": "^1.14.3",
33
- "prettier-eslint-cli": "^4.7.1",
38
+ "prettier": "^2.0.1",
39
+ "prettier-eslint-cli": "^5.0.0",
34
40
  "prop-types": "^15.5.10",
35
41
  "react": "^16.5.2",
36
42
  "react-dom": "^16.5.2",
37
43
  "react-transform-hmr": "^1.0.4",
38
44
  "redux": "^4.0.1",
39
45
  "release-it": "^8.2.0",
40
- "tap-spec": "^5.0.0",
41
- "tape": "^4.7.0",
46
+ "ts-jest": "^25.2.1",
47
+ "tslint-config-prettier": "^1.18.0",
48
+ "typescript": "^3.8.3",
42
49
  "webpack": "^3.4.1",
43
50
  "webpack-manifest-plugin": "^1.2.1"
44
51
  },
45
52
  "dependencies": {
46
- "@babel/runtime-corejs2": "^7.0.0"
53
+ "@babel/runtime-corejs3": "^7.9.6",
54
+ "concurrently": "^5.1.0"
47
55
  },
48
56
  "peerDependencies": {
49
57
  "js-yaml": ">= 3.0.0",
50
- "react": ">= 0.14",
51
- "react-dom": ">= 0.14"
58
+ "react": ">= 16",
59
+ "react-dom": ">= 16"
52
60
  },
53
61
  "files": [
54
62
  "node_package/lib",
55
63
  "webpackConfigLoader.js"
56
64
  ],
57
65
  "scripts": {
58
- "test": "babel-tape-runner -r node_package/tests/helpers/test_helper.js node_package/tests/*.js | tap-spec",
66
+ "test": "jest node_package/tests",
59
67
  "clean": "rm -rf node_package/lib",
68
+ "start": "nps",
60
69
  "prepare": "yarn run build",
61
- "prepublish": "npm run prepare",
62
- "babel": "babel --out-dir node_package/lib node_package/src",
63
- "build": "yarn run clean && yarn run babel",
64
- "build-watch": "babel --watch --out-dir node_package/lib node_package/src",
65
- "eslint": "eslint .",
66
- "flow": "flow check node_package",
67
- "lint": "yarn run eslint && yarn run flow",
68
- "check": "yarn run lint && yarn run flow && yarn run test",
70
+ "build": "yarn run clean && yarn run tsc --declaration",
71
+ "build-watch": "yarn run clean && yarn run tsc --watch",
72
+ "lint": "nps eslint",
73
+ "check": "yarn run lint && yarn run test && yarn run type-check",
74
+ "type-check": "yarn run tsc --noEmit --noErrorTruncation",
69
75
  "prerelease": "yarn run check && yarn run clean && yarn run build",
70
76
  "release:patch": "node_package/scripts/release patch",
71
77
  "release:minor": "node_package/scripts/release minor",
72
78
  "release:major": "node_package/scripts/release major",
73
79
  "dummy:install": "rake dummy_apps",
74
- "dummy:spec": "rake run_rspec:dummy",
75
- "install-react-on-rails": "yarn link"
80
+ "dummy:spec": "rake run_rspec:dummy"
76
81
  },
77
82
  "repository": {
78
83
  "type": "git",
@@ -91,9 +96,5 @@
91
96
  "bugs": {
92
97
  "url": "https://github.com/shakacode/react_on_rails/issues"
93
98
  },
94
- "jest": {
95
- "verbose": true,
96
- "testURL": "http://localhost/"
97
- },
98
99
  "homepage": "https://github.com/shakacode/react_on_rails#readme"
99
100
  }
@@ -8,6 +8,7 @@ namespace :dummy_apps do
8
8
  task :yarn_install do
9
9
  yarn_install_cmd = "yarn install --mutex network"
10
10
  sh_in_dir(dummy_app_dir, yarn_install_cmd)
11
+ sh_in_dir(dummy_app_dir, "yalc link react-on-rails")
11
12
  end
12
13
 
13
14
  task dummy_app: [:yarn_install] do
@@ -15,15 +16,6 @@ namespace :dummy_apps do
15
16
  bundle_install_in(dummy_app_dir)
16
17
  end
17
18
 
18
- task :dummy_no_webpacker do
19
- npm_install_cmd = "npm install"
20
- install_react_on_rails_cmd = "yarn run install-react-on-rails"
21
- dummy_app_dir = File.join(gem_root, "spec/dummy_no_webpacker")
22
- sh_in_dir(File.join(gem_root, "spec/dummy_no_webpacker/client"), npm_install_cmd)
23
- sh_in_dir(dummy_app_dir, install_react_on_rails_cmd)
24
- sh_in_dir(dummy_app_dir, "BUNDLE_GEMFILE=Gemfile.rails32 bundle install")
25
- end
26
-
27
19
  task dummy_apps: %i[dummy_app node_package] do
28
20
  puts "Prepared all Dummy Apps"
29
21
  end
@@ -49,8 +49,10 @@ module ReactOnRails
49
49
  end
50
50
 
51
51
  # Options we pass when running `rails new` from the command-line.
52
+ attr_writer :rails_options
53
+
52
54
  def rails_options
53
- "--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record"
55
+ @rails_options ||= "--skip-bundle --skip-spring --skip-git --skip-test-unit --skip-active-record"
54
56
  end
55
57
 
56
58
  %w[gen clobber npm_install build_webpack_bundles].each do |task_type|