💻
How are you using Babel?
jest
Input code
Issue when running jest with code coverage turned on. Works fine when run without code coverage.
npx jest --env=jsdom --collect-coverage --watchAll=false
Configuration file name
No response
Configuration
{
presets: ['@babel/react', ['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
ignore: ['**/__snapshots__', '**/*.d.ts', '**/*.test.*'],
plugins: [
'@babel/plugin-transform-typescript',
'babel-plugin-typescript-to-proptypes',
'@babel/plugin-proposal-export-default-from',
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
[
'module-resolver',
{
root: ['./src'],
extensions: ['.ts', '.tsx'],
resolvePath(sourcePath, currentFile, opts) {
if (sourcePath.includes('../assets/')) {
return `../${sourcePath}`;
}
return false;
}
}
]
]
}
Current and expected behavior
This issue only presents itself when updating from @babel/core from 7.22.15 to 7.22.17
SyntaxError: C:\_src\webinvest-frontend-hooks\node_modules\@babel\types\lib\index.js: 'return' outside of function. (4:51)
2 |
3 | if (typeof process === "object" && process.version === "v20.6.0") {
> 4 | if (exports["___internal__alreadyRunning" + ""]) return;
| ^
5 | Object.defineProperty(exports, "___internal__alreadyRunning", {
6 | value: true,
7 | enumerable: false,
1 | import React from 'react';
> 2 | import { toMatchDiffSnapshot } from 'snapshot-diff';
| ^
3 | import { configureStore } from '@reduxjs/toolkit';
4 | import { createFrontendStore, defaultFrontendStore, FRONTEND_STORE_NAME } from '@cmctechnology/webinvest-store-frontend';
5 | import { ACCOUNT_STORE_NAME, createAccountStore, defaultAccountStore } from '@cmctechnology/webinvest-store-accounts';
at constructor (node_modules/@babel/parser/src/parse-error.ts:81:19)
at Parser.toParseError [as raise] (node_modules/@babel/parser/src/tokenizer/index.ts:1487:19)
at Parser.raise [as parseReturnStatement] (node_modules/@babel/parser/src/parser/statement.ts:1055:12)
at Parser.parseReturnStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:478:21)
at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
at Parser.parseStatementLike [as parseStatementOrSloppyAnnexBFunctionDeclaration] (node_modules/@babel/parser/src/parser/statement.ts:386:17)
at Parser.parseStatementOrSloppyAnnexBFunctionDeclaration [as parseIfStatement] (node_modules/@babel/parser/src/parser/statement.ts:1046:28)
at Parser.parseIfStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:476:21)
at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
at Parser.parseStatementLike [as parseStatementListItem] (node_modules/@babel/parser/src/parser/statement.ts:366:17)
at Parser.parseStatementListItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1395:16)
at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1368:10)
at Parser.parseBlockBody [as parseBlock] (node_modules/@babel/parser/src/parser/statement.ts:1336:10)
at Parser.parseBlock [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:564:21)
at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
at Parser.parseStatementLike [as parseStatementOrSloppyAnnexBFunctionDeclaration] (node_modules/@babel/parser/src/parser/statement.ts:386:17)
at Parser.parseStatementOrSloppyAnnexBFunctionDeclaration [as parseIfStatement] (node_modules/@babel/parser/src/parser/statement.ts:1046:28)
at Parser.parseIfStatement [as parseStatementContent] (node_modules/@babel/parser/src/parser/statement.ts:476:21)
at Parser.parseStatementContent [as parseStatementLike] (node_modules/@babel/parser/src/parser/statement.ts:417:17)
at Parser.parseStatementLike [as parseModuleItem] (node_modules/@babel/parser/src/parser/statement.ts:354:17)
at Parser.parseModuleItem [as parseBlockOrModuleBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1394:16)
at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (node_modules/@babel/parser/src/parser/statement.ts:1368:10)
at Parser.parseBlockBody [as parseProgram] (node_modules/@babel/parser/src/parser/statement.ts:213:10)
at Parser.parseProgram [as parseTopLevel] (node_modules/@babel/parser/src/parser/statement.ts:195:25)
at Parser.parseTopLevel [as parse] (node_modules/@babel/parser/src/parser/index.ts:45:10)
at parse (node_modules/@babel/parser/src/index.ts:66:38)
at parser (node_modules/@babel/core/src/parser/index.ts:28:19)
at normalizeFile (node_modules/@babel/core/src/transformation/normalize-file.ts:51:24)
at normalizeFile.next (<anonymous>)
at run (node_modules/@babel/core/src/transformation/index.ts:39:36)
at run.next (<anonymous>)
at transform (node_modules/@babel/core/src/transform.ts:29:20)
at transform.next (<anonymous>)
at evaluateSync (node_modules/gensync/index.js:251:28)
at sync (node_modules/gensync/index.js:89:14)
at fn (node_modules/@babel/core/src/errors/rewrite-stack-trace.ts:99:14)
at transformSync (node_modules/@babel/core/src/transform.ts:66:52)
at ScriptTransformer._instrumentFile (node_modules/@jest/transform/build/ScriptTransformer.js:389:46)
at ScriptTransformer._buildTransformResult (node_modules/@jest/transform/build/ScriptTransformer.js:491:33)
at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:554:17)
at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:726:19)
at Object.require (node_modules/@babel/generator/src/node/whitespace.ts:1:1)
at Object.require (node_modules/@babel/generator/src/node/index.ts:1:1)
at Object.require (node_modules/@babel/generator/src/printer.ts:3:1)
at Object.require (node_modules/@babel/generator/src/index.ts:2:1)
at Object.<anonymous> (node_modules/snapshot-diff/build/index.js:6:18)
at Object.require (src/setupTests.tsx:2:1)
Environment
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 18.15.0 - C:\tmp\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 9.5.0 - C:\tmp\nodejs\npm.CMD
npmPackages:
@babel/cli: 7.22.15 => 7.22.15
@babel/core: 7.22.17 => 7.22.17
@babel/plugin-proposal-class-properties: 7.18.6 => 7.18.6
@babel/plugin-proposal-export-default-from: 7.22.5 => 7.22.5
@babel/plugin-proposal-object-rest-spread: ^7.20.7 => 7.20.7
@babel/plugin-transform-typescript: 7.22.15 => 7.22.15
@babel/preset-env: 7.22.15 => 7.22.15
@babel/preset-react: 7.22.15 => 7.22.15
@babel/preset-typescript: 7.22.15 => 7.22.15
babel-plugin-module-resolver: 5.0.0 => 5.0.0
babel-plugin-transform-es2015-modules-umd: 6.24.1 => 6.24.1
babel-plugin-typescript-to-proptypes: 2.1.0 => 2.1.0
eslint: 8.49.0 => 8.49.0
jest: 29.6.4 => 29.6.4
Possible solution
There is no function to return from in this file
node_modules\@babel\core\lib\index.js
"use strict";
if (typeof process === "object" && process.version === "v20.6.0") {
if (exports["___internal__alreadyRunning" + ""]) return; // <<<<<----- HERE is a return with no function outside
Object.defineProperty(exports, "___internal__alreadyRunning", {
value: true,
enumerable: false,
configurable: true
});
}
Object.defineProperty(exports, "__esModule", {
value: true
});
Additional context
No response
💻
How are you using Babel?
jest
Input code
Issue when running jest with code coverage turned on. Works fine when run without code coverage.
npx jest --env=jsdom --collect-coverage --watchAll=falseConfiguration file name
No response
Configuration
{ presets: ['@babel/react', ['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], ignore: ['**/__snapshots__', '**/*.d.ts', '**/*.test.*'], plugins: [ '@babel/plugin-transform-typescript', 'babel-plugin-typescript-to-proptypes', '@babel/plugin-proposal-export-default-from', '@babel/proposal-class-properties', '@babel/proposal-object-rest-spread', [ 'module-resolver', { root: ['./src'], extensions: ['.ts', '.tsx'], resolvePath(sourcePath, currentFile, opts) { if (sourcePath.includes('../assets/')) { return `../${sourcePath}`; } return false; } } ] ] }Current and expected behavior
This issue only presents itself when updating from @babel/core from 7.22.15 to 7.22.17
Environment
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 18.15.0 - C:\tmp\nodejs\node.EXE
Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 9.5.0 - C:\tmp\nodejs\npm.CMD
npmPackages:
@babel/cli: 7.22.15 => 7.22.15
@babel/core: 7.22.17 => 7.22.17
@babel/plugin-proposal-class-properties: 7.18.6 => 7.18.6
@babel/plugin-proposal-export-default-from: 7.22.5 => 7.22.5
@babel/plugin-proposal-object-rest-spread: ^7.20.7 => 7.20.7
@babel/plugin-transform-typescript: 7.22.15 => 7.22.15
@babel/preset-env: 7.22.15 => 7.22.15
@babel/preset-react: 7.22.15 => 7.22.15
@babel/preset-typescript: 7.22.15 => 7.22.15
babel-plugin-module-resolver: 5.0.0 => 5.0.0
babel-plugin-transform-es2015-modules-umd: 6.24.1 => 6.24.1
babel-plugin-typescript-to-proptypes: 2.1.0 => 2.1.0
eslint: 8.49.0 => 8.49.0
jest: 29.6.4 => 29.6.4
Possible solution
There is no function to return from in this file
node_modules\@babel\core\lib\index.jsAdditional context
No response