Skip to content

Commit 93afb72

Browse files
authored
fix: typescript loader config (#1029)
1 parent 194f9b3 commit 93afb72

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

packages/conf/src/index.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -552,20 +552,11 @@ export function catalogMigration(
552552
const pipe = (...functions: Array<Function>) => (args: any): any =>
553553
functions.reduce((arg, fn) => fn(arg), args)
554554

555-
// copied from @EndemolShineGroup/cosmiconfig-typescript-loader
556-
// to support sync operations
557-
// if this PR gets merged and published, this piece of code can be thrown away
558-
// https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader/pull/132
555+
/** Typescript loader using just typescript API and eval(), instead of using ts-node/register which is slower */
559556
function TypeScriptLoader(filePath: string) {
560-
try {
561-
require("ts-node/register")
562-
const result = require(filePath)
563-
564-
return get(result, "default", result)
565-
} catch (error) {
566-
// Replace with logger class OR throw a more specific error
567-
throw require("@endemolshinegroup/cosmiconfig-typescript-loader/dist/Errors/TypeScriptCompileError").fromError(
568-
error
569-
)
570-
}
557+
const tsc = require("typescript")
558+
const fileContent = fs.readFileSync(filePath, "utf-8")
559+
const { outputText } = tsc.transpileModule(fileContent, { compilerOptions: { module: tsc.ModuleKind.CommonJS }});
560+
const configFileParsed = eval(outputText)
561+
return configFileParsed
571562
}

0 commit comments

Comments
 (0)