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 - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

## [2.1.0](https://github.com/nonara/ts-patch/compare/v2.0.2...v2.1.0) (2022-12-08)
### Features
* Updated to support TS 4.9 ([26f6099](https://github.com/nonara/ts-patch/commit/26f6099543d258a2a430f8344b482aba85ac9b0e))
### [2.0.2](https://github.com/nonara/ts-patch/compare/v2.0.1...v2.0.2) (2022-08-10)

@@ -7,0 +14,0 @@

26

lib/patcher.js

@@ -50,3 +50,3 @@ "use strict";

}
var patchModule = function (tsModule, tsPackage, source) {
var patchModuleDiagnostics = function (tsModule, tsPackage, source) {
var src = source || tsModule.moduleSrc;

@@ -84,3 +84,3 @@ var funcPos = src.search(/function emitFilesAndReportErrors\(/);

/* Add diagnostic modification support */
var moduleSrc = patchModule(tsModule, tsPackage);
var moduleSrc = patchModuleDiagnostics(tsModule, tsPackage);
try {

@@ -94,9 +94,23 @@ if (isTSC) {

.filter(function (f) { return fs_1.default.existsSync(f); })[0];
/* Get TSC-specific module slice */
var ver = tsPackage.version.split('.');
var majorVer = +ver[0];
var minorVer = +ver[1];
var tscSlice = majorVer >= 4 && minorVer >= 9
? moduleSrc.replace(/^[\s\S]+(\(function \(ts\) {\s+var StatisticType;[\s\S]+)$/, '$1')
: moduleSrc.replace(/^[\s\S]+(\(function \(ts\) {\s+function countLines[\s\S]+)$/, '$1');
var execCmdPost = tscSlice.lastIndexOf('\nts.executeCommandLine\(');
if (execCmdPost < 0)
throw new Error("Could not find tsc executeCommandLine");
var execCmd = tscSlice.slice(execCmdPost);
tscSlice = tscSlice.slice(0, execCmdPost);
/* Expand TSC with full typescript library (splice tsc part on top of typescript.ts code) */
fs_1.default.writeFileSync(file, Buffer.concat([
var content = Buffer.concat([
Buffer.from(getHeader()),
Buffer.from(patchModule(tsModule, tsPackage, fs_1.default.readFileSync(tsFile, 'utf-8'))),
Buffer.from(patchModuleDiagnostics(tsModule, tsPackage, fs_1.default.readFileSync(tsFile, 'utf-8'))),
Buffer.from(!(0, file_utils_1.getTSModule)(tsFile).patchVersion ? patchSrc : ''),
Buffer.from(moduleSrc.replace(/^[\s\S]+(\(function \(ts\) {\s+function countLines[\s\S]+)$/, '$1'))
]));
Buffer.from(tscSlice),
Buffer.from(execCmd)
]);
fs_1.default.writeFileSync(file, content);
}

@@ -103,0 +117,0 @@ else

@@ -17,3 +17,3 @@ /**

*/
export declare const getKeys: <T>(obj: T) => (keyof T)[];
export declare const getKeys: <T extends object>(obj: T) => (keyof T)[];
declare type GetDescriptorType<T extends PropertyDescriptor & {

@@ -20,0 +20,0 @@ initializer?: (...args: any[]) => any;

{
"name": "ts-patch",
"version": "2.0.2",
"version": "2.1.0",
"description": "Patch typescript to support custom transformers in tsconfig.json",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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