-
-
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
Turn on Babel helpers
#5093
Turn on Babel helpers
#5093
Changes from 3 commits
775387a
ca2777f
b86f9bd
937d786
b74852a
3cdbbfe
3dbc5f8
2b06e8b
8ef839d
55a605b
071aa4f
82c82f8
a404acc
5bb2ee2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const validateBoolOption = (name, value, defaultValue) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy paste is your friend! Although I don't care There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As in you'd rather it be copypasta instead of a util file? 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's something trivial like this, yeah I don't mind copy pasta. |
||
if (typeof value === 'undefined') { | ||
value = defaultValue; | ||
} | ||
|
||
if (typeof value !== 'boolean') { | ||
throw new Error(`Preset react-app: '${name}' option must be a boolean.`); | ||
} | ||
|
||
return value; | ||
}; | ||
|
||
module.exports = { validateBoolOption }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ky from 'ky'; | ||
|
||
export default class extends Component { | ||
static propTypes = { | ||
onReady: PropTypes.func.isRequired, | ||
}; | ||
|
||
state = { ip: null }; | ||
|
||
async componentDidMount() { | ||
const ip = await ky.get('https://canihazip.com/s').text(); | ||
this.setState({ ip }); | ||
} | ||
|
||
componentDidUpdate() { | ||
this.props.onReady(); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div id="feature-babel-node-modules"> | ||
{this.state.ip ? <span>{this.state.ip}</span> : null} | ||
</div> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
describe('node_modules compile', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
return import('./NodeModulesCompilation').then( | ||
({ default: NodeModulesCompilation }) => { | ||
return new Promise(resolve => { | ||
ReactDOM.render(<NodeModulesCompilation onReady={resolve} />, div); | ||
}); | ||
} | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, shouldn't default be false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the non-dependency version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it's for app code. Hmm.
Would it break these instructions?
https://reactjs.org/docs/add-react-to-a-website.html#run-jsx-preprocessor
If so I think it should still be off by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/facebook/create-react-app/pull/5093/files#diff-e4eb38a3161bed144100754a3e97763dR26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right but I don't want this to break non-commonjs usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe we should have a separate entry point for "standalone" usage.