metro-react-native-babel-preset
Advanced tools
Comparing version 0.73.3 to 0.73.5
{ | ||
"name": "metro-react-native-babel-preset", | ||
"version": "0.73.3", | ||
"version": "0.73.5", | ||
"description": "Babel preset for React Native applications", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -10,2 +10,3 @@ /** | ||
*/ | ||
"use strict"; | ||
@@ -12,0 +13,0 @@ |
@@ -10,5 +10,7 @@ /** | ||
*/ | ||
// This is the set of modules that React Native publicly exports and that we | ||
// want to require lazily. Keep this list in sync with | ||
// react-native/index.js (though having extra entries here is fairly harmless). | ||
"use strict"; | ||
@@ -47,3 +49,4 @@ | ||
"VirtualizedList", | ||
"VirtualizedSectionList", // APIs | ||
"VirtualizedSectionList", | ||
// APIs | ||
"ActionSheetIOS", | ||
@@ -82,3 +85,4 @@ "Alert", | ||
"UTFSequence", | ||
"Vibration", // Plugins | ||
"Vibration", | ||
// Plugins | ||
"RCTDeviceEventEmitter", | ||
@@ -85,0 +89,0 @@ "RCTNativeAppEventEmitter", |
@@ -10,16 +10,13 @@ /** | ||
*/ | ||
"use strict"; | ||
const passthroughSyntaxPlugins = require("../passthrough-syntax-plugins"); | ||
const lazyImports = require("./lazy-imports"); | ||
function isTypeScriptSource(fileName) { | ||
return !!fileName && fileName.endsWith(".ts"); | ||
} | ||
function isTSXSource(fileName) { | ||
return !!fileName && fileName.endsWith(".tsx"); | ||
} | ||
const defaultPlugins = [ | ||
@@ -29,3 +26,4 @@ [require("@babel/plugin-syntax-flow")], | ||
[ | ||
require("@babel/plugin-proposal-class-properties"), // use `this.foo = bar` instead of `this.defineProperty('foo', ...)` | ||
require("@babel/plugin-proposal-class-properties"), | ||
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)` | ||
{ | ||
@@ -40,3 +38,2 @@ loose: true, | ||
]; | ||
const getPreset = (src, options) => { | ||
@@ -51,3 +48,2 @@ const transformProfile = | ||
const extraPlugins = []; | ||
if (!options.useTransformReactJSXExperimental) { | ||
@@ -61,3 +57,2 @@ extraPlugins.push([ | ||
} | ||
if (!options || !options.disableImportExportTransform) { | ||
@@ -84,7 +79,7 @@ extraPlugins.push( | ||
extraPlugins.push([require("@babel/plugin-transform-classes")]); | ||
} // TODO(gaearon): put this back into '=>' indexOf bailout | ||
} | ||
// TODO(gaearon): put this back into '=>' indexOf bailout | ||
// and patch react-refresh to not depend on this transform. | ||
extraPlugins.push([require("@babel/plugin-transform-arrow-functions")]); | ||
if (!isHermes) { | ||
@@ -107,3 +102,2 @@ extraPlugins.push([require("@babel/plugin-transform-computed-properties")]); | ||
} | ||
if (!isHermesCanary) { | ||
@@ -117,3 +111,2 @@ extraPlugins.push([ | ||
} | ||
if (!isHermes && (isNull || hasClass || src.indexOf("...") !== -1)) { | ||
@@ -123,3 +116,4 @@ extraPlugins.push( | ||
[ | ||
require("@babel/plugin-proposal-object-rest-spread"), // Assume no dependence on getters or evaluation order. See https://github.com/babel/babel/pull/11520 | ||
require("@babel/plugin-proposal-object-rest-spread"), | ||
// Assume no dependence on getters or evaluation order. See https://github.com/babel/babel/pull/11520 | ||
{ | ||
@@ -132,3 +126,2 @@ loose: true, | ||
} | ||
if (!isHermes && (isNull || src.indexOf("`") !== -1)) { | ||
@@ -149,3 +142,2 @@ extraPlugins.push([ | ||
} | ||
if ( | ||
@@ -158,3 +150,2 @@ isNull || | ||
} | ||
if (!isHermes && (isNull || src.indexOf("?.") !== -1)) { | ||
@@ -168,3 +159,2 @@ extraPlugins.push([ | ||
} | ||
if (!isHermes && (isNull || src.indexOf("??") !== -1)) { | ||
@@ -178,3 +168,2 @@ extraPlugins.push([ | ||
} | ||
if (options && options.dev && !options.useTransformReactJSXExperimental) { | ||
@@ -184,3 +173,2 @@ extraPlugins.push([require("@babel/plugin-transform-react-jsx-source")]); | ||
} | ||
if (!options || options.enableBabelRuntime !== false) { | ||
@@ -203,3 +191,2 @@ // Allows configuring a specific runtime version to optimize output | ||
} | ||
return { | ||
@@ -247,15 +234,14 @@ comments: false, | ||
}; | ||
module.exports = (options) => { | ||
if (options.withDevTools == null) { | ||
const env = process.env.BABEL_ENV || process.env.NODE_ENV; | ||
if (!env || env === "development") { | ||
return getPreset(null, { ...options, dev: true }); | ||
return getPreset(null, { | ||
...options, | ||
dev: true, | ||
}); | ||
} | ||
} | ||
return getPreset(null, options); | ||
}; | ||
module.exports.getPreset = getPreset; |
@@ -10,11 +10,10 @@ /** | ||
*/ | ||
"use strict"; | ||
const main = require("./configs/main"); | ||
module.exports = function (babel, options) { | ||
return main(options); | ||
}; | ||
module.exports.getPreset = main.getPreset; | ||
module.exports.passthroughSyntaxPlugins = require("./passthrough-syntax-plugins"); |
@@ -10,3 +10,6 @@ /** | ||
*/ | ||
"use strict"; // This list of syntax plugins is used for two purposes: | ||
"use strict"; | ||
// This list of syntax plugins is used for two purposes: | ||
// 1. Enabling experimental syntax features in the INPUT to the Metro Babel | ||
@@ -16,3 +19,2 @@ // transformer, regardless of whether we actually transform them. | ||
// the Metro Babel transformer. | ||
const passthroughSyntaxPlugins = [ | ||
@@ -19,0 +21,0 @@ [require("@babel/plugin-syntax-nullish-coalescing-operator")], |
14609
364