@weichwarenprojekt/ts-importer
v0.1.7
Published
A library that allows you to load typescript files at runtime.
Downloads
380
Readme
Quickstart
Ts importer is a small library that allows you to load typescript files at runtime.
Installation
npm i --save-dev @weichwarenprojekt/ts-importer
Usage
The library only offers the "loadModule" function. You can simply call it like this:
import { loadModule } from "@weichwarenprojekt/ts-importer";
loadModule("/absolute/path/to/the/module.ts");
In case you have special requirements you can also override the transpileOptions for the typescript transpiler by providing the TranspileOptions as second parameter:
import { loadModule } from "@weichwarenprojekt/ts-importer";
import { ScriptTarget } from "typescript";
loadModule("/absolute/path/to/the/module.ts", {
compilerOptions: { target: ScriptTarget.ES2016, module: ModuleKind.CommonJS },
fileName: "whatever",
});