-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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 4 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) => { | ||
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 |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
const babelJest = require('babel-jest'); | ||
|
||
module.exports = babelJest.createTransformer({ | ||
presets: [require.resolve('babel-preset-react-app')], | ||
presets: [[require.resolve('babel-preset-react-app'), { helpers: true }]], | ||
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. Doesn't matter for Jest though? 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. Probably not, how about eject? This is why I'd rather it by on by default, see |
||
babelrc: false, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,7 +234,12 @@ module.exports = { | |
options: { | ||
// @remove-on-eject-begin | ||
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. This is removed on eject. Where do we decide what to write on eject? Seems like we'd lose this. Maybe it means I wasn't right about the app default. 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. |
||
babelrc: false, | ||
presets: [require.resolve('babel-preset-react-app')], | ||
presets: [ | ||
[ | ||
require.resolve('babel-preset-react-app'), | ||
{ helpers: true }, | ||
], | ||
], | ||
// Make sure we have a unique cache identifier, erring on the | ||
// side of caution. | ||
// We remove this when the user ejects because the default | ||
|
@@ -275,6 +280,7 @@ module.exports = { | |
// Unlike the application JS, we only compile the standard ES features. | ||
{ | ||
test: /\.js$/, | ||
exclude: /@babel\/runtime/, | ||
use: [ | ||
// This loader parallelizes code compilation, it is optional but | ||
// improves compile time on larger projects | ||
|
@@ -290,7 +296,10 @@ module.exports = { | |
babelrc: false, | ||
compact: false, | ||
presets: [ | ||
require.resolve('babel-preset-react-app/dependencies'), | ||
[ | ||
require.resolve('babel-preset-react-app/dependencies'), | ||
{ helpers: true }, | ||
], | ||
], | ||
cacheDirectory: true, | ||
// Don't waste time on Gzipping the cache | ||
|
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.
Copy paste is your friend! Although I don't care
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.
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 comment
The 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.