diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ebdf0feb..fbc0d8b22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,14 +15,9 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac ### [Unreleased] Changes since the last non-beta release. -#### Changed -- Bump minimum version of peer dependencies as following [PR 1596](https://github.com/shakacode/react_on_rails/pull/1596) by [ahangarha](https://github.com/ahangarha). - - `js-yaml` to `4.1.0` - - `react` and `react-dom` to `17.0.0` - #### Removed - Dropped Ruby 2.7 support [PR 1595](https://github.com/shakacode/react_on_rails/pull/1595) by [ahangarha](https://github.com/ahangarha). -- Dropped support for Node 14 and 17 [PR 1596](https://github.com/shakacode/react_on_rails/pull/1596) by [ahangarha](https://github.com/ahangarha). +- Removed deprecated `webpackConfigLoader.js` [PR 1600](https://github.com/shakacode/react_on_rails/pull/1600) by [ahangarha](https://github.com/ahangarha). ### [13.4.1] #### Fixed diff --git a/docs/javascript/troubleshooting-when-using-webpacker.md b/docs/javascript/troubleshooting-when-using-webpacker.md index 8c5026086..322c4778f 100644 --- a/docs/javascript/troubleshooting-when-using-webpacker.md +++ b/docs/javascript/troubleshooting-when-using-webpacker.md @@ -43,30 +43,7 @@ At the same time dev/prod environments works fine (with extra webpack calling st ### webpack.config.js -```js -... -const ManifestPlugin = require('webpack-manifest-plugin'); -... -const { output } = webpackConfigLoader(configPath); -... - output: { - filename: '[name]-[hash].js', - - // Leading and trailing slashes ARE necessary. - publicPath: output.publicPath, - path: output.path, - }, -... - plugins: [ - ... - new ManifestPlugin({ - publicPath: output.publicPath, - writeToFileEmit: true - }), - ... - ] -... -``` +See [Shakapcker Webpack Configuration](https://github.com/shakacode/shakapacker/blob/master/README.md#webpack-configuration). ### config/webpacker.yml diff --git a/package.json b/package.json index 399f139db..b2c501adb 100644 --- a/package.json +++ b/package.json @@ -50,13 +50,12 @@ "@babel/runtime-corejs3": "^7.12.5" }, "peerDependencies": { - "js-yaml": ">= 4.1.0", - "react": ">= 17", - "react-dom": ">= 17" + "js-yaml": ">= 3.0.0", + "react": ">= 16", + "react-dom": ">= 16" }, "files": [ - "node_package/lib", - "webpackConfigLoader.js" + "node_package/lib" ], "scripts": { "test": "jest node_package/tests", diff --git a/webpackConfigLoader.js b/webpackConfigLoader.js deleted file mode 100644 index f48f496f7..000000000 --- a/webpackConfigLoader.js +++ /dev/null @@ -1,71 +0,0 @@ -/** - * TODO: THIS SHOULD BE REMOVED - * - * Allow defaults for the config/webpacker.yml. Thee values in this file MUST match values - * in https://github.com/rails/webpacker/blob/master/lib/install/config/webpacker.yml - * - * NOTE: for HMR reloading, env.WEBPACKER_HMR value will override any config value. This env value - * should be set to TRUE to turn this on. - */ - -const { join, resolve } = require('path'); -const { env } = require('process'); -const { load } = require('js-yaml'); -const { readFileSync } = require('fs'); - -function removeOuterSlashes(string) { - return string.replace(/^\/*/, '').replace(/\/*$/, ''); -} - -function formatPublicPath(settings) { - if (settings.dev_server) { - const { host } = settings.dev_server; - const { port } = settings.dev_server; - const path = settings.public_output_path; - const hostWithHttp = `http://${host}:${port}`; - - let formattedHost = removeOuterSlashes(hostWithHttp); - if (formattedHost && !/^http/i.test(formattedHost)) { - formattedHost = `//${formattedHost}`; - } - const formattedPath = removeOuterSlashes(path); - return `${formattedHost}/${formattedPath}/`; - } - - const publicOuterPathWithoutOutsideSlashes = removeOuterSlashes(settings.public_output_path); - return `//${publicOuterPathWithoutOutsideSlashes}/`; -} - -/** - * @param configPath, location where webpacker.yml will be found - * Return values are consistent with Webpacker's js helpers - * For example, you might define: - * const isHMR = settings.dev_server && settings.dev_server.hmr - * @returns {{ - settings, - resolvedModules, - output: { path, publicPath, publicPathWithHost } - }} - */ -const configLoader = (configPath) => { - // Some test environments might not have the NODE_ENV set, so we'll have fallbacks. - const configEnv = env.NODE_ENV || env.RAILS_ENV || 'development'; - const ymlConfigPath = join(configPath, 'webpacker.yml'); - const settings = load(readFileSync(ymlConfigPath, 'utf8'))[configEnv]; - - // NOTE: Rails path is hard coded to `/public` - const output = { - // Next line differs from the webpacker definition as we use the configPath to create - // the relative path. - path: resolve(configPath, '..', 'public', settings.public_output_path), - publicPath: `/${settings.public_output_path}/`.replace(/([^:]\/)\/+/g, '$1'), - publicPathWithHost: formatPublicPath(settings), - }; - - return { - settings, - output, - }; -}; - -module.exports = configLoader;