@@ -68,7 +68,7 @@ export async function transformWithOxc(
68
68
ensureWatchedFile ( watcher , tsconfigFile , config . root )
69
69
}
70
70
const loadedCompilerOptions = loadedTsconfig . compilerOptions ?? { }
71
- // tsc compiler alwaysStrict/ experimentalDecorators/importsNotUsedAsValues/preserveValueImports/ target/useDefineForClassFields/verbatimModuleSyntax
71
+ // tsc compiler experimentalDecorators/target/useDefineForClassFields
72
72
73
73
resolvedOptions . jsx ??= { }
74
74
if ( loadedCompilerOptions . jsxFactory ) {
@@ -99,6 +99,47 @@ export async function transformWithOxc(
99
99
default :
100
100
break
101
101
}
102
+
103
+ /**
104
+ * | preserveValueImports | importsNotUsedAsValues | verbatimModuleSyntax | onlyRemoveTypeImports |
105
+ * | -------------------- | ---------------------- | -------------------- |---------------------- |
106
+ * | false | remove | false | false |
107
+ * | false | preserve, error | - | - |
108
+ * | true | remove | - | - |
109
+ * | true | preserve, error | true | true |
110
+ */
111
+ if ( loadedCompilerOptions . verbatimModuleSyntax !== undefined ) {
112
+ resolvedOptions . typescript ??= { }
113
+ resolvedOptions . typescript . onlyRemoveTypeImports =
114
+ loadedCompilerOptions . verbatimModuleSyntax
115
+ } else if (
116
+ loadedCompilerOptions . preserveValueImports !== undefined ||
117
+ loadedCompilerOptions . importsNotUsedAsValues !== undefined
118
+ ) {
119
+ const preserveValueImports =
120
+ loadedCompilerOptions . preserveValueImports ?? false
121
+ const importsNotUsedAsValues =
122
+ loadedCompilerOptions . importsNotUsedAsValues ?? 'remove'
123
+ if (
124
+ preserveValueImports === false &&
125
+ importsNotUsedAsValues === 'remove'
126
+ ) {
127
+ resolvedOptions . typescript ??= { }
128
+ resolvedOptions . typescript . onlyRemoveTypeImports = true
129
+ } else if (
130
+ preserveValueImports === true &&
131
+ ( importsNotUsedAsValues === 'preserve' ||
132
+ importsNotUsedAsValues === 'error' )
133
+ ) {
134
+ resolvedOptions . typescript ??= { }
135
+ resolvedOptions . typescript . onlyRemoveTypeImports = false
136
+ } else {
137
+ ctx . warn (
138
+ `preserveValueImports=${ preserveValueImports } + importsNotUsedAsValues=${ importsNotUsedAsValues } is not supported by oxc.` +
139
+ 'Please migrate to the new verbatimModuleSyntax option.' ,
140
+ )
141
+ }
142
+ }
102
143
} catch ( e ) {
103
144
if ( e instanceof TSConfckParseError ) {
104
145
// tsconfig could be out of root, make sure it is watched on dev
0 commit comments