From 1ae2564d6fcc568a09beab099965e1f76f6231ed Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Tue, 23 Aug 2022 17:38:10 +0300 Subject: [PATCH 1/4] GENERATE_SOURCEMAP=false caused an error since it affected to the structure of webpack.config.js --- .../config/sharetribeWebpackConfig.js | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/config/sharetribeWebpackConfig.js b/packages/react-scripts/config/sharetribeWebpackConfig.js index 10188948b82..c2c2d6c1160 100644 --- a/packages/react-scripts/config/sharetribeWebpackConfig.js +++ b/packages/react-scripts/config/sharetribeWebpackConfig.js @@ -45,25 +45,21 @@ const postcssOptionsPlugins = [ const checkConfigStructure = config => { // First validate the structure of the config to ensure that we mutate // the config with the correct assumptions. - const hasRules = - config && - config.module && - config.module.rules && - config.module.rules.length === 2; - const hasOneOf = + const hasRules = config?.module?.rules?.length > 0; + const foundRuleWithOneOfArray = hasRules && - config.module.rules[1].oneOf && - config.module.rules[1].oneOf.length === 10; + config.module.rules.find(rule => rule.oneOf?.length === 10); + const hasCssLoader = - hasOneOf && - config.module.rules[1].oneOf[5].test && - config.module.rules[1].oneOf[5].test.test('file.css'); + foundRuleWithOneOfArray && + foundRuleWithOneOfArray.oneOf[5].test && + foundRuleWithOneOfArray.oneOf[5].test.test('file.css'); const hasPlugins = !!config.plugins; const hasOutput = !!config.output; const hasOptimization = !!config.optimization; const configStructureKnown = hasRules - && hasOneOf + && foundRuleWithOneOfArray && hasCssLoader && hasPlugins && hasOutput From 370a8248947f66fc512f4afeca50f979886b38b4 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Tue, 23 Aug 2022 17:39:55 +0300 Subject: [PATCH 2/4] splitChunks was reintroduced prematurely. CRA 5 is discussing to reintroduce it, but the previous (CRA4) style does not work with 'async' marked thunk functions. https://github.com/sharetribe/ftw-daily/issues/1545 We decided to follow CRA's releases instead of branch out wiht own experiments. --- packages/react-scripts/config/webpack.config.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 0d64ce1c943..f47b598bbd9 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -252,14 +252,6 @@ module.exports = function(webpackEnv, target = 'web') { level: 'none', }, optimization: { - // Sharetribe custom: create vendor chunk - // CRA v5, removed this splitChunks feature, but they are planning to reintroduce it. - // https://github.com/facebook/create-react-app/pull/11763 - splitChunks: isEnvDevelopment - ? undefined - : { - chunks: 'all', - }, minimize: isEnvProduction, minimizer: [ // This is only used in production mode From ed5a752294b0192ff25ca1cb4f4eac12f7d13a16 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Tue, 23 Aug 2022 17:43:43 +0300 Subject: [PATCH 3/4] Update version in package.json --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 72a2531d450..aa266d58488 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "sharetribe-scripts", - "version": "6.0.0", + "version": "6.0.1", "description": "Fork of facebookincubator/create-react-app@5.0.1 with some additional features. This is a major version update to CRA", "repository": { "type": "git", From 7583f494f7077f74de62c69b8fda90c3aaf0b663 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Mon, 29 Aug 2022 13:48:53 +0300 Subject: [PATCH 4/4] Add instructions how to use Verdaccio --- packages/react-scripts/README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/react-scripts/README.md b/packages/react-scripts/README.md index a1a883eef0f..1a693298dbd 100644 --- a/packages/react-scripts/README.md +++ b/packages/react-scripts/README.md @@ -60,6 +60,35 @@ To update the fork to use a new version of the upstream repository: To test your local changes, use [Verdaccio](https://verdaccio.org/en/) or link the local repository to the application: +#### Verdaccio + +1. Run Verdaccio locally (http://localhost:4873/) and create user there + +1. Make changes to this repo and update version in the package.json of this react-scripts dir + The version could be something like "6.0.0-alpha" + +1. Publish your changes to the local registry + + ``` + npm publish --registry http://localhost:4873/ + ``` + +1. Go to FTW repo and add .yarnrc file with content: + + ``` + registry "http://localhost:4873" + ``` + +1. Modify FTW template's package.json + + ``` + "sharetribe-scripts": "6.0.0-alpha", + ``` + + Then run `yarn install` + +#### Linking + 1. In the `create-react-app/packages/react-scripts` directory, install dependencies and make a link of the package: