-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Fix Babel issues in tests by applying the right transforms #1179
Conversation
Test file I used in different environments: import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
export function *foo() {
yield 42;
yield 49;
}
export async function lol() {
return await Promise.resolve(5000);
}
class App extends Component {
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
var addIndex = function addIndex({ index, ...routes } = {}, base) {
};
function doSometing() {
return {};
}
const getId = async () => {
const { id } = await doSometing(42)
return id
};
const getId2 = async () => {
const p = await doSometing(42)
const { id } = p
return id
};
function Record() {
return function() {}
}
const User = new Record({ id: NaN })
new User({ id: 42 })
export const x = async () => {
var y = foo()
var z = y.next()
while (!z.done) {
console.log(z.value);
z = y.next();
}
const wow = await lol();
console.log(wow)
};
x();
export default App; I tried Chrome, IE11, Node 4, and Node 7. |
Just more explaination for future ref
This is simply because I didn't account for a default in object rest spread so currently the object/rest spread transform doesn't do anything to the code and thus the syntax error.
Still need to look into it |
which is checking an Expression but getting an ObjectPattern via @benjamn just reimplemented the transform in facebook/regenerator#259 |
Other transforms are sometimes necessary to satisfy the preconditions of Regenerator. That's why |
Do we need to add everything from |
I wouldn't literally use |
Hmm. Is there ever a case where Node supports classes/arrows/block-scoping/for-of but not generators? |
Node 4 / 5 don't support generator |
@hzoo Does -env take care of this? Should I file an issue? |
@gaearon Looks like it does, for both for-of and regenerator; generators were fixed a v8 release before for-of (according to compat-table). |
Sounds great. Thanks! |
* master: (30 commits) Relax peerDependencies for ESLint preset (facebook#1191) Update Webpack to fix source map issues (facebook#1188) Update webpack prod config (facebook#1181) Chrome 'open tab' reuse an empty tab when possible (facebook#1165) Use file-loader for svgs (facebook#1180) Fix Babel issues in tests by applying the right transforms (facebook#1179) [babel-preset-react-app] Temporary fix missing babel plugins (facebook#1177) Add Subresource Integrity support (facebook#1176) Remove path module from webpack config on eject. (facebook#1175) Don't strip stack traces of evaluated webpack bundles (facebook#1050) Add deploy to Firebase CDN on template's README (Closes facebook#374) (facebook#1143) Update e2e.sh (facebook#1167) Document what npm build does and pushState (facebook#933) Fix minor typo/grammar (facebook#1099) Add "npm run build silently fails" to Troubleshooting (facebook#1168) Add testURL to jest config (facebook#1120) Make jsx-no-undef rule an error (facebook#1159) Update CHANGELOG.md Publish Update changelog for 0.8.1 ...
Fixed in 0.8.2. https://github.com/facebookincubator/create-react-app/releases/tag/v0.8.2 |
tests are OK for me |
This is a followup to #1177 with a less aggressive fix.
For context, read threads #1156 and #1160.
Why this works:
test
environment was incorrect. Itsasync: false
option only made sense fordevelopment
andproduction
configuration where we usebabel-preset-latest
, and so async functions are already being handled. But fortest
environment we usebabel-preset-env
instead ofbabel-preset-latest
, and so including regenerator second time is redundant (and somehow breaks things—@hzoo could you clarify why this happened?)I am remove
destructuring
andarrow-functions
because they were added as stopgap measure in #1177 but turned out unnecessary per #1156 (comment).Fixes #1156 and #1160.