Allow 'verbatimModuleSyntax' with transpileModule (#53240)

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
Ron Buckton
2023-03-14 16:03:43 -04:00
committed by GitHub
parent 2378c0b65e
commit ae1b3db8ce
280 changed files with 1437 additions and 73 deletions

View File

@@ -43,6 +43,12 @@ export interface TranspileOutput {
sourceMapText?: string;
}
const optionsRedundantWithVerbatimModuleSyntax = new Set([
"isolatedModules",
"preserveValueImports",
"importsNotUsedAsValues"
]);
/*
* This function will compile source text from 'input' argument using specified compiler options.
* If not options are provided - it will use a set of default compiler options.
@@ -66,6 +72,11 @@ export function transpileModule(input: string, transpileOptions: TranspileOption
}
for (const option of transpileOptionValueCompilerOptions) {
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
if (options.verbatimModuleSyntax && optionsRedundantWithVerbatimModuleSyntax.has(option.name)) {
continue;
}
options[option.name] = option.transpileOptionValue;
}