You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP →

babel-plugin-module-name-mapper

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-module-name-mapper - npm Package Compare versions

Comparing version

to
1.2.0

@@ -44,3 +44,3 @@ "use strict";

if (replaceUsesPkgDir) {
const pkgDir = (0, _utils.lazyFindPkg)(fileDirname);
const pkgDir = (0, _utils.lazyFindPkgDir)(fileDirname);
nextPath = nextPath.replace('<pkgDir>', pkgDir);

@@ -47,0 +47,0 @@ }

"use strict";
exports.__esModule = true;
exports.traverseExpression = exports.lazyFindPkg = void 0;
exports.traverseExpression = exports.lazyFindPkgDir = void 0;
var _lodash = require("lodash");
var _lodash = _interopRequireDefault(require("lodash.memoize"));
var _path = require("path");
var _findPkg = _interopRequireDefault(require("find-pkg"));
var _fs = require("fs");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const lazyFindPkg = (0, _lodash.memoize)(filename => (0, _path.dirname)(_findPkg.default.sync(filename)));
// @docs https://github.com/shinnn/find-pkg-dir/blob/master/index.js
// const PKG_ERROR = new Error('package.json not found');
const PKG_FILENAME = 'package.json';
const lazyFindPkgDir = (0, _lodash.default)(dirName => {
const actualDirName = (0, _path.resolve)(dirName);
const _parse = (0, _path.parse)(actualDirName),
root = _parse.root;
const pkgPath = (0, _path.join)(actualDirName, PKG_FILENAME);
const pkgExists = (0, _fs.existsSync)(pkgPath);
if (pkgExists) {
return (0, _path.dirname)(pkgPath);
}
if (dirName === root) {
return null;
}
return lazyFindPkgDir((0, _path.dirname)(dirName));
/*
try {
const pkgPath = require.resolve(join(actualDirName, PKG_FILENAME))
if (basename(pkgPath) !== PKG_FILENAME) {
throw PKG_ERROR;
}
return dirname(pkgPath);
} catch (err) {
if (dirName === root) {
return null;
}
return lazyFindPkgDir(dirname(dirName));
}
*/
});
/**

@@ -22,3 +57,3 @@ * Recursively traverses binary expressions to find the first `StringLiteral` if any.

exports.lazyFindPkg = lazyFindPkg;
exports.lazyFindPkgDir = lazyFindPkgDir;

@@ -25,0 +60,0 @@ const traverseExpression = (t, arg) => {

{
"name": "babel-plugin-module-name-mapper",
"version": "1.1.2",
"version": "1.2.0",
"description": "Babel plugin to map module resolution",

@@ -22,4 +22,3 @@ "main": "lib/index.js",

"dependencies": {
"find-pkg": "^2.0.0",
"lodash": "^4.17.11"
"lodash.memoize": "^4.1.2"
},

@@ -26,0 +25,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet