babel: [Bug]: React Native bundling error on new @babel/core@7.18.5
💻
- Would you like to work on a fix?
How are you using Babel?
@babel/register or @babel/node
Input code
I had to downgrade to 7.18.2 from 7.18.5 with React Native bundling in IOS and Android.
Task :app:bundleDebugJsAndAssets FAILED
Error: /Users/bill/theclub/TheClub/src/app-context/SmoochContext.tsx: Couldn't find a Program
at Scope.getProgramParent (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/scope/index.js:899:11)
at Scope.crawl (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/scope/index.js:802:32)
at Scope.init (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/scope/index.js:791:12)
at NodePath.setScope (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/path/context.js:146:30)
at NodePath.setContext (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/path/context.js:162:8)
at NodePath.popContext (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/path/context.js:222:10)
at TraversalContext.visitQueue (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/context.js:117:12)
at TraversalContext.visitMultiple (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/context.js:72:17)
at TraversalContext.visit (/Users/bill/theclub/TheClub/node_modules/@babel/traverse/lib/context.js:129:19)
info Run CLI with --verbose flag for more details.
Not much info.
Import looks like:
import SmoochContext from ‘…/…/…/…/app-context/SmoochContext’;
Configuration file name
babel.config.json
Configuration
module.exports = {
presets: ['module:metro-react-native-babel-preset', '@babel/preset-typescript'],
plugins: [
[
'react-native-reanimated/plugin',
],
[
'module-resolver',
{
"root": [
"./src"
],
alias: {
"^~(.+)$": "./src/\\1",
tests: ['./tests/'],
},
extensions: ['.ios.js', '.android.js', '.js', '.jsx', '.ts', '.tsx', '.json'],
},
],
],
};
Current and expected behavior
Should not error on build.
Environment
Node 16.
“react-native”: “^0.68.2”,
System:
OS: macOS 12.4
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.18 - /usr/local/bin/yarn
npm: 8.5.0 - /usr/local/bin/npm
npmPackages:
@babel/core: 7.18.2 => 7.18.2
@babel/eslint-parser: ^7.18.2 => 7.18.2
@babel/preset-typescript: ^7.17.12 => 7.17.12
@babel/runtime: ^7.18.3 => 7.18.3
babel-jest: ^28.1.1 => 28.1.1
babel-plugin-module-resolver: ^4.1.0 => 4.1.0
eslint: ^8.17.0 => 8.17.0
jest: ^28.1.1 => 28.1.1
metro-react-native-babel-preset: 0.71.0 => 0.71.0
react-native: ^0.68.2 => 0.68.2 ```
### Possible solution
Downgrade.
### Additional context
No idea.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (6 by maintainers)
I couldn’t reproduce this issue on REPL, which means it may be an integration issue between Babel presets and third-party plugins. Can you provide a minimal reproduction repo?