MCPcopy
hub / github.com/TypeStrong/ts-node / initializeTranspilerFactory

Function initializeTranspilerFactory

src/index.ts:759–799  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

757 }
758 let createTranspiler = initializeTranspilerFactory();
759 function initializeTranspilerFactory() {
760 if (transpiler) {
761 if (!transpileOnly)
762 throw new Error(
763 'Custom transpiler can only be used when transpileOnly is enabled.'
764 );
765 const transpilerName =
766 typeof transpiler === 'string' ? transpiler : transpiler[0];
767 const transpilerOptions =
768 typeof transpiler === 'string' ? {} : transpiler[1] ?? {};
769 const transpilerConfigLocalResolveHelper = transpilerBasePath
770 ? createProjectLocalResolveHelper(transpilerBasePath)
771 : projectLocalResolveHelper;
772 const transpilerPath = transpilerConfigLocalResolveHelper(
773 transpilerName,
774 true
775 );
776 const transpilerFactory = require(transpilerPath)
777 .create as TranspilerFactory;
778 return createTranspiler;
779
780 function createTranspiler(
781 compilerOptions: TSCommon.CompilerOptions,
782 nodeModuleEmitKind?: NodeModuleEmitKind
783 ) {
784 return transpilerFactory?.({
785 service: {
786 options,
787 config: {
788 ...config,
789 options: compilerOptions,
790 },
791 projectLocalResolveHelper,
792 },
793 transpilerConfigLocalResolveHelper,
794 nodeModuleEmitKind,
795 ...transpilerOptions,
796 });
797 }
798 }
799 }
800
801 /**
802 * True if require() hooks should interop with experimental ESM loader.

Callers 1

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…