Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-patch

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-patch

Patch typescript to support custom transformers in tsconfig.json

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
decreased by-49.99%
Maintainers
1
Weekly downloads
 
Created

What is ts-patch?

ts-patch is a tool that allows you to patch the TypeScript compiler (tsc) to enable custom transformers and other advanced features. It is particularly useful for developers who need to extend the capabilities of TypeScript beyond what is natively supported.

What are ts-patch's main functionalities?

Custom Transformers

This feature allows you to apply custom transformers to the TypeScript compiler. By patching the compiler, you can specify custom transformers in your tsconfig.json file, enabling advanced code transformations during the compilation process.

const { patch, unpatch } = require('ts-patch');

// Apply the patch
patch();

// Now you can use custom transformers in your tsconfig.json
// tsconfig.json
{
  "compilerOptions": {
    "plugins": [
      { "transform": "./path/to/your/transformer" }
    ]
  }
}

// Unpatch when done
unpatch();

Advanced Compiler Options

This feature allows you to enable advanced compiler options that are not natively supported by TypeScript. By patching the compiler, you can use options like experimental decorators and emit decorator metadata.

const { patch, unpatch } = require('ts-patch');

// Apply the patch
patch();

// Now you can use advanced compiler options in your tsconfig.json
// tsconfig.json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

// Unpatch when done
unpatch();

Integration with Build Tools

This feature allows you to integrate ts-patch with various build tools like Webpack. By patching the TypeScript compiler, you can use custom transformers and advanced compiler options in your build process.

const { patch, unpatch } = require('ts-patch');

// Apply the patch
patch();

// Now you can integrate ts-patch with build tools like Webpack
// webpack.config.js
const path = require('path');

module.exports = {
  entry: './src/index.ts',
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: 'ts-loader',
        exclude: /node_modules/
      }
    ]
  },
  resolve: {
    extensions: ['.tsx', '.ts', '.js']
  },
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  }
};

// Unpatch when done
unpatch();

Other packages similar to ts-patch

Keywords

FAQs

Package last updated on 31 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc