metro-react-native-babel-preset
Advanced tools
Comparing version 0.49.0 to 0.49.1
{ | ||
"name": "metro-react-native-babel-preset", | ||
"version": "0.49.0", | ||
"version": "0.49.1", | ||
"description": "Babel preset for React Native applications", | ||
@@ -54,5 +54,5 @@ "main": "src/index.js", | ||
"@babel/template": "^7.0.0", | ||
"metro-babel7-plugin-react-transform": "0.49.0", | ||
"metro-babel7-plugin-react-transform": "0.49.1", | ||
"react-transform-hmr": "^1.0.4" | ||
} | ||
} |
@@ -12,3 +12,5 @@ /** | ||
var path = require("path"); | ||
var hmrTransform = "react-transform-hmr/lib/index.js"; | ||
var transformPath = require.resolve(hmrTransform); | ||
@@ -19,5 +21,4 @@ | ||
? "./" + path.relative(path.dirname(filename), transformPath) // packager can't handle absolute paths | ||
: hmrTransform; | ||
: hmrTransform; // Fix the module path to use '/' on Windows. | ||
// Fix the module path to use '/' on Windows. | ||
if (path.sep === "\\") { | ||
@@ -24,0 +25,0 @@ transform = transform.replace(/\\/g, "/"); |
@@ -9,18 +9,36 @@ /** | ||
*/ | ||
"use strict"; | ||
"use strict"; | ||
var _extends = | ||
Object.assign || | ||
function(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
function _objectSpread(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
var ownKeys = Object.keys(source); | ||
if (typeof Object.getOwnPropertySymbols === "function") { | ||
ownKeys = ownKeys.concat( | ||
Object.getOwnPropertySymbols(source).filter(function(sym) { | ||
return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
}) | ||
); | ||
} | ||
return target; | ||
}; | ||
ownKeys.forEach(function(key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
return obj; | ||
} | ||
function isTypeScriptSource(fileName) { | ||
@@ -36,12 +54,11 @@ return !!fileName && fileName.endsWith(".ts"); | ||
[require("@babel/plugin-proposal-optional-catch-binding")], | ||
[require("@babel/plugin-transform-block-scoping")], | ||
// the flow strip types plugin must go BEFORE class properties! | ||
[require("@babel/plugin-transform-block-scoping")], // the flow strip types plugin must go BEFORE class properties! | ||
// there'll be a test case that fails if you don't. | ||
[require("@babel/plugin-transform-flow-strip-types")], | ||
[ | ||
require("@babel/plugin-proposal-class-properties"), | ||
// use `this.foo = bar` instead of `this.defineProperty('foo', ...)` | ||
{ loose: true } | ||
require("@babel/plugin-proposal-class-properties"), // use `this.foo = bar` instead of `this.defineProperty('foo', ...)` | ||
{ | ||
loose: true | ||
} | ||
], | ||
[require("@babel/plugin-syntax-dynamic-import")], | ||
@@ -60,7 +77,5 @@ [require("@babel/plugin-syntax-export-default-from")], | ||
]; | ||
const es2015ExportDefault = [ | ||
require("@babel/plugin-proposal-export-default-from") | ||
]; | ||
const es2015ImportExport = [ | ||
@@ -70,15 +85,16 @@ require("@babel/plugin-transform-modules-commonjs"), | ||
strict: false, | ||
strictMode: false, // prevent "use strict" injections | ||
strictMode: false, | ||
// prevent "use strict" injections | ||
allowTopLevelThis: true // dont rewrite global `this` -> `undefined` | ||
} | ||
]; | ||
const es2015ArrowFunctions = [ | ||
require("@babel/plugin-transform-arrow-functions") | ||
]; | ||
const es2015Classes = [require("@babel/plugin-transform-classes")]; | ||
const es2015ForOf = [ | ||
require("@babel/plugin-transform-for-of"), | ||
{ loose: true } | ||
{ | ||
loose: true | ||
} | ||
]; | ||
@@ -88,9 +104,9 @@ const es2015Spread = [require("@babel/plugin-transform-spread")]; | ||
require("@babel/plugin-transform-template-literals"), | ||
{ loose: true } | ||
{ | ||
loose: true | ||
} | ||
]; | ||
const exponentiationOperator = [ | ||
require("@babel/plugin-transform-exponentiation-operator") | ||
]; | ||
const objectAssign = [require("@babel/plugin-transform-object-assign")]; | ||
@@ -100,17 +116,17 @@ const objectRestSpread = [require("@babel/plugin-proposal-object-rest-spread")]; | ||
require("@babel/plugin-proposal-nullish-coalescing-operator"), | ||
{ loose: true } | ||
{ | ||
loose: true | ||
} | ||
]; | ||
const optionalChaining = [ | ||
require("@babel/plugin-proposal-optional-chaining"), | ||
{ loose: true } | ||
{ | ||
loose: true | ||
} | ||
]; | ||
const reactDisplayName = [ | ||
require("@babel/plugin-transform-react-display-name") | ||
]; | ||
const reactJsxSource = [require("@babel/plugin-transform-react-jsx-source")]; | ||
const symbolMember = [require("../transforms/transform-symbol-member")]; | ||
const babelRuntime = [ | ||
@@ -129,3 +145,2 @@ require("@babel/plugin-transform-runtime"), | ||
isNull || (src.indexOf("for") !== -1 && src.indexOf("of") !== -1); | ||
const extraPlugins = []; | ||
@@ -140,5 +155,7 @@ | ||
} | ||
if (isNull || src.indexOf("=>") !== -1) { | ||
extraPlugins.push(es2015ArrowFunctions); | ||
} | ||
if (isNull || hasClass || src.indexOf("...") !== -1) { | ||
@@ -148,17 +165,23 @@ extraPlugins.push(es2015Spread); | ||
} | ||
if (isNull || src.indexOf("`") !== -1) { | ||
extraPlugins.push(es2015TemplateLiterals); | ||
} | ||
if (isNull || src.indexOf("**") !== -1) { | ||
extraPlugins.push(exponentiationOperator); | ||
} | ||
if (isNull || src.indexOf("Object.assign") !== -1) { | ||
extraPlugins.push(objectAssign); | ||
} | ||
if (hasForOf) { | ||
extraPlugins.push(es2015ForOf); | ||
} | ||
if (hasForOf || src.indexOf("Symbol") !== -1) { | ||
extraPlugins.push(symbolMember); | ||
} | ||
if ( | ||
@@ -171,5 +194,7 @@ isNull || | ||
} | ||
if (isNull || src.indexOf("?.") !== -1) { | ||
extraPlugins.push(optionalChaining); | ||
} | ||
if (isNull || src.indexOf("??") !== -1) { | ||
@@ -194,17 +219,24 @@ extraPlugins.push(nullishCoalescingOperator); | ||
}, | ||
{ | ||
test: isTypeScriptSource, | ||
plugins: [ | ||
[require("@babel/plugin-transform-typescript"), { isTSX: false }] | ||
[ | ||
require("@babel/plugin-transform-typescript"), | ||
{ | ||
isTSX: false | ||
} | ||
] | ||
] | ||
}, | ||
{ | ||
test: isTSXSource, | ||
plugins: [ | ||
[require("@babel/plugin-transform-typescript"), { isTSX: true }] | ||
[ | ||
require("@babel/plugin-transform-typescript"), | ||
{ | ||
isTSX: true | ||
} | ||
] | ||
] | ||
}, | ||
{ | ||
@@ -220,6 +252,13 @@ plugins: extraPlugins | ||
const env = process.env.BABEL_ENV || process.env.NODE_ENV; | ||
if (!env || env === "development") { | ||
return getPreset(null, _extends({}, options, { dev: true })); | ||
return getPreset( | ||
null, | ||
_objectSpread({}, options, { | ||
dev: true | ||
}) | ||
); | ||
} | ||
} | ||
return getPreset(null, options); | ||
@@ -226,0 +265,0 @@ }; |
@@ -9,3 +9,2 @@ /** | ||
*/ | ||
"use strict"; | ||
@@ -12,0 +11,0 @@ |
@@ -9,5 +9,3 @@ /** | ||
*/ | ||
"use strict"; | ||
/*eslint consistent-return: 0*/ | ||
@@ -27,5 +25,5 @@ | ||
*/ | ||
module.exports = function symbolMember(babel) { | ||
const t = babel.types; | ||
return { | ||
@@ -39,3 +37,2 @@ visitor: { | ||
const node = path.node; | ||
path.replaceWith( | ||
@@ -48,10 +45,8 @@ t.conditionalExpression( | ||
), | ||
node, | ||
t.stringLiteral(`@@${node.property.name}`) | ||
) | ||
); | ||
); // We should stop to avoid infinite recursion, since Babel | ||
// traverses replaced path, and again would hit our transform. | ||
// We should stop to avoid infinite recursion, since Babel | ||
// traverses replaced path, and again would hit our transform. | ||
path.stop(); | ||
@@ -65,3 +60,2 @@ } | ||
const node = path.node; | ||
return ( | ||
@@ -68,0 +62,0 @@ path.parentPath.type !== "AssignmentExpression" && |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13364
337
+ Addedelectron-to-chromium@1.5.30(transitive)
+ Addedmetro-babel7-plugin-react-transform@0.49.1(transitive)
- Removedelectron-to-chromium@1.5.29(transitive)
- Removedmetro-babel7-plugin-react-transform@0.49.0(transitive)