mirror of https://github.com/status-im/metro.git
Add transform-react-jsx-source to react-native preset
Summary: Putting this up as request for comments. The PR adds [transform-react-jsx-source](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-source) to the list of plugins that come by default with the `react-native` preset. It will enable the use of a bunch of really cool tooling around JSX, however those are generally useful only in development mode. Is changing `react-native` preset the right thing to do in this case? Is there a way to enable this transform only in DEV? Should I add this somewhere else? Closes https://github.com/facebook/react-native/pull/6351 Differential Revision: D3302906 Pulled By: frantic fbshipit-source-id: 012d3a4142168f9f90d30d1686115d4dc3996eb9
This commit is contained in:
parent
bd7114d00f
commit
e52076df73
|
@ -100,15 +100,22 @@ function buildBabelConfig(filename, options) {
|
||||||
function transform(src, filename, options) {
|
function transform(src, filename, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
const babelConfig = buildBabelConfig(filename, options);
|
const OLD_BABEL_ENV = process.env.BABEL_ENV;
|
||||||
const result = babel.transform(src, babelConfig);
|
process.env.BABEL_ENV = options.dev ? 'development' : 'production';
|
||||||
|
|
||||||
return {
|
try {
|
||||||
ast: result.ast,
|
const babelConfig = buildBabelConfig(filename, options);
|
||||||
code: result.code,
|
const result = babel.transform(src, babelConfig);
|
||||||
map: result.map,
|
|
||||||
filename: filename,
|
return {
|
||||||
};
|
ast: result.ast,
|
||||||
|
code: result.code,
|
||||||
|
map: result.map,
|
||||||
|
filename: filename,
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
process.env.BABEL_ENV = OLD_BABEL_ENV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = function(data, callback) {
|
module.exports = function(data, callback) {
|
||||||
|
|
Loading…
Reference in New Issue