Socket
Socket
Sign inDemoInstall

metro-react-native-babel-transformer

Package Overview
Dependencies
Maintainers
2
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metro-react-native-babel-transformer - npm Package Compare versions

Comparing version 0.73.3 to 0.73.5

8

package.json
{
"name": "metro-react-native-babel-transformer",
"version": "0.73.3",
"version": "0.73.5",
"description": "Babel transformer for React Native applications.",

@@ -24,5 +24,5 @@ "main": "src/index.js",

"hermes-parser": "0.8.0",
"metro-babel-transformer": "0.73.3",
"metro-react-native-babel-preset": "0.73.3",
"metro-source-map": "0.73.3",
"metro-babel-transformer": "0.73.5",
"metro-react-native-babel-preset": "0.73.5",
"metro-source-map": "0.73.5",
"nullthrows": "^1.1.1"

@@ -29,0 +29,0 @@ },

@@ -11,33 +11,28 @@ /**

*/
// Note: This is a fork of the fb-specific transform.js
"use strict";
const { parseSync, transformFromAstSync } = require("@babel/core");
const inlineRequiresPlugin = require("babel-preset-fbjs/plugins/inline-requires");
const crypto = require("crypto");
const fs = require("fs");
const makeHMRConfig = require("metro-react-native-babel-preset/src/configs/hmr");
const { generateFunctionMap } = require("metro-source-map");
const nullthrows = require("nullthrows");
const path = require("path");
const cacheKeyParts = [
fs.readFileSync(__filename),
require("babel-preset-fbjs/package.json").version,
]; // TS detection conditions copied from metro-react-native-babel-preset
];
// TS detection conditions copied from metro-react-native-babel-preset
function isTypeScriptSource(fileName) {
return !!fileName && fileName.endsWith(".ts");
}
function isTSXSource(fileName) {
return !!fileName && fileName.endsWith(".tsx");
}
/**

@@ -48,8 +43,7 @@ * Return a memoized function that checks for the existence of a

*/
const getBabelRC = (function () {
let babelRC = null;
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
return function _getBabelRC({

@@ -63,3 +57,2 @@ projectRoot,

}
babelRC = {

@@ -69,13 +62,13 @@ plugins: [],

};
if (extendsBabelConfigPath) {
return babelRC;
} // Let's look for a babel config file in the project root.
}
let projectBabelRCPath; // .babelrc
// Let's look for a babel config file in the project root.
let projectBabelRCPath;
// .babelrc
if (projectRoot) {
projectBabelRCPath = path.resolve(projectRoot, ".babelrc");
}
if (projectBabelRCPath) {

@@ -85,9 +78,11 @@ // .babelrc.js

projectBabelRCPath = path.resolve(projectRoot, ".babelrc.js");
} // babel.config.js
}
// babel.config.js
if (!fs.existsSync(projectBabelRCPath)) {
projectBabelRCPath = path.resolve(projectRoot, "babel.config.js");
} // If we found a babel config file, extend our config off of it
}
// If we found a babel config file, extend our config off of it
// otherwise the default config will be used
if (fs.existsSync(projectBabelRCPath)) {

@@ -97,10 +92,12 @@ // $FlowFixMe[incompatible-use] `extends` is missing in null or undefined.

}
} // If a babel config file doesn't exist in the project then
}
// If a babel config file doesn't exist in the project then
// the default preset for react-native will be used instead.
// $FlowFixMe[incompatible-use] `extends` is missing in null or undefined.
// $FlowFixMe[incompatible-type] `extends` is missing in null or undefined.
if (!babelRC.extends) {
const { experimentalImportSupport, ...presetOptions } = options; // $FlowFixMe[incompatible-use] `presets` is missing in null or undefined.
const { experimentalImportSupport, ...presetOptions } = options;
// $FlowFixMe[incompatible-use] `presets` is missing in null or undefined.
babelRC.presets = [

@@ -121,6 +118,6 @@ [

}
return babelRC;
};
})();
/**

@@ -130,3 +127,2 @@ * Given a filename and options, build a Babel

*/
function buildBabelConfig(

@@ -149,10 +145,12 @@ filename,

};
let config = { ...babelRC, ...extraConfig }; // Add extra plugins
let config = {
...babelRC,
...extraConfig,
};
// Add extra plugins
const extraPlugins = [];
if (options.inlineRequires) {
extraPlugins.push(inlineRequiresPlugin);
}
const withExtrPlugins = (config.plugins = extraPlugins.concat(

@@ -162,3 +160,2 @@ config.plugins,

));
if (options.dev && options.hot) {

@@ -172,13 +169,16 @@ // Note: this intentionally doesn't include the path separator because

filename.indexOf("node_modules") === -1;
if (mayContainEditableReactComponents) {
const hmrConfig = makeHMRConfig();
hmrConfig.plugins = withExtrPlugins.concat(hmrConfig.plugins);
config = { ...config, ...hmrConfig };
config = {
...config,
...hmrConfig,
};
}
}
return { ...babelRC, ...config };
return {
...babelRC,
...config,
};
}
function transform({ filename, options, src, plugins }) {

@@ -189,3 +189,2 @@ const OLD_BABEL_ENV = process.env.BABEL_ENV;

: process.env.BABEL_ENV || "production";
try {

@@ -215,4 +214,5 @@ const babelConfig = {

filename,
}); // The result from `transformFromAstSync` can be null (if the file is ignored)
});
// The result from `transformFromAstSync` can be null (if the file is ignored)
if (!result) {

@@ -226,3 +226,2 @@ /* $FlowFixMe BabelTransformer specifies that the `ast` can never be null but

}
return {

@@ -238,3 +237,2 @@ ast: nullthrows(result.ast),

}
function getCacheKey() {

@@ -245,3 +243,2 @@ var key = crypto.createHash("md5");

}
module.exports = {

@@ -248,0 +245,0 @@ transform,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc