Socket
Socket
Sign inDemoInstall

@talend/babel-plugin-import-from-index

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.0-alpha.3 to 1.4.0-alpha.4

2

package.json
{
"name": "@talend/babel-plugin-import-from-index",
"version": "1.4.0-alpha.3",
"version": "1.4.0-alpha.4",
"description": "Transform default imports from specific path to named import from index",

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

@@ -10,8 +10,2 @@ const PACKAGES = ['@talend/react-components', 'lodash', 'react-bootstrap', 'redux-saga'];

const hasNameSupport = {
lodash: true,
'react-bootstrap': true,
'@talend/react-components': false,
'redux-saga': true,
};
const hasNamedSubSupport = {

@@ -78,21 +72,25 @@ lodash: false,

if (hasNamedSubSupport[packageName] && lastName) {
let first = false;
let mustBeAdded = false;
if (!addConst[packageName]) {
first = true;
addConst[packageName] = {};
}
if (!addConst[packageName][lastName]) {
mustBeAdded = true;
addConst[packageName][lastName] = [];
}
addConst[packageName][lastName].push(imported.name);
// only one default
if (!first) {
if (mustBeAdded) {
return types.importSpecifier(
types.identifier(lastName),
types.identifier(lastName)
types.identifier(lastName),
);
}
return false;
}
} else if (lastName && lastName !== localName && hasNameSupport[packageName]) {
} else if (lastName && lastName !== localName) {
importedName = lastName;

@@ -116,3 +114,6 @@ }

const source = types.stringLiteral(packageName);
const imp = types.importDeclaration(importSpecifiers[packageName].filter(Boolean), source);
const imp = types.importDeclaration(
importSpecifiers[packageName].filter(Boolean),
source,
);

@@ -122,10 +123,7 @@ const extraKeys = Object.keys(addConst[packageName] || {});

extraKeys.forEach(extraKey => {
const properties = addConst[packageName][extraKey].map(n => types.objectProperty(types.identifier(n), types.identifier(n), false, true));
const pattern = types.objectPattern(
properties
const properties = addConst[packageName][extraKey].map(n =>
types.objectProperty(types.identifier(n), types.identifier(n), false, true),
);
const declarator = types.variableDeclarator(
pattern,
types.identifier(extraKey)
);
const pattern = types.objectPattern(properties);
const declarator = types.variableDeclarator(pattern, types.identifier(extraKey));
const c = types.variableDeclaration('const', [declarator]);

@@ -132,0 +130,0 @@ realLastImport.insertAfter(c);

@@ -33,3 +33,3 @@ import pluginTester from 'babel-plugin-tester';

import { SidePanel } from '@talend/react-components';
import Actions, { ActionButton, ActionDropdown } from '@talend/react-components/lib/actions';
import { Actions, ActionButton, ActionDropdown } from '@talend/react-components';
import List from '@talend/react-components/lib/List';`,

@@ -36,0 +36,0 @@ output: `

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc