🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ts-import

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-import - npm Package Compare versions

Comparing version

to
4.0.0-beta.7

6

dist/load.interfaces.d.ts
import * as tsc from 'typescript';
declare type RecursivePartial<T> = {
type RecursivePartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];

@@ -12,2 +12,3 @@ };

allowConfigurationWithComments?: boolean;
useCache?: boolean;
transpileOptions: {

@@ -23,2 +24,3 @@ cache: {

allowConfigurationWithComments?: boolean;
useCache?: boolean;
compileOptions: {

@@ -28,3 +30,3 @@ compilerOptions: tsc.CompilerOptions;

}
export declare type LoadOptions = RecursivePartial<LoadTranspileOptions | LoadCompileOptions>;
export type LoadOptions = RecursivePartial<LoadTranspileOptions | LoadCompileOptions>;
export {};

@@ -0,0 +0,0 @@ "use strict";

@@ -5,2 +5,3 @@ import { LoadMode, LoadOptions } from './load.interfaces';

allowConfigurationWithComments: boolean;
useCache: boolean;
};

@@ -7,0 +8,0 @@ export declare const load: (tsRelativePath: string, options?: LoadOptions) => Promise<any>;

@@ -15,4 +15,6 @@ "use strict";

allowConfigurationWithComments: false,
useCache: true,
};
const load = async (tsRelativePath, options) => {
var _a, _b;
if (options === null || options === void 0 ? void 0 : options.allowConfigurationWithComments) {

@@ -30,14 +32,16 @@ const commentConfig = await commentParser.getTsImportCommentConfig(tsRelativePath);

const jsPath = path.join(cacheDir, jsAfterCachePath).replace(/\.[^/.]+$/u, `.js`);
const [tsFileExists, jsFileExists] = await Promise.all([
utils.checkIfFileExists(tsPath),
utils.checkIfFileExists(jsPath).catch(() => {
}),
]);
if (jsFileExists && !utils.isFileNewer(tsFileExists, jsFileExists)) {
const loaded = await Promise.resolve().then(() => require(jsPath));
return loaded;
if (loadConfig.useCache) {
const [tsFileExists, jsFileExists] = await Promise.all([
utils.checkIfFileExists(tsPath),
utils.checkIfFileExists(jsPath).catch(() => {
}),
]);
if (jsFileExists && !utils.isFileNewer(tsFileExists, jsFileExists)) {
const loaded = await (_a = jsPath, Promise.resolve().then(() => require(_a)));
return loaded;
}
}
await providers.load(Object.assign({ tsPath,
jsPath }, config));
const loaded = await Promise.resolve().then(() => require(jsPath));
const loaded = await (_b = jsPath, Promise.resolve().then(() => require(_b)));
return loaded;

@@ -59,13 +63,15 @@ };

const jsPath = path.join(cacheDir, jsAfterCachePath).replace(/\.[^/.]+$/u, `.js`);
const tsFileExists = utils.checkIfFileExistsSync(tsPath);
let jsFileExists;
try {
jsFileExists = utils.checkIfFileExistsSync(jsPath);
if (loadConfig.useCache) {
const tsFileExists = utils.checkIfFileExistsSync(tsPath);
let jsFileExists;
try {
jsFileExists = utils.checkIfFileExistsSync(jsPath);
}
catch (err) {
}
if (jsFileExists && !utils.isFileNewer(tsFileExists, jsFileExists)) {
const loaded = require(jsPath);
return loaded;
}
}
catch (err) {
}
if (jsFileExists && !utils.isFileNewer(tsFileExists, jsFileExists)) {
const loaded = require(jsPath);
return loaded;
}
providers.loadSync(Object.assign({ tsPath,

@@ -72,0 +78,0 @@ jsPath }, config));

export declare const getTsImportCommentConfig: (tsRelativePath: string) => Promise<any>;
export declare const getTsImportCommentConfigSync: (tsRelativePath: string) => any;
export * from './get-ts-import-comment-config';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as tsc from 'typescript';

@@ -0,0 +0,0 @@ "use strict";

export * from './compile';
export * from './transpile';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as tsc from 'typescript';

@@ -0,0 +0,0 @@ "use strict";

export declare const getJsAfterCachePath: (tsPath: string) => string;
export * from './get-js-after-cache-path';

@@ -0,0 +0,0 @@ "use strict";

import { LoadCompileOptions } from '../../load.interfaces';
export declare const getCacheDir: (options: LoadCompileOptions[`compileOptions`]) => string | undefined;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as tsc from 'typescript';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export * from './get-cache-dir';

@@ -0,0 +0,0 @@ "use strict";

import * as compiler from '../../modules/compiler';
export declare const loadSync: (options: compiler.CompileOptions) => void;

@@ -0,0 +0,0 @@ "use strict";

import * as compiler from '../../modules/compiler';
export declare const load: (options: compiler.CompileOptions) => Promise<void>;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as compiler from '../modules/compiler';

@@ -0,0 +0,0 @@ "use strict";

import { LoadTranspileOptions } from '../../load.interfaces';
export declare const getCacheDir: (options: LoadTranspileOptions[`transpileOptions`]) => string;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { LoadOptions } from '../../load.interfaces';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export * from './get-cache-dir';

@@ -0,0 +0,0 @@ "use strict";

import * as compiler from '../../modules/compiler';
export declare const loadSync: (options: compiler.TranspileOptions) => void;

@@ -0,0 +0,0 @@ "use strict";

import * as compiler from '../../modules/compiler';
export declare const load: (options: compiler.TranspileOptions) => Promise<void>;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ /// <reference types="node" />

@@ -0,0 +0,0 @@ "use strict";

export * from './check-if-file-exists';
export * from './is-file-newer';

@@ -0,0 +0,0 @@ "use strict";

import * as fs from 'fs';
export declare const isFileNewer: (file1: fs.Stats, file2: fs.Stats) => boolean;

@@ -0,0 +0,0 @@ "use strict";

{
"name": "ts-import",
"version": "4.0.0-beta.6",
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.",
"license": "MIT",
"keywords": [
"compile",
"dynamic",
"import",
"require",
"typescript"
],
"files": [
"dist"
],
"author": "Artur Kurowski <radarsu@gmail.com>",
"homepage": "https://github.com/radarsu/ts-import#readme",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"dependencies": {
"comment-parser": "1.3.1",
"options-defaults": "2.0.40",
"tslib": "2.4.0"
},
"devDependencies": {
"@radrat-scripts/package": "2.0.46",
"@radrat/cli": "3.0.0-beta.5",
"@types/jest": "28.1.4",
"@types/node": "16.11.42",
"jest": "28.1.2",
"jest-cli": "28.1.2",
"ts-jest": "28.0.5"
},
"peerDependencies": {
"typescript": "4"
},
"engines": {
"node": ">=14.14.0"
},
"gitHead": "5f409f3708573a20e3ce2e5088531dcd8951df7b"
}
"name": "ts-import",
"version": "4.0.0-beta.7",
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.",
"license": "MIT",
"keywords": [
"compile",
"dynamic",
"import",
"require",
"typescript"
],
"files": [
"dist"
],
"author": "Artur Kurowski <radarsu@gmail.com>",
"homepage": "https://github.com/radarsu/ts-import#readme",
"main": "dist/main.js",
"types": "dist/main.d.ts",
"dependencies": {
"comment-parser": "1.3.1",
"options-defaults": "2.0.40",
"tslib": "2.4.1"
},
"devDependencies": {
"@jest/globals": "29.3.1",
"@radrat/cli": "3.0.0-beta.6",
"@types/jest": "29.2.3",
"@types/node": "18.11.9",
"jest": "29.3.1",
"ts-jest": "29.0.3",
"typescript": "4.9.3"
},
"peerDependencies": {
"typescript": "4"
},
"engines": {
"node": ">=14.14.0"
},
"gitHead": "5f409f3708573a20e3ce2e5088531dcd8951df7b"
}

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