Tsonic GitHub
Edit on GitHub

Importing Modules

Importing from @tsonic/nodejs/index.js

Most Node-style modules are exported as named values from the package root entry point:

import { console, fs, path, process, crypto } from "@tsonic/nodejs/index.js";

Types that are part of those modules are also exported from the root entry point:

import { EventEmitter } from "@tsonic/nodejs/index.js";

Importing submodules (namespaces)

Some namespaces are emitted as separate entry points. For example, HTTP lives in the nodejs.Http namespace:

import { http, IncomingMessage, ServerResponse } from "@tsonic/nodejs/nodejs.Http.js";

Do not import Node builtins ("fs", "path", ...)

Tsonic projects compile to .NET and do not run on Node.js. You should not write:

// ❌ Not supported
import * as fs from "fs";
import * as path from "path";

Instead import from @tsonic/nodejs/index.js:

// ✅ Supported
import { fs, path } from "@tsonic/nodejs/index.js";