Skip to content

Commit d68c010

Browse files
committed
support react-scripts 5
1 parent c8ecc5a commit d68c010

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ you can find more detail in [this file][css-patch]
221221
| 2.1.2 | 0.1.4 |
222222
| 3.0.0 | 0.2.0 |
223223
| 4.0.0 | 0.3.0 |
224+
| 5.0.0 | 5.0.0-0 |
224225

225226
## Thanks
226227

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"monkey-react-scripts": "./bin/monkey-react-scripts.js"
1515
},
1616
"peerDependencies": {
17-
"react-scripts": ">=2.0.0"
17+
"react-scripts": ">=5.0.0"
1818
}
1919
}

Diff for: scripts/test.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const webpackMonkeyPath = path.resolve(appPath, 'webpack.monkey.js');
1616
require('react-scripts/config/jest/babelTransform.js')
1717

1818
if (fs.existsSync(webpackMonkeyPath)) {
19-
console.log(chalk.yellow('WARNING! .babelrc file is enabled!'));
20-
const babelJest = require('babel-jest');
19+
console.log(chalk.yellow('WARNING! .babelrc file is enabled!'));
20+
const babelJest = require('babel-jest').default;
2121

2222
const hasJsxRuntime = (() => {
2323
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
@@ -32,16 +32,20 @@ if (fs.existsSync(webpackMonkeyPath)) {
3232
}
3333
})();
3434

35-
patchModule('react-scripts/config/jest/babelTransform.js', babelJest.createTransformer({
36-
presets: [
37-
require.resolve('babel-preset-react-app'),
38-
{
39-
runtime: hasJsxRuntime ? 'automatic' : 'classic',
40-
},
41-
],
42-
babelrc: true,
43-
configFile: false,
44-
}));
35+
const babelTransform = babelJest.createTransformer({
36+
presets: [
37+
[
38+
require.resolve('babel-preset-react-app'),
39+
{
40+
runtime: hasJsxRuntime ? 'automatic' : 'classic',
41+
},
42+
],
43+
],
44+
babelrc: true,
45+
configFile: false,
46+
});
47+
48+
patchModule('react-scripts/config/jest/babelTransform.js', babelTransform);
4549
}
4650

4751
require('react-scripts/scripts/test');

0 commit comments

Comments
 (0)