-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.57.0-rc.4] Running local-cli commands fails with "regeneratorRuntime is not defined" when using babel.config.js #21052
Comments
I had the same problem before. |
Awesome ! Thanks. |
Not work for me {
"presets": [
[
"@babel/env",
{
"modules": false,
"targets": {
"browsers": [
">0.25%",
"not ie 11",
"not op_mini all"
]
}
}
]
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-export-namespace-from",
"@babel/proposal-function-sent",
"@babel/proposal-json-strings",
"@babel/proposal-numeric-separator",
"@babel/proposal-throw-expressions",
"@babel/syntax-dynamic-import",
"@babel/syntax-import-meta",
"@babel/transform-runtime"
]
} |
@Piterden Try |
{
"presets": [
[
"@babel/env",
{
"modules": false,
"useBuiltIns": "usage",
"targets": {
"browsers": ["last 2 Chrome versions"]
},
"debug":true
}
]
],
"plugins": [
"@babel/transform-async-to-generator",
"@babel/transform-runtime"
]
} The same error |
Sorry, it is included. |
Without downgrading the runtime I had the following error after adding "plugin-transform-runtime": I got the hint to downgrade the runtime from meteor/meteor#10126 Also, because I downgraded the runtime I had to downgrade my other babel dependencies back to beta.47 too. My project uses react-native 56 and Metro 0.38. I only added plugin-transform-runtime because of this bug. Hope it helps. |
Hey, Helena, thank you for response. But shouldn't Honestly I use Vue. But this bug is not depend on our frameworks. It is babel. I already wrote there an issue. |
Hey, Piterden, no problem. I was just relieved there were people commenting on this issue and you were keeping the thread alive. But, yeah, I just noticed that so will move it before I commit. After this, I've opened the app and I've ran into another bug, and found this git issue.
I'm thinking about resorting back to using .bablerc because it all worked except for being able to have separate environments. |
For me it not work, I spent 15 hrs ))) |
@fhadsheikh solution worked after I did the following:
It helped to create a new project with "react-native init" and fix the bug to see which dependencies were needed. N.B. No need for @babel/plugin-transform-runtime if using .babelrc. My babel config is:
|
My solution is making those two methods sync, because |
This was an absolute nightmare to work out - Thanks for your hard work @helenaford - saved me a bunch of time 👍 |
…abelrc This adds support for projects using `metro-babel-register` with Babel 7's babel.config.js files. The `metro-babel-register` package is designed to apply a static, hardcoded list of Babel plugins. It intentionally ignores .babelrc files by setting `babelrc: false`. Babel 7 added a new configuration file called babel.config.js, with similar but slightly different loading semantics. To disable babel.config.js lookup, there is a new option called `configFile` instead of `babelrc`. See https://babeljs.io/docs/en/next/config-files#project-wide-configuration. Fixes facebook/react-native#21052 Test plan: In a React Native project with babel.config.js and an error about `regeneratorRuntime` missing, said error goes away with this `metro-babel-register` patch.
Thanks for the solution @helenaford ! saved my day! |
This is a really bad developer experience and why I stray from da fe 🧶 |
How is this not included in the readme or in troubleshooting or something? I 've followed the get started guide to run a hello world app and I 've struggled for two days searching for this. I ended up using react-native init instead of expo init and then run react-native run-ios twice till I get the project running. |
I had to also install the following plugins and dependancies that @helenaford 's comment shows: '@babel/plugin-proposal-export-default-from', |
I was having this problem when I runned this command "yarn". I fixed it by running "npm install" after I deleted my node_modules folder. If it does not work with yarn try npm |
Environment
Description
Using react-native 0.57.0-rc.4, the following issue exists:
Running the react-native local-cli (e.g. running the
npm start
command of a fresh react-native project) fails withwhen babel is setup with
babel.config.js
:Everything works when the same babel configuration is applied in the old
.babelrc
format.I traced down the problem by inserting console.logs in
node_modules/@babel/register/lib/node.js
, functioncompile
. When usingbabel.config.js
you can see that all plugins ofmodule:metro-react-native-babel-preset
are being applied to thenode_modules/react-native/local-cli/core/index.js
file; when using.babelrc
that's not the case. The code breaks because apparentlyregeneratorRuntime
call is inserted, butbabel/polyfill
(orregenerator-runtime/runtime
) import is not happening.Is this behaviour known? How are users expected to make use of
babel.config.js
?Reproducible Demo
Repository with working state
With a broken state
Repro:
npm install
/yarn install
npm start
The text was updated successfully, but these errors were encountered: