We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
regenerator shouldn't change code of the form:
if (false) { // do something }
to
case 1: if (true) break; // do something
It seems to be a little more complex than just moving the return statement outside of the if statement. Even this code causes an error:
async function test() { if (false) { console.log('do something') return {} } else { return {t: 1} } }
Generates this:
"use strict"; function test() { return regeneratorRuntime.async(function test$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (!false) { _context.next = 5; break; } console.log('do something'); return _context.abrupt("return", {}); case 5: return _context.abrupt("return", { t: 1 }); case 6: case "end": return _context.stop(); } }); }
The problem is that this prevents optimizing out the if (false) require on the client-side (the require should only run on the server).
Related: vercel/next.js#9298
The text was updated successfully, but these errors were encountered:
Basic test:
const code = ` async function test() { if (false) { console.log('do something') return {} } else { return {t: 1} } } ` const compiled = require("@babel/core").transformSync(code, { configFile: false, plugins: [ require("regenerator-transform"), require("@babel/plugin-transform-modules-commonjs") ] }).code; console.log(compiled) console.assert(compiled.indexOf('if (!false)') === -1)
Sorry, something went wrong.
No branches or pull requests
regenerator shouldn't change code of the form:
to
It seems to be a little more complex than just moving the return statement outside of the if statement. Even this code causes an error:
Generates this:
The problem is that this prevents optimizing out the if (false) require on the client-side (the require should only run on the server).
Related: vercel/next.js#9298
The text was updated successfully, but these errors were encountered: