Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function esModuleToCommonJSModule(
js: string,
target: ts.ScriptTarget
): string {
let out = ts.transpileModule(js, {
fileName: "custom.js",
compilerOptions: {
module: ts.ModuleKind.CommonJS,
esModuleInterop: true,
target,
newLine: ts.NewLineKind.LineFeed,
// Remove 'use strict' from outputs.
noImplicitUseStrict: true
}
}).outputText;
return out;
}