@talend/babel-plugin-import-from-index
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "@talend/babel-plugin-import-from-index", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Transform default imports from specific path to named import from index", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -19,3 +19,6 @@ const PACKAGE_NAME = '@talend/react-components'; | ||
imports.push( | ||
...importDeclarationPath.node.specifiers.map(({ local }) => local.name), | ||
...importDeclarationPath.node.specifiers.map(({ local, imported }) => ({ | ||
local: local.name, | ||
imported: imported ? imported.name : local.name, | ||
})), | ||
); | ||
@@ -31,4 +34,4 @@ importDeclarationPath.remove(); | ||
const source = types.stringLiteral(PACKAGE_NAME); | ||
const specifiers = imports.map(name => | ||
types.importSpecifier(types.identifier(name), types.identifier(name)), | ||
const specifiers = imports.map(({ local, imported }) => | ||
types.importSpecifier(types.identifier(local), types.identifier(imported)), | ||
); | ||
@@ -35,0 +38,0 @@ const imp = types.importDeclaration(specifiers, source); |
@@ -22,3 +22,12 @@ import pluginTester from 'babel-plugin-tester'; | ||
}, | ||
{ | ||
code: ` | ||
import React from 'react'; | ||
import { SidePanel } from '@talend/react-components'; | ||
import { ModelViewer as ModelViewerComponent } from '@talend/react-components';`, | ||
output: ` | ||
import React from 'react'; | ||
import { SidePanel, ModelViewer as ModelViewerComponent } from '@talend/react-components';`, | ||
}, | ||
], | ||
}); |
3934
69