From deaffeb3d7ca91dd4e1873e53868592e65b518d6 Mon Sep 17 00:00:00 2001 From: Matthew O'Connell Date: Thu, 14 Sep 2023 18:31:37 +0200 Subject: [PATCH] fix(react-scripts@4.0.3): add .mjs file-type --- package.json | 36 +++++++++++---------- patches/react-scripts+4.0.3.patch | 52 +++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 patches/react-scripts+4.0.3.patch diff --git a/package.json b/package.json index a3b38ff5..2b37a82d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "contracts:deploy-factory": "yarn workspace @smart-invoice/contracts deploy-factory", "lint": "eslint --ignore-path .gitignore \"./packages/**/*.{ts,tsx,js,jsx}\"", "format": "prettier --ignore-path .gitignore --write \"{*,**/*}.{ts,tsx,js,jsx,json,md,sol}\"", - "prepare": "husky install" + "prepare": "husky install", + "postinstall": "patch-package" }, "workspaces": { "nohoist": [ @@ -46,23 +47,23 @@ "async-prompt": "^1.0.1", "babel-eslint": "^10.1.0", "dotenv": "^8.2.0", - "eslint": "^7.11.0", - "eslint-config-airbnb": "^18.2.0", - "eslint-config-prettier": "8.1.0", - "eslint-config-react-app": "^6.0.0", - "eslint-plugin-flowtype": "^5.6.0", - "eslint-plugin-import": "2.22.1", - "eslint-plugin-jsx-a11y": "^6.4.1", - "eslint-plugin-mocha": "^8.1.0", - "eslint-plugin-react": "7.23.1", - "eslint-plugin-react-hooks": "4.2.0", - "eslint-plugin-simple-import-sort": "7.0.0", + "eslint": "^8.49.0", + "eslint-config-airbnb": "^19.0.4", + "eslint-config-prettier": "9.0.0", + "eslint-config-react-app": "^7.0.1", + "eslint-plugin-flowtype": "^8.0.3", + "eslint-plugin-import": "2.28.1", + "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-mocha": "^10.1.0", + "eslint-plugin-react": "7.33.2", + "eslint-plugin-react-hooks": "4.6.0", + "eslint-plugin-simple-import-sort": "10.0.0", "ethers": "^5.1.0", "husky": "^6.0.0", "it-all": "^1.0.2", - "lint-staged": "^10.3.0", - "prettier": "^2.1.1", - "prettier-plugin-solidity": "^1.0.0-beta.10" + "lint-staged": "^14.0.1", + "prettier": "^3.0.3", + "prettier-plugin-solidity": "^1.1.3" }, "lint-staged": { "*.{ts,tsx,js,jsx}": [ @@ -74,7 +75,8 @@ ] }, "dependencies": { - "@typescript-eslint/parser": "^5.27.0", - "typescript": "^4.7.2" + "@typescript-eslint/parser": "^6.7.0", + "patch-package": "^8.0.0", + "typescript": "^4.9.5" } } diff --git a/patches/react-scripts+4.0.3.patch b/patches/react-scripts+4.0.3.patch new file mode 100644 index 00000000..7df4887f --- /dev/null +++ b/patches/react-scripts+4.0.3.patch @@ -0,0 +1,52 @@ +diff --git a/node_modules/react-scripts/config/paths.js b/node_modules/react-scripts/config/paths.js +index 67ba927..ab7da87 100644 +--- a/node_modules/react-scripts/config/paths.js ++++ b/node_modules/react-scripts/config/paths.js +@@ -34,6 +34,7 @@ const buildPath = process.env.BUILD_PATH || 'build'; + const moduleFileExtensions = [ + 'web.mjs', + 'mjs', ++ 'cjs', + 'web.js', + 'js', + 'web.ts', +diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js +index 26c2a65..b541923 100644 +--- a/node_modules/react-scripts/config/webpack.config.js ++++ b/node_modules/react-scripts/config/webpack.config.js +@@ -402,7 +402,7 @@ module.exports = function (webpackEnv) { + // Process application JS with Babel. + // The preset includes JSX, Flow, TypeScript, and some ESnext features. + { +- test: /\.(js|mjs|jsx|ts|tsx)$/, ++ test: /\.(js|mjs|jsx|cjs|ts|tsx)$/, + include: paths.appSrc, + loader: require.resolve('babel-loader'), + options: { +@@ -465,7 +465,7 @@ module.exports = function (webpackEnv) { + // Process any JS outside of the app with Babel. + // Unlike the application JS, we only compile the standard ES features. + { +- test: /\.(js|mjs)$/, ++ test: /\.(js|mjs|cjs)$/, + exclude: /@babel(?:\/|\\{1,2})runtime/, + loader: require.resolve('babel-loader'), + options: { +@@ -586,7 +586,7 @@ module.exports = function (webpackEnv) { + // its runtime that would otherwise be processed through "file" loader. + // Also exclude `html` and `json` extensions so they get processed + // by webpacks internal loaders. +- exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], ++ exclude: [/\.(js|mjs|jsx|cjs|ts|tsx)$/, /\.html$/, /\.json$/], + options: { + name: 'static/media/[name].[hash:8].[ext]', + }, +@@ -756,7 +756,7 @@ module.exports = function (webpackEnv) { + !disableESLintPlugin && + new ESLintPlugin({ + // Plugin options +- extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'], ++ extensions: ['js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx'], + formatter: require.resolve('react-dev-utils/eslintFormatter'), + eslintPath: require.resolve('eslint'), + failOnError: !(isEnvDevelopment && emitErrorsAsWarnings), \ No newline at end of file