react_on_rails 9.0.0.beta.6 → 9.0.0.beta.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87401aa3f78e7c02c43df0ba13f2befc6c0d6f7a
4
- data.tar.gz: 6fee72ba5bdab701ae4c270ebd2622b2c20005e3
3
+ metadata.gz: 55bfe083238d38b5106cdc776bf9f96ec6a93b5c
4
+ data.tar.gz: '03907dec757d9ac37df327e9f002d56a3f529fe2'
5
5
  SHA512:
6
- metadata.gz: 43b5ea95a1424cac2a0537bd727158e7903a59174438335bcdfe29a0d744f9f9e1faab21397bb0787b6da6a978d061f81fd98d1718447824b12324262d0d9bdd
7
- data.tar.gz: 6429193a7bd2741c5d0a7ea26d00e3dd6dad7a4c64d84e497a0e5f89fda1f5af301b7d576b308b3b1f2b9174c4c298639c251d216ad66bc9d8a1ea2d1f77f234
6
+ metadata.gz: e1d670a7c73bc79180efbfef68012e0e5119b29d0e2cdf53a6ce0e3101299b0d2b471d997e85b1b3b826069105bd5ac8a0574732d3c808ef52f2a7620a02a973
7
+ data.tar.gz: 2b75e5a43ca5b0294751f43c087429fb49bf69c8d76b55c7c8b2ee8108f99d4b6139e0212919a696b630bb070ba9676d403a544db9147f4254ac9d4deb724797
data/CHANGELOG.md CHANGED
@@ -18,23 +18,47 @@ All 9.0.0 beta versions can be viewed in [PR 908](https://github.com/shakacode/r
18
18
 
19
19
  ```rb
20
20
  gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
21
- branch: "issue-464-merge-webpacker-lite-into-webpacker"
21
+ branch: "issue-464-merge-webpacker-lite-into-webpacker-v2"
22
22
  ```
23
23
 
24
24
  - Update for the renaming in the `WebpackConfigLoader` in your webpack configuration.
25
25
  You will need to rename the following object properties:
26
- - hotReloadingUrl ==> devServerUrl
27
- - hotReloadingHostname ==> devServerHost
28
- - hotReloadingPort ==> devServerPort
26
+ - webpackOutputPath ==> output.path
27
+ - webpackPublicOutputDir ==> output.publicPath
28
+ - hotReloadingUrl ==> output.publicPathWithHost
29
+ - hotReloadingHostname ==> settings.dev_server.host
30
+ - hotReloadingPort ==> settings.dev_server.port
31
+ - hmr ==> settings.dev_server.hmr
32
+ - manifest ==> Remove this one. We use the default for Webpack of manifest.json
33
+ - env ==> Use `const { env } = require('process');
34
+ - devBuild ==> Use `const devBuild = process.env.NODE_ENV !== 'production';
35
+
36
+ - Edit your Webpack.config files:
37
+ - Change your Webpack output to be like:
38
+ ```
39
+ // Leading slash is necessary
40
+ publicPath: `/${output.publicPath}`,
41
+ path: output.path,
42
+ ```
43
+ - Change your ManifestPlugin definition to include publicPath
44
+ ```
45
+ output: {
46
+ // Name comes from the entry section.
47
+ filename: '[name]-[chunkhash].js',
48
+
49
+ publicPath: output.publicPath,
50
+ path: output.path,
51
+ },
52
+
53
+ ```
54
+
29
55
 
30
56
  - Find your `webpacker_lite.yml` and rename it to `webpacker.yml`
31
57
  - Add a section like this under your development env:
32
58
  ```
33
59
  dev_server:
34
60
  host: localhost
35
- port: 8080
36
- https: false
37
- # Can be enabled by export WEBPACKER_HMR=TRUE in env
61
+ port: 3035
38
62
  hmr: false
39
63
  ```
40
64
  - See the example `spec/dummy/config/webpacker.yml`.
@@ -61,6 +85,19 @@ deploying assets using the webpack-dev-server.
61
85
  ### [9.0.0]
62
86
  *Diffs for the beta to master*
63
87
 
88
+ ### [9.0.0-beta.7]
89
+ - Depend on updated rails/webpacker in branch
90
+
91
+ gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
92
+ branch: "issue-464-merge-webpacker-lite-into-webpacker-v2"
93
+
94
+
95
+ ### [9.0.0-beta.6]
96
+ - Change "hot" to "hmr".
97
+
98
+ ### [9.0.0-beta.3]
99
+ - Fix typo on webpackConfigLoader.js
100
+
64
101
  ### [9.0.0-beta.3]
65
102
  - Fix typo on webpackConfigLoader.js
66
103
 
@@ -688,8 +725,12 @@ Best done with Object destructing:
688
725
  ##### Fixed
689
726
  - Fix several generator related issues.
690
727
 
691
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/rails-webpacker...9.0.0-beta.3
692
- [9.0.0]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.3...master
728
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/rails-webpacker...9.0.0-beta.7
729
+ [9.0.0]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.7...master
730
+ [9.0.0-beta.7]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.7...9.0.0-beta.6
731
+ [9.0.0-beta.6]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.6...9.0.0-beta.5
732
+ [9.0.0-beta.5]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.5...9.0.0-beta.4
733
+ [9.0.0-beta.4]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.4...9.0.0-beta.3
693
734
  [9.0.0-beta.3]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.3...9.0.0-beta.2
694
735
  [9.0.0-beta.2]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.2...9.0.0-beta.1
695
736
  [9.0.0-beta.1]: https://github.com/shakacode/react_on_rails/compare/9.0.0-beta.1...master
data/Gemfile CHANGED
@@ -39,6 +39,9 @@ gem "launchy"
39
39
  gem "poltergeist"
40
40
  gem "selenium-webdriver"
41
41
  gem "webpacker", git: "https://github.com/shakacode/webpacker.git",
42
- branch: "issue-464-merge-webpacker-lite-into-webpacker"
42
+ branch: "issue-464-merge-webpacker-lite-into-webpacker-v2"
43
+
44
+ # TODO: remove once we get out of beta.
45
+ # gem 'webpacker', path: "../../forks/webpacker"
43
46
 
44
47
  gem "rainbow"
@@ -75,7 +75,7 @@ module ReactOnRails
75
75
 
76
76
  gem 'mini_racer', platforms: :ruby
77
77
  gem 'webpacker', git: "https://github.com/shakacode/webpacker.git",
78
- branch: "issue-464-merge-webpacker-lite-into-webpacker"
78
+ branch: "issue-464-merge-webpacker-lite-into-webpacker-v2"
79
79
  GEMS
80
80
  append_to_file("Gemfile",
81
81
  gems)
@@ -9,8 +9,7 @@ const ManifestPlugin = require('webpack-manifest-plugin');
9
9
  const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
10
10
 
11
11
  const configPath = resolve('..', 'config');
12
- const { devBuild, manifest, webpackOutputPath, webpackPublicOutputDir } =
13
- webpackConfigLoader(configPath);
12
+ const { devBuild, output } = webpackConfigLoader(configPath);
14
13
 
15
14
  const config = {
16
15
 
@@ -27,11 +26,11 @@ const config = {
27
26
 
28
27
  output: {
29
28
  // Name comes from the entry section.
30
- filename: '[name]-[hash].js',
29
+ filename: '[name]-[chunkhash].js',
31
30
 
32
31
  // Leading slash is necessary
33
- publicPath: `/${webpackPublicOutputDir}`,
34
- path: webpackOutputPath,
32
+ publicPath: `/${output.publicPath}`,
33
+ path: output.path,
35
34
  },
36
35
 
37
36
  resolve: {
@@ -43,7 +42,9 @@ const config = {
43
42
  NODE_ENV: 'development', // use 'development' unless process.env.NODE_ENV is defined
44
43
  DEBUG: false,
45
44
  }),
46
- new ManifestPlugin({ fileName: manifest, writeToFileEmit: true }),
45
+ new ManifestPlugin({
46
+ publicPath: output.publicPath,
47
+ writeToFileEmit: true }),
47
48
  ],
48
49
 
49
50
  module: {
@@ -11,9 +11,7 @@ development:
11
11
  # Temporarily disabling live-reloading until the server script is added.
12
12
  # dev_server:
13
13
  # host: localhost
14
- # port: 8080
15
- # https: false
16
- # # Can be enabled by export WEBPACKER_HMR=TRUE in env
14
+ # port: 3035
17
15
  # hmr: false
18
16
 
19
17
  test:
@@ -62,22 +62,31 @@ exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
62
62
  end
63
63
 
64
64
  def self.server_bundle_js_file_path
65
- # Don't ever use the hashed file name?
66
- # Cases:
67
- # 1. Using same bundle for both server and client, so server bundle will be hashed
68
- # 2. Using a different bundle (different Webpack config), so file is not hashed
69
- bundle_js_file_path(ReactOnRails.configuration.server_bundle_js_file)
65
+ # Either:
66
+ # 1. Using same bundle for both server and client, so server bundle will be hashed in manifest
67
+ # 2. Using a different bundle (different Webpack config), so file is not hashed, and
68
+ # bundle_js_path will throw.
69
+ # 3. Not using webpacker, and bundle_js_path always returns
70
+
71
+ # Note, server bundle should not be in the manifest
72
+ # If using webpacker gem per https://github.com/rails/webpacker/issues/571
73
+ return @server_bundle_path if @server_bundle_path && !Rails.env.development?
74
+
75
+ bundle_name = ReactOnRails.configuration.server_bundle_js_file
76
+ @server_bundle_path = begin
77
+ bundle_js_file_path(bundle_name)
78
+ rescue Webpacker::Manifest::MissingEntryError
79
+ Rails.root.join(File.join(Webpacker.config.public_output_path, bundle_name)).to_s
80
+ end
70
81
  end
71
82
 
72
83
  def self.bundle_js_file_path(bundle_name)
73
84
  if using_webpacker?
74
- # Note, server bundle should not be in the manifest
75
- # If using webpacker gem per https://github.com/rails/webpacker/issues/571
76
- hashed_name = Webpacker::Manifest.lookup(bundle_name, throw_if_missing: false)
77
- hashed_name = bundle_name if hashed_name.blank?
78
- Rails.root.join(File.join(Webpacker::Configuration.output_path, hashed_name)).to_s
85
+ # Next line will throw if the file or manifest does not exist
86
+ Webpacker.manifest.lookup(bundle_name)
79
87
  else
80
- # Else either the file is not in the manifest, so we'll default to the non-hashed name.
88
+ # Default to the non-hashed name in the specified output directory, which, for legacy
89
+ # React on Rails, this is the output directory picked up by the asset pipeline.
81
90
  File.join(ReactOnRails.configuration.generated_assets_dir, bundle_name)
82
91
  end
83
92
  end
@@ -107,7 +116,7 @@ exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
107
116
  end
108
117
 
109
118
  def self.manifest_exists?
110
- Webpacker::Configuration.manifest_path.exist?
119
+ Webpacker.config.public_manifest_path.exist?
111
120
  end
112
121
 
113
122
  module Required
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "9.0.0.beta.6"
4
+ VERSION = "9.0.0.beta.7"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "9.0.0-beta.6",
3
+ "version": "9.0.0-beta.7",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
@@ -5,70 +5,53 @@
5
5
  * NOTE: for HMR reloading, env.WEBPACKER_HMR value will override any config value. This env value
6
6
  * should be set to TRUE to turn this on.
7
7
  */
8
+
8
9
  const { join, resolve } = require('path');
10
+ const { env } = require('process');
9
11
  const { safeLoad } = require('js-yaml');
10
12
  const { readFileSync } = require('fs');
11
13
 
12
- const MANIFEST = 'manifest.json';
13
- const DEFAULT_PUBLIC_OUTPUT_PATH = 'packs';
14
- const DEFAULT_DEV_SERVER_HOST = 'localhost';
15
- const DEFAULT_DEV_SERVER_PORT = '8080';
16
- const DEFAULT_DEV_SERVER_HTTPS = false;
17
- const DEFAULT_DEV_SERVER_HMR = false;
14
+
15
+ function removeOuterSlashes(string) {
16
+ return string.replace(/^\/*/, '').replace(/\/*$/, '');
17
+ }
18
+
19
+ function formatPublicPath(host = '', path = '') {
20
+ let formattedHost = removeOuterSlashes(host);
21
+ if (formattedHost && !/^http/i.test(formattedHost)) {
22
+ formattedHost = `//${formattedHost}`;
23
+ }
24
+ const formattedPath = removeOuterSlashes(path);
25
+ return `${formattedHost}/${formattedPath}/`;
26
+ }
18
27
 
19
28
  /**
20
29
  * @param configPath, location where webpacker.yml will be found
30
+ * Return values are consistent with Webpacker's js helpers
21
31
  * @returns {{
22
- * devBuild,
23
- * hmrReloadingEnabled,
24
- * devServerEnabled,
25
- * devServerHost,
26
- * devServerPort,
27
- * devServerUrl,
28
- * manifest,
29
- * webpackOutputPath,
30
- * webpackPublicOutputDir
31
- * }}
32
+ settings,
33
+ resolvedModules,
34
+ output: { path, publicPath, publicPathWithHosts }
35
+ }}
32
36
  */
33
37
  const configLoader = (configPath) => {
34
- const env = process.env;
35
-
36
38
  // Some test environments might not have the NODE_ENV set, so we'll have fallbacks.
37
39
  const configEnv = (process.env.NODE_ENV || process.env.RAILS_ENV || 'development');
38
40
  const ymlConfigPath = join(configPath, 'webpacker.yml');
39
- const configuration = safeLoad(readFileSync(ymlConfigPath, 'utf8'))[configEnv];
40
- const devServerValues = configuration.dev_server;
41
- const devBuild = configEnv !== 'production';
42
- const devServerHost = devServerValues && (devServerValues.host || DEFAULT_DEV_SERVER_HOST);
43
- const devServerPort = devServerValues && (devServerValues.port || DEFAULT_DEV_SERVER_PORT);
44
- const devServerHttps = devServerValues && (devServerValues.https || DEFAULT_DEV_SERVER_HTTPS);
45
- const devServerHmr = devServerValues && (devServerValues.hmr || DEFAULT_DEV_SERVER_HMR);
41
+ const settings = safeLoad(readFileSync(ymlConfigPath, 'utf8'))[configEnv];
46
42
 
47
43
  // NOTE: Rails path is hard coded to `/public`
48
- const webpackPublicOutputDir = configuration.public_output_path ||
49
- DEFAULT_PUBLIC_OUTPUT_PATH;
50
- const webpackOutputPath = resolve(configPath, '..', 'public', webpackPublicOutputDir);
51
-
52
- const manifest = MANIFEST;
53
-
54
- const devServerEnabled = !!devServerValues;
55
- const hmrReloadingEnabled = !!devServerHmr || env.WEBPACKER_HMR === 'TRUE';
56
-
57
- let devServerUrl = null;
58
- if (devServerValues) {
59
- devServerUrl = `http${devServerHttps ? 's' : ''}://${devServerHost}:${devServerPort}`;
60
- }
44
+ const output = {
45
+ // Next line differs from the webpacker definition as we use the configPath to create
46
+ // the relative path.
47
+ path: resolve(configPath, '..', 'public', settings.public_output_path),
48
+ publicPath: `/${settings.public_output_path}/`.replace(/([^:]\/)\/+/g, '$1'),
49
+ publicPathWithHost: formatPublicPath(env.ASSET_HOST, settings.public_output_path),
50
+ };
61
51
 
62
52
  return {
63
- devBuild,
64
- hmrReloadingEnabled,
65
- devServerEnabled,
66
- devServerHost,
67
- devServerPort,
68
- devServerUrl,
69
- manifest,
70
- webpackOutputPath,
71
- webpackPublicOutputDir,
53
+ settings,
54
+ output,
72
55
  };
73
56
  };
74
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.0.beta.6
4
+ version: 9.0.0.beta.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-11 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow