New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-tiny-import

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-tiny-import - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

README.md

9

lib/easy-module-mapper.js

@@ -12,5 +12,5 @@

}
const { basename, resolve, resolvePackageAsAbsolute, filename } = opts
if (typeof resolve === 'function') {
return resolve(path, opts);
const { basename, resolve: _resolve, resolvePackageAsAbsolute, filename } = opts
if (typeof _resolve === 'function') {
return _resolve(path, opts);
}

@@ -30,2 +30,3 @@

basedir: filename ? nps.dirname(filename): undefined,
preserveSymlinks: false,
...(typeof resolvePackageAsAbsolute === 'object' ? resolvePackageAsAbsolute : {})

@@ -89,3 +90,3 @@ })

var key = node.left.property.name;
var moduleName = resolve(node.right.arguments[0].value, obj.basename);
var moduleName = resolve(node.right.arguments[0].value, obj);

@@ -92,0 +93,0 @@ map[key] = moduleName

@@ -66,3 +66,5 @@ /**

function packModuleMapper(moduleMapper) {
function packModuleMapper(state) {
let { moduleMapper, resolveFromRelative = true } = state.opts || {};
const resolveFromFile = state.file && state.file.opts && state.file.opts.filename || state.filename;
assertModuleMapper(moduleMapper);

@@ -85,10 +87,22 @@

}
return moduleMapper;
return function () {
const finalResult = moduleMapper.apply(this, arguments)
if (!finalResult) {
return finalResult
}
if (finalResult.moduleName && resolveFromRelative && resolveFromFile && nps.posix.isAbsolute(finalResult.moduleName)) {
return {
...finalResult,
moduleName: nps.posix.join('.', nps.relative(resolveFromFile, finalResult.moduleName)),
}
}
return finalResult
};
}
function getImportOrExportDeclarationMultipleNodes(map, {
moduleMapper, moduleName, state, isImport = true
moduleName, state, isImport = true
}) {
var ignoreMap = state.ignoreMap;
moduleMapper = packModuleMapper(moduleMapper);
const moduleMapper = packModuleMapper(state);

@@ -225,3 +239,2 @@ return Object.keys(map).map(function (local) {

getImportOrExportDeclarationMultipleNodes(map, {
moduleMapper: state.opts.moduleMapper,
moduleName: path.node.source.value,

@@ -241,3 +254,3 @@ state: this,

getImportOrExportDeclarationMultipleNodes(map, {
moduleMapper: state.opts.moduleMapper, moduleName: path.node.source.value, state: this,
moduleName: path.node.source.value, state: this,
isImport: false

@@ -271,3 +284,3 @@ }),

});
var moduleMapper = packModuleMapper(state.opts.moduleMapper);
var moduleMapper = packModuleMapper(state);
var moduleName = node.init.arguments[0].value;

@@ -274,0 +287,0 @@ var restArguments = node.init.arguments.slice(1);

{
"name": "babel-plugin-tiny-import",
"version": "1.0.1",
"version": "1.0.2",
"description": "split import from wrap package",

@@ -5,0 +5,0 @@ "private": false,

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