Socket
Socket
Sign inDemoInstall

tsickle

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsickle - npm Package Compare versions

Comparing version 0.21.1 to 0.21.2

1

build/definitions/tsickle_compiler_host.d.ts

@@ -113,2 +113,3 @@ import { SourceMapConsumer, SourceMapGenerator } from 'source-map';

combineSourceMaps(filePath: string, tscSourceMapText: string): string;
combineInlineSourceMaps(filePath: string, compiledJsWithInlineSourceMap: string): string;
convertCommonJsToGoogModule(fileName: string, content: string): string;

@@ -115,0 +116,0 @@ private downlevelDecorators(sourceFile, program, fileName, languageVersion);

@@ -31,2 +31,3 @@ /**

export declare function formatDiagnostics(diags: ts.Diagnostic[]): string;
export declare function isDtsFileName(fileName: string): boolean;
export declare function annotate(program: ts.Program, file: ts.SourceFile, options?: Options, host?: ts.ModuleResolutionHost, tsOpts?: ts.CompilerOptions): Output;

3

build/definitions/util.d.ts

@@ -1,2 +0,1 @@

import * as ts from 'typescript';
/**

@@ -9,2 +8,3 @@ * @license

*/
import * as ts from 'typescript';
export declare function toArray<T>(iterator: Iterator<T>): T[];

@@ -25,1 +25,2 @@ /**

export declare function createOutputRetainingCompilerHost(outputFiles: Map<string, string>, delegate: ts.CompilerHost): ts.CompilerHost;
export declare function extractInlineSourceMap(source: string): string;

@@ -9,2 +9,3 @@ "use strict";

var tsickle_1 = require("./tsickle");
var util_1 = require("./util");
/**

@@ -73,6 +74,8 @@ * Tsickle can perform 2 different precompilation transforms - decorator downleveling

if (path.extname(fileName) !== '.map') {
fileName = this.delegate.getCanonicalFileName(fileName);
if (this.options.googmodule && !fileName.match(/\.d\.ts$/)) {
if (this.options.googmodule && !tsickle_1.isDtsFileName(fileName)) {
content = this.convertCommonJsToGoogModule(fileName, content);
}
if (!tsickle_1.isDtsFileName(fileName) && this.tscOptions.inlineSourceMap) {
content = this.combineInlineSourceMaps(fileName, content);
}
}

@@ -132,2 +135,8 @@ else {

};
TsickleCompilerHost.prototype.combineInlineSourceMaps = function (filePath, compiledJsWithInlineSourceMap) {
var sourceMapJson = util_1.extractInlineSourceMap(compiledJsWithInlineSourceMap);
var composedSourceMap = this.combineSourceMaps(filePath, sourceMapJson);
var encodedSourceMap = Buffer.from(composedSourceMap, 'utf8').toString('base64');
return compiledJsWithInlineSourceMap.replace(new RegExp('^//# sourceMappingURL=data:application/json;base64,(.*)$', 'm'), "//# sourceMappingURL=data:application/json;base64," + encodedSourceMap);
};
TsickleCompilerHost.prototype.convertCommonJsToGoogModule = function (fileName, content) {

@@ -164,3 +173,3 @@ var moduleId = this.environment.fileNameToModuleId(fileName);

this.tsickleSourceMaps.set(this.getCanonicalFileName(sourceFile.path), new source_map_1.SourceMapGenerator());
var isDefinitions = /\.d\.ts$/.test(fileName);
var isDefinitions = tsickle_1.isDtsFileName(fileName);
// Don't tsickle-process any d.ts that isn't a compilation target;

@@ -167,0 +176,0 @@ // this means we don't process e.g. lib.d.ts.

@@ -87,2 +87,3 @@ /**

}
exports.isDtsFileName = isDtsFileName;
/** Returns the Closure name of a function parameter, special-casing destructuring. */

@@ -89,0 +90,0 @@ function getParameterName(param, index) {

@@ -1,3 +0,1 @@

"use strict";
var ts = require("typescript");
/**

@@ -10,5 +8,7 @@ * @license

*/
"use strict";
// toArray is a temporary function to help in the use of
// ES6 maps and sets when running on node 4, which doesn't
// support Iterators completely.
var ts = require("typescript");
function toArray(iterator) {

@@ -83,3 +83,10 @@ var array = [];

exports.createOutputRetainingCompilerHost = createOutputRetainingCompilerHost;
function extractInlineSourceMap(source) {
var regex = new RegExp('^//# sourceMappingURL=data:application/json;base64,(.*)$', 'm');
var result = regex.exec(source);
var base64EncodedMap = result[1];
return Buffer.from(base64EncodedMap, 'base64').toString('utf8');
}
exports.extractInlineSourceMap = extractInlineSourceMap;
//# sourceMappingURL=util.js.map
{
"name": "tsickle",
"version": "0.21.1",
"version": "0.21.2",
"description": "Transpile TypeScript code to JavaScript with Closure annotations.",

@@ -5,0 +5,0 @@ "main": "build/src/tsickle.js",

@@ -8,3 +8,4 @@ import * as path from 'path';

import {ModulesManifest} from './modules_manifest';
import {annotate} from './tsickle';
import {annotate, isDtsFileName} from './tsickle';
import {extractInlineSourceMap} from './util';

@@ -144,6 +145,8 @@ /**

if (path.extname(fileName) !== '.map') {
fileName = this.delegate.getCanonicalFileName(fileName);
if (this.options.googmodule && !fileName.match(/\.d\.ts$/)) {
if (this.options.googmodule && !isDtsFileName(fileName)) {
content = this.convertCommonJsToGoogModule(fileName, content);
}
if (!isDtsFileName(fileName) && this.tscOptions.inlineSourceMap) {
content = this.combineInlineSourceMaps(fileName, content);
}
} else {

@@ -214,2 +217,11 @@ content = this.combineSourceMaps(fileName, content);

combineInlineSourceMaps(filePath: string, compiledJsWithInlineSourceMap: string): string {
const sourceMapJson = extractInlineSourceMap(compiledJsWithInlineSourceMap);
const composedSourceMap = this.combineSourceMaps(filePath, sourceMapJson);
const encodedSourceMap = Buffer.from(composedSourceMap, 'utf8').toString('base64');
return compiledJsWithInlineSourceMap.replace(
new RegExp('^//# sourceMappingURL=data:application/json;base64,(.*)$', 'm'),
`//# sourceMappingURL=data:application/json;base64,${encodedSourceMap}`);
}
convertCommonJsToGoogModule(fileName: string, content: string): string {

@@ -257,3 +269,3 @@ const moduleId = this.environment.fileNameToModuleId(fileName);

this.getCanonicalFileName(sourceFile.path), new SourceMapGenerator());
let isDefinitions = /\.d\.ts$/.test(fileName);
let isDefinitions = isDtsFileName(fileName);
// Don't tsickle-process any d.ts that isn't a compilation target;

@@ -260,0 +272,0 @@ // this means we don't process e.g. lib.d.ts.

@@ -93,3 +93,3 @@ /**

function isDtsFileName(fileName: string): boolean {
export function isDtsFileName(fileName: string): boolean {
return /\.d\.ts$/.test(fileName);

@@ -96,0 +96,0 @@ }

@@ -1,3 +0,1 @@

import * as ts from 'typescript';
/**

@@ -15,2 +13,4 @@ * @license

import * as ts from 'typescript';
export function toArray<T>(iterator: Iterator<T>): T[] {

@@ -92,1 +92,8 @@ const array: T[] = [];

}
export function extractInlineSourceMap(source: string): string {
const regex = new RegExp('^//# sourceMappingURL=data:application/json;base64,(.*)$', 'm');
const result = regex.exec(source)!;
const base64EncodedMap = result[1];
return Buffer.from(base64EncodedMap, 'base64').toString('utf8');
}

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