Skip to content

Commit bd91283

Browse files
[babel-preset-jest] Allow Babel 8 as a peer dep
1 parent 953be97 commit bd91283

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

packages/babel-preset-jest/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
const jestPreset = {
9-
plugins: [require.resolve('babel-plugin-jest-hoist')],
10-
presets: [require.resolve('babel-preset-current-node-syntax')],
11-
};
8+
const jestHoist = require.resolve('babel-plugin-jest-hoist');
9+
const currentNodeSyntax = require.resolve('babel-preset-current-node-syntax');
1210

13-
// @babel/core requires us to export a function
14-
const jestPresetPlugin = () => jestPreset;
15-
module.exports = jestPresetPlugin;
11+
module.exports = api => {
12+
if (api.version && api.version.startsWith('8.')) {
13+
return {plugins: [jestHoist]};
14+
}
15+
return {plugins: [jestHoist], presets: [currentNodeSyntax]};
16+
};

packages/babel-preset-jest/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
},
1515
"dependencies": {
1616
"babel-plugin-jest-hoist": "workspace:*",
17-
"babel-preset-current-node-syntax": "^1.1.0"
17+
"babel-preset-current-node-syntax": "^1.1.1"
1818
},
1919
"peerDependencies": {
20-
"@babel/core": "^7.11.0"
20+
"@babel/core": "^7.11.0 || ^8.0.0-beta.1"
2121
},
2222
"engines": {
2323
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"

yarn.lock

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8202,14 +8202,39 @@ __metadata:
82028202
languageName: node
82038203
linkType: hard
82048204

8205+
"babel-preset-current-node-syntax@npm:^1.1.1":
8206+
version: 1.1.1
8207+
resolution: "babel-preset-current-node-syntax@npm:1.1.1"
8208+
dependencies:
8209+
"@babel/plugin-syntax-async-generators": "npm:^7.8.4"
8210+
"@babel/plugin-syntax-bigint": "npm:^7.8.3"
8211+
"@babel/plugin-syntax-class-properties": "npm:^7.12.13"
8212+
"@babel/plugin-syntax-class-static-block": "npm:^7.14.5"
8213+
"@babel/plugin-syntax-import-attributes": "npm:^7.24.7"
8214+
"@babel/plugin-syntax-import-meta": "npm:^7.10.4"
8215+
"@babel/plugin-syntax-json-strings": "npm:^7.8.3"
8216+
"@babel/plugin-syntax-logical-assignment-operators": "npm:^7.10.4"
8217+
"@babel/plugin-syntax-nullish-coalescing-operator": "npm:^7.8.3"
8218+
"@babel/plugin-syntax-numeric-separator": "npm:^7.10.4"
8219+
"@babel/plugin-syntax-object-rest-spread": "npm:^7.8.3"
8220+
"@babel/plugin-syntax-optional-catch-binding": "npm:^7.8.3"
8221+
"@babel/plugin-syntax-optional-chaining": "npm:^7.8.3"
8222+
"@babel/plugin-syntax-private-property-in-object": "npm:^7.14.5"
8223+
"@babel/plugin-syntax-top-level-await": "npm:^7.14.5"
8224+
peerDependencies:
8225+
"@babel/core": ^7.0.0 || ^8.0.0-0
8226+
checksum: 10/4f8a4ee7e8d2f3848a9c67c3d30432be72c0baae7360c43f5f5511edbb745b3fcdec08aa874af53a39f2ffcac822a39473aed06091f044cf58ed9a358b5972b2
8227+
languageName: node
8228+
linkType: hard
8229+
82058230
"babel-preset-jest@workspace:*, babel-preset-jest@workspace:packages/babel-preset-jest":
82068231
version: 0.0.0-use.local
82078232
resolution: "babel-preset-jest@workspace:packages/babel-preset-jest"
82088233
dependencies:
82098234
babel-plugin-jest-hoist: "workspace:*"
8210-
babel-preset-current-node-syntax: "npm:^1.1.0"
8235+
babel-preset-current-node-syntax: "npm:^1.1.1"
82118236
peerDependencies:
8212-
"@babel/core": ^7.11.0
8237+
"@babel/core": ^7.11.0 || ^8.0.0-beta.1
82138238
languageName: unknown
82148239
linkType: soft
82158240

0 commit comments

Comments
 (0)