tsrun/ts/loader.ts

28 lines
1000 B
TypeScript

import * as paths from './paths.js';
import * as plugins from './plugins.js';
import type { CompilerOptions } from 'typescript';
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
compilerOptions: {
lib: ['dom'],
target: <any>'es2022', // Script Target should be a string -> 2 is for ES2015
experimentalDecorators: true,
useDefineForClassFields: false,
esModuleInterop: true,
strictNullChecks: false,
moduleResolution: <any>'nodenext',
module: <any>'nodenext',
verbatimModuleSyntax: true,
paths: plugins.smartfile.fs.toObjectSync(plugins.path.join(paths.cwd, 'tsconfig.json'))
?.compilerOptions?.paths,
} as CompilerOptions,
esm: true,
skipIgnore: true,
transpileOnly: true,
};
console.log(`tsrun is using the following options: ${JSON.stringify(defaultTsNodeOptions, null, 2)}`);
export const { resolve, load, getFormat, transformSource } = plugins.tsNode.createEsmHooks(
plugins.tsNode.register(defaultTsNodeOptions),
) as any;