Skip to content

Commit

Permalink
fix: typescript loader config (#1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
semoal authored Apr 8, 2021
1 parent 194f9b3 commit 93afb72
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions packages/conf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,20 +552,11 @@ export function catalogMigration(
const pipe = (...functions: Array<Function>) => (args: any): any =>
functions.reduce((arg, fn) => fn(arg), args)

// copied from @EndemolShineGroup/cosmiconfig-typescript-loader
// to support sync operations
// if this PR gets merged and published, this piece of code can be thrown away
// https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader/pull/132
/** Typescript loader using just typescript API and eval(), instead of using ts-node/register which is slower */
function TypeScriptLoader(filePath: string) {
try {
require("ts-node/register")
const result = require(filePath)

return get(result, "default", result)
} catch (error) {
// Replace with logger class OR throw a more specific error
throw require("@endemolshinegroup/cosmiconfig-typescript-loader/dist/Errors/TypeScriptCompileError").fromError(
error
)
}
const tsc = require("typescript")
const fileContent = fs.readFileSync(filePath, "utf-8")
const { outputText } = tsc.transpileModule(fileContent, { compilerOptions: { module: tsc.ModuleKind.CommonJS }});
const configFileParsed = eval(outputText)
return configFileParsed
}

1 comment on commit 93afb72

@vercel
Copy link

@vercel vercel bot commented on 93afb72 Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.