Skip to content

Commit

Permalink
fix(react-scripts@4.0.3): add .mjs file-type
Browse files Browse the repository at this point in the history
  • Loading branch information
moconnell committed Sep 14, 2023
1 parent 5be995c commit deaffeb
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 17 deletions.
36 changes: 19 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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}": [
Expand All @@ -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"
}
}
52 changes: 52 additions & 0 deletions patches/react-scripts+4.0.3.patch
Original file line number Diff line number Diff line change
@@ -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),

0 comments on commit deaffeb

Please # to comment.