Skip to content

Commit d29ac5f

Browse files
committed
Revert "internal type imports"
This reverts commit 88ab462.
1 parent 88ab462 commit d29ac5f

File tree

1 file changed

+6
-28
lines changed
  • packages/cli/src/scripts/codemod/transforms/export-maps

1 file changed

+6
-28
lines changed

packages/cli/src/scripts/codemod/transforms/export-maps/main.cts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const compatPackageName = '@ui5/webcomponents-react-compat';
1010

1111
const packageNames = [mainPackageName, basePackageName, chartsPackageName, aiPackageName, compatPackageName];
1212

13-
const internalTypes = new Set([
13+
const ignoredImportedNames = new Set([
1414
'ReducedReactNode',
1515
'ReducedReactNodeWithBoolean',
1616
'UI5WCSlotsNode',
@@ -85,6 +85,7 @@ try {
8585
console.warn(`⚠️ Could not read utils index at ${utilsIndexPath}.`, e);
8686
}
8787

88+
// Mapping functions
8889
function resolveBaseExport(importedName: string): string | undefined {
8990
const directMap: Record<string, string> = {
9091
Device: `${basePackageName}/Device`,
@@ -145,7 +146,7 @@ export default function transform(file: FileInfo, api: API): string | undefined
145146
}
146147

147148
let isDirty = false;
148-
let shouldKeepOldImport = false;
149+
149150
packageNames.forEach((pkg) => {
150151
root.find(j.ImportDeclaration, { source: { value: pkg } }).forEach((importPath) => {
151152
const specifiers = importPath.node.specifiers || [];
@@ -156,28 +157,8 @@ export default function transform(file: FileInfo, api: API): string | undefined
156157
}
157158

158159
const importedName = spec.imported.name as string;
159-
shouldKeepOldImport = false;
160-
if (internalTypes.has(importedName)) {
161-
if (pkg === mainPackageName) {
162-
const newImport = j.importDeclaration(
163-
[
164-
j.importSpecifier(
165-
j.identifier(importedName),
166-
j.identifier(spec.local && typeof spec.local.name === 'string' ? spec.local.name : importedName),
167-
),
168-
],
169-
j.literal(`${basePackageName}/dist/types/index.js`),
170-
);
171-
if ('importKind' in spec && spec.importKind === 'type') {
172-
newImport.importKind = 'type';
173-
}
174-
j(importPath).insertBefore(newImport);
175-
isDirty = true;
176-
} else {
177-
// todo: clarify if this should be included as well
178-
// If from base package, keep import as is for now
179-
shouldKeepOldImport = true;
180-
}
160+
161+
if (ignoredImportedNames.has(importedName)) {
181162
return;
182163
}
183164

@@ -221,10 +202,7 @@ export default function transform(file: FileInfo, api: API): string | undefined
221202
j(importPath).insertBefore(newImport);
222203
isDirty = true;
223204
});
224-
225-
if (!shouldKeepOldImport) {
226-
j(importPath).remove();
227-
}
205+
j(importPath).remove();
228206
});
229207
});
230208

0 commit comments

Comments
 (0)