-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Uncaught ReferenceError: regeneratorRuntime #1762
Comments
By default parcel uses babel to transpile your code. If you use promised or async/await babel will polyfill it. But as you do not provide a polyfill get an error. To fix this add a |
Thank you for answers, By default if i want to use async/await which babel packages dependencies i should install for my project ? |
Install |
Thank you all for your help. One irellevant question before i close this post. When iam saving a module the web browser shouldnt automatically refresh ? It only refresh when i save the main file index.js |
It should happen on every file, it might be a windows bug if you're on windows otherwise maybe safe-write? |
@DeMoorJasper When i save a module in .js the old HTML is still render in the web browser, i have to do it manually is that normal ? |
The HTML shouldn't change if you change js, it should reload through the socket that's been setup (called HMR). If it's just standard js (No framework) you'll probably have to write some HMR logic (either to refresh the page or handle HMR properly, probably easier to set it to refresh) |
To babel7 users (Parcel >= 1.10.0): {
"plugins": [
["@babel/plugin-transform-runtime", {
"corejs": 2
}]
]
} |
This works for me. Just config
|
following babel's docs solved my problem |
@timespace7 how come it doesn't work with |
I'm quite confused. I just tried parcel with Typescript and got the same error, but Typescript itself can already transform all code, why use Babel when? |
The detection of when to supply a default
I have to add a redundant |
+++ This is really broken. Parcel doesn't look smart because of that :\ BTW, I've found a workaround for the issue by downgrading parcel to
And adding It works but meeeeeh :\ |
In Parcel 2, we'll apply polyfills automatically where needed using Babel 7's This would be a breaking change for Parcel 1 to do this automatically, so we're waiting for Parcel 2. |
@devongovett but wait, maybe it's needed for js but in case of typescript it sounds like a workaround for this problem. Isn't it's better to handle transpilation with Because, if it's using Babel, I will better use webpack. Actually, it's one of two things I worried about:
P.S. just two cents / two comments from me, ty |
Hmm well the original issue wasn’t about typescript, but sure. Babel does currently run after typescript if needed. You can turn that off by setting up your browserslist properly. That said, for parcel 2 we’re considering just compiling typescript with Babel instead of tsc since Babel 7 can do that now. That’s a separate issue though. |
@fab7jj not sure I can be much help without a reproducible repository of some sort, importing that package should solve it... |
@DeMoorJasper to be honest with you all I am doing is using the async/await syntax and this issue popped up in the browser when that part of the code gets executed only when using the 'build' command, since while using the 'watch' or 'serve' command it is fine which is strange. Do i need to do something else besides importing that package in my index.js? declare it in the packagae.json or something? In parcel 2 there is no support for babel.rc file right? |
Like I said it should work, I've never had this issue before and use async all the time |
@DeMoorJasper Can you point me to some documentation on how to wire in this .babelrc config file in parcel 2 since I have seen a solution that requires installing the plugin: @babel/plugin-transform-runtime and then declare it in such file but I can't try it out since a rookie like me have no clue where to put it. That is strange then how some of us are having this issue, the only way I now made it work is by adding the below to the package.json
Only Chrome 78 worked, for example: last 1 Chrome versions did not work, but i fear that this is more of workaround rather than a proper solution Thanks a lot |
+1 for @zavan, I mean, I can understand that devs wouldn't like to fix issues that happens in v1.x while actively developing v2.x, but at least v2.x should have fixed the issue, but it didn't and that's a shame. And I'm not even talking about v2.x being very much less zero-config than v1.x... |
@KaKi87 this isn't an issue, this is just how babel/preset-env works... we didn't write that. Like I mentioned I can't get any of these issues to happen and use the async syntax all the time. @fab7jj you can view the v2 docs at https://v2.parceljs.org/ |
@DeMoorJasper can you point me to something more specific please I can't find anything about how to use .babelrc or babel.config.json in there. For example if I want to implement this solution here how I need to do in parcel 2? Since I believe I am having issues because I have babel-runtime installed. |
Well, this "non-issue" doesn't happen when using other bundlers. |
👍 Thin definitely is a parcel-only issue even if it originates in babel |
This is definitely still a problem. One solution is using this babelrc (Parcel 2): {
"presets": ["@parcel/babel-preset-env"],
"plugins": ["@parcel/babel-plugin-transform-runtime"]
} I'll investigate why we aren't doing this by default... |
@mischnic I tried the above babelrc but I am having an error when trying to run |
With Parcel 2, if you do specify a babel config, Parcel won't amend it, so you probably need: {
"presets": ["@parcel/babel-preset-env", "@babel/preset-react"],
"plugins": ["@parcel/babel-plugin-transform-runtime"]
} |
@mischnic please can you explain to me what is the difference between Also do you have any clue why I am getting this warning: "@parcel/babel-plugin-transform-runtime > @babel/plugin-transform-runtime@7.12.1" has unmet peer dependency "@babel/core@^7.0.0-0". I am using "parcel": "^2.0.0-beta.1" Thanks a lot |
Sorry, you should always use
You can ignore that for now. Looks like we need to add |
@mischnic thanks a lot for the clarifications |
We should definitely do this, the only question is whether |
I'm currently running into this issue. It only happens in production builds though, in development everything works automatically. I can solve it by adding |
Hi! Running into this too. After checking all possible solutions I've got to the following working combination. Expand
{
"dependencies": {
"react": "17.0.1",
"react-dom": "17.0.1",
"react-table": "7.6.3"
},
"scripts": {
"start": "parcel serve ./index.html",
"prestart": "rm -rf dist .parcel-cache"
},
"devDependencies": {
"parcel": "2.0.0-nightly.520"
}
} I'm using
import React, { useState } from "react";
import ReactDOM from "react-dom";
import { useAsyncDebounce } from "react-table";
const App = () => {
const [label, setLabel] = useState("");
const debounced = useAsyncDebounce(setLabel, 400); // Uncaught ReferenceError: regeneratorRuntime is not defined
// const debounced = setLabel; // works
return (
<>
<input
autoComplete="off"
type="text"
name="name"
defaultValue=""
onChange={(e) => debounced(e.target.value)}
/>
<p>{label}</p>
</>
);
};
ReactDOM.render(<App />, document.getElementById("app")); Steps to make it work:
For me, it wasn't enough to have only the babel config or the import alone - I had to add both. Otherwise, the error persists. |
Just this line is enough for me, without any other tweaks to configurations. |
Thanks for the reply! With
With
I've kept my project setup and just replaced the |
I'm not 100% sure how regeneratorRuntime is supposed to work, but I do find it strange that react-table just assumes that there's a global variable of that name: https://unpkg.com/browse/react-table@7.6.3/dist/react-table.development.js (line 301). |
@mischnic that is code generated by Babel. It replaces generators and async functions with that busy loop, but apparently react-table is not bundling the runtime and instead leaving it for the importer... |
I cannot find this anywhere in Parcel 2s Codebase. Both dev/preset-env and utils/preset-env use 'entry' |
I'm still having this issue with parcel 2.0.1, and none of the aforementioned solutions worked for me. I'm using React-Table as well. I managed to get it "working" by writing This looks brittle, but I hope it helps someone else. |
🐛 bug report
Iam trying to import and export a class from a module and i get this behavior. Every time iam trying to import the class or export it i get regeneratorRuntime .
🎛 Configuration (.babelrc, package.json, cli command)
🤔 Expected Behavior
Just import/export the class to the index.js
😯 Current Behavior
Instead of import/export the class i get the follow error :
js\models\foodSearch.js:6 Uncaught ReferenceError: regeneratorRuntime is not defined
at js\models\foodSearch.js:6
at js\models\foodSearch.js:12
at Object.parcelRequire.js\models\foodSearch.js.axios (js\models\foodSearch.js:12)
at newRequire (js.ee4a09a9.js:48)
at localRequire (js.ee4a09a9.js:54)
at Object.parcelRequire.js\index.js../models/famousChefQuotes (js\index.js:3)
at newRequire (js.ee4a09a9.js:48)
at parcelRequire.js\models\famousChefQuotes.js (js.ee4a09a9.js:80)
at js.ee4a09a9.js:106
........\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\util-deprecate\browser.js:14 Uncaught ReferenceError: regeneratorRuntime is not defined
at ........\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\util-deprecate\browser.js:14
at ........\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\util-deprecate\browser.js:41
at Object.parcelRequire.js\models\SearchFood.js.axios (........\AppData\Roaming\npm\node_modules\parcel-bundler\node_modules\util-deprecate\browser.js:45)
at newRequire (js.ee4a09a9.js:48)
at localRequire (js.ee4a09a9.js:54)
at Object.parcelRequire.js\index.js../models/famousChefQuotes (js\index.js:3)
at newRequire (js.ee4a09a9.js:48)
at parcelRequire.js\models\famousChefQuotes.js (js.ee4a09a9.js:80)
at js.ee4a09a9.js:106
💻 Code Sample
https://gist.github.com/Clickys/dd0d2ef946b15b0bf34b1ac23ecab3e0
🌍 Your Environment
+-- animate.css@3.6.1
+-- axios@0.18.0
+-- eslint@4.19.1
+-- eslint-config-airbnb-base@13.0.0
`-- eslint-plugin-import@2.13.0
parcel latest: '1.9.7'
The text was updated successfully, but these errors were encountered: