@@ -3,16 +3,16 @@ import { Collection, JSCodeshift } from "jscodeshift";
33import { PACKAGE_NAME } from "../config" ;
44import { getClientTypeNames } from "../ts-type" ;
55import { getClientDeepImportPath } from "../utils" ;
6- import { hasImportEquals } from "./hasImportEquals" ;
7- import { hasRequire } from "./hasRequire" ;
86import { removeImportDefault } from "./removeImportDefault" ;
97import { removeImportEquals } from "./removeImportEquals" ;
108import { removeImportNamed } from "./removeImportNamed" ;
119import { removeRequireIdentifier } from "./removeRequireIdentifier" ;
1210import { removeRequireObjectProperty } from "./removeRequireObjectProperty" ;
1311import { removeRequireProperty } from "./removeRequireProperty" ;
12+ import { ImportType } from "./types" ;
1413
1514export interface RemoveClientModuleOptions {
15+ importType : ImportType ;
1616 v2ClientName : string ;
1717 v2ClientLocalName : string ;
1818 v2GlobalName ?: string ;
@@ -23,17 +23,17 @@ export const removeClientModule = (
2323 source : Collection < unknown > ,
2424 options : RemoveClientModuleOptions
2525) => {
26- const { v2ClientName, v2ClientLocalName } = options ;
26+ const { importType , v2ClientName, v2ClientLocalName } = options ;
2727 const deepImportPath = getClientDeepImportPath ( v2ClientName ) ;
2828
2929 const defaultOptions = { localName : v2ClientLocalName , sourceValue : deepImportPath } ;
3030 const namedOptions = { localName : v2ClientLocalName , sourceValue : PACKAGE_NAME } ;
3131
32- if ( hasRequire ( j , source ) ) {
32+ if ( importType === ImportType . REQUIRE ) {
3333 removeRequireIdentifier ( j , source , defaultOptions ) ;
3434 removeRequireObjectProperty ( j , source , namedOptions ) ;
3535 removeRequireProperty ( j , source , { ...namedOptions , propertyName : v2ClientName } ) ;
36- } else if ( hasImportEquals ( j , source ) ) {
36+ } else if ( importType === ImportType . IMPORT_EQUALS ) {
3737 removeImportEquals ( j , source , defaultOptions ) ;
3838 } else {
3939 removeImportDefault ( j , source , defaultOptions ) ;
0 commit comments