@eliasku/ts-transformers 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +24 -17
- package/src/types.ts +5 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -51,24 +51,27 @@ function createTransformerFactory(
|
|
|
51
51
|
if (inlined) return inlined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (
|
|
57
|
-
|
|
54
|
+
// don't remove any imports
|
|
55
|
+
if (fullOptions.keepConstEnumEmptyDeclaration !== true) {
|
|
56
|
+
if (ts.isImportSpecifier(node)) {
|
|
57
|
+
const removed = tryRemoveConstEnumImport(node);
|
|
58
|
+
if (removed === undefined || node.isTypeOnly) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
58
61
|
}
|
|
59
|
-
}
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (ts.isExportSpecifier(node)) {
|
|
64
|
+
const removed = tryRemoveConstEnumExport(node);
|
|
65
|
+
if (removed === undefined || node.isTypeOnly) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
65
68
|
}
|
|
66
|
-
}
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (ts.isImportClause(node)) {
|
|
71
|
+
const removed = tryRemoveConstEnumImportClause(node);
|
|
72
|
+
if (removed === undefined) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
77
|
}
|
|
@@ -709,16 +712,20 @@ function createTransformerFactory(
|
|
|
709
712
|
node.members,
|
|
710
713
|
);
|
|
711
714
|
}
|
|
715
|
+
|
|
716
|
+
if (fullOptions.keepConstEnumEmptyDeclaration === true) {
|
|
717
|
+
return ts.factory.updateEnumDeclaration(node, node.modifiers, node.name, []);
|
|
718
|
+
}
|
|
712
719
|
return undefined;
|
|
713
720
|
}
|
|
714
721
|
|
|
715
722
|
function wrapTransformNode(node: ts.Node): ts.Node | undefined {
|
|
716
723
|
if (ts.isEnumDeclaration(node)) {
|
|
717
724
|
const result = handleEnumDeclaration(node);
|
|
718
|
-
if (result === undefined) {
|
|
719
|
-
return undefined;
|
|
720
|
-
}
|
|
721
725
|
if (result !== node) {
|
|
726
|
+
if (result) {
|
|
727
|
+
return transformNode(result);
|
|
728
|
+
}
|
|
722
729
|
return result;
|
|
723
730
|
}
|
|
724
731
|
}
|
package/src/types.ts
CHANGED
|
@@ -32,6 +32,11 @@ export interface OptimizerOptions {
|
|
|
32
32
|
* Whether to inline const enum values.
|
|
33
33
|
*/
|
|
34
34
|
inlineConstEnums?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Keep empty const enum declarations, keep imports / exports
|
|
38
|
+
*/
|
|
39
|
+
keepConstEnumEmptyDeclaration?: boolean;
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
export const enum VisibilityType {
|