or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mdconfiguration.mdcore-service.mdesm.mdindex.mdregister.mdrepl.mdtranspilers.md
tile.json

register.mddocs/

Register Entry Points

Convenient entry points for different registration modes, designed for use with Node.js --require flag and programmatic registration scenarios.

Capabilities

Default Registration

Standard ts-node registration with default configuration.

// Available as ts-node/register entry point
// Equivalent to: require('ts-node').register()

Usage Examples:

# Command line registration
node --require ts-node/register script.ts

# Environment variable
NODE_OPTIONS="--require ts-node/register" node script.ts
// Programmatic registration
require('ts-node/register');

// Now you can require .ts files directly
const myModule = require('./my-typescript-file.ts');

Transpile-Only Registration

Fast transpile-only mode that skips type checking for improved performance.

// Available as ts-node/register/transpile-only entry point
// Equivalent to: require('ts-node').register({ transpileOnly: true })

Usage Examples:

# Fast development mode
node --require ts-node/register/transpile-only script.ts

# With environment variables
TS_NODE_TRANSPILE_ONLY=true node --require ts-node/register script.ts
// Programmatic fast registration
require('ts-node/register/transpile-only');

const myModule = require('./my-typescript-file.ts');

Type-Check Registration

Explicit type checking mode that ensures full TypeScript type validation.

// Available as ts-node/register/type-check entry point
// Equivalent to: require('ts-node').register({ typeCheck: true })

Usage Examples:

# Strict type checking mode
node --require ts-node/register/type-check script.ts

# Override transpile-only environment variable
TS_NODE_TRANSPILE_ONLY=true node --require ts-node/register/type-check script.ts
// Force type checking
require('ts-node/register/type-check');

const myModule = require('./my-typescript-file.ts');

Files Registration

Registration mode that loads "files" and "include" from tsconfig.json on startup.

// Available as ts-node/register/files entry point
// Equivalent to: require('ts-node').register({ files: true })

Usage Examples:

# Include tsconfig files and include patterns
node --require ts-node/register/files script.ts
// Load all files specified in tsconfig.json
require('ts-node/register/files');

// All files in tsconfig "files" and "include" are now loaded
const myModule = require('./my-typescript-file.ts');

Registration Patterns

Environment-Based Configuration

Combine registration entry points with environment variables for flexible configuration.

# Fast development with custom compiler options
TS_NODE_COMPILER_OPTIONS='{"strict":false,"noImplicitAny":false}' \
node --require ts-node/register/transpile-only script.ts

# Debug mode with pretty output
TS_NODE_DEBUG=true TS_NODE_PRETTY=true \
node --require ts-node/register script.ts

# Custom project configuration
TS_NODE_PROJECT=./tsconfig.dev.json \
node --require ts-node/register script.ts

Multiple Registration Modes

// Conditional registration based on environment
if (process.env.NODE_ENV === 'development') {
  require('ts-node/register/transpile-only');
} else {
  require('ts-node/register/type-check');
}

Integration with Testing Frameworks

// Jest configuration
module.exports = {
  preset: 'ts-jest',
  setupFilesAfterEnv: ['ts-node/register/transpile-only'],
  testEnvironment: 'node',
};
// Mocha with ts-node
// mocha.opts or package.json test script
// --require ts-node/register test/**/*.test.ts

Package.json Scripts

{
  "scripts": {
    "dev": "node --require ts-node/register/transpile-only src/index.ts",
    "dev:debug": "TS_NODE_DEBUG=true node --require ts-node/register src/index.ts",
    "test": "node --require ts-node/register/transpile-only test/runner.ts",
    "type-check": "node --require ts-node/register/type-check src/index.ts",
    "build:check": "node --require ts-node/register/files build-script.ts"
  }
}

Advanced Registration Usage

Custom Registration Wrapper

// register-wrapper.js
const { register } = require('ts-node');

// Custom registration with project-specific defaults
register({
  transpileOnly: process.env.NODE_ENV === 'development',
  compilerOptions: {
    target: 'es2020',
    module: 'commonjs',
    strict: true,
    esModuleInterop: true,
    skipLibCheck: true,
  },
  ignore: [
    /node_modules/,  
    /\.test\.ts$/,   // Ignore test files in production
    /\.spec\.ts$/,   // Ignore spec files in production
  ],
});
# Use custom wrapper
node --require ./register-wrapper.js src/app.ts

Conditional TypeScript Processing

// conditional-register.js
const path = require('path');

// Only register ts-node for .ts files in src/ directory
const originalRequire = require.extensions['.js'];

require('ts-node/register/transpile-only');

// Override to check file path
require.extensions['.js'] = function(module, filename) {
  if (filename.includes('/src/') && filename.endsWith('.ts')) {
    return require.extensions['.ts'](module, filename);
  }
  return originalRequire(module, filename);
};

Registration with Module Path Mapping

// register-with-paths.js
const { register } = require('ts-node');
const { resolve } = require('path');

register({
  transpileOnly: true,
  compilerOptions: {
    baseUrl: resolve(__dirname),
    paths: {
      '@/*': ['src/*'],
      '@shared/*': ['shared/*'],
      '@utils/*': ['src/utils/*'],
    },
  },
});

Docker Integration

# Dockerfile
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production

COPY . .

# Use register entry point for TypeScript execution
CMD ["node", "--require", "ts-node/register/transpile-only", "src/index.ts"]

PM2 Integration

{
  "apps": [{
    "name": "my-app",
    "script": "src/index.ts",
    "node_args": "--require ts-node/register/transpile-only",
    "env": {
      "NODE_ENV": "development",
      "TS_NODE_TRANSPILE_ONLY": "true"
    },
    "env_production": {
      "NODE_ENV": "production",
      "TS_NODE_TRANSPILE_ONLY": "false"
    }
  }]
}

Register Entry Point Implementation

The register entry points are simple wrappers that call the main register function with predefined options:

// ts-node/register/index.js implementation concept
module.exports = require('../dist').register();

// ts-node/register/transpile-only.js implementation concept  
module.exports = require('../dist').register({ transpileOnly: true });

// ts-node/register/type-check.js implementation concept
module.exports = require('../dist').register({ typeCheck: true });

// ts-node/register/files.js implementation concept
module.exports = require('../dist').register({ files: true });