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

ts-import

Package Overview
Dependencies
Maintainers
1
Versions
88
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 3.0.0-beta.3 to 3.0.0-beta.4

17

dist/main.d.ts
import * as tsc from 'typescript';
export interface LoadOptions {
cache: {
dir: string;
};
transpileOptions: tsc.TranspileOptions;
compilerOptions: tsc.CompilerOptions;
}
export declare let defaultLoadOptions: {
transpileOptions: {};
compilerOptions: {
outDir: string;
downlevelIteration: boolean;
emitDecoratorMetadata: boolean;
experimentalDecorators: boolean;
module: tsc.ModuleKind;
resolveJsonModule: boolean;
rootDir: string;
skipLibCheck: boolean;
target: tsc.ScriptTarget;
};
};
export declare const load: (tsRelativePath: string, options?: Partial<LoadOptions>) => Promise<any>;
export declare const loadSync: (tsRelativePath: string, options?: Partial<LoadOptions>) => any;

@@ -7,12 +7,22 @@ "use strict";

const path = require("path");
const tsc = require("typescript");
const utils = require("./utils");
const options_defaults_1 = require("options-defaults");
exports.defaultLoadOptions = {
transpileOptions: {},
compilerOptions: {
outDir: path.resolve(__dirname, `..`, `cache`),
downlevelIteration: true,
emitDecoratorMetadata: true,
experimentalDecorators: true,
module: tsc.ModuleKind.CommonJS,
resolveJsonModule: true,
rootDir: `/`,
skipLibCheck: true,
target: tsc.ScriptTarget.ES2015,
},
};
const load = async (tsRelativePath, options) => {
var _a, _b;
const config = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options);
const cwd = process.cwd();
const cacheDir = (_b = (_a = config.cache) === null || _a === void 0 ? void 0 : _a.dir) !== null && _b !== void 0 ? _b : path.resolve(__dirname, `..`, `cache`);
const cacheDir = config.compilerOptions.outDir;
const tsPath = path.resolve(cwd, tsRelativePath);

@@ -30,6 +40,5 @@ let jsAfterCachePath = crossPlatform.getJsAfterCachePath(tsPath);

}
await compiler.compile({
compiler.compile({
tsPath,
jsPath,
transpileOptions: config.transpileOptions,
compilerOptions: config.compilerOptions,
});

@@ -41,6 +50,5 @@ const loaded = await Promise.resolve().then(() => require(jsPath));

const loadSync = (tsRelativePath, options) => {
var _a, _b;
const config = (0, options_defaults_1.defaults)(exports.defaultLoadOptions, options);
const cwd = process.cwd();
const cacheDir = (_b = (_a = config.cache) === null || _a === void 0 ? void 0 : _a.dir) !== null && _b !== void 0 ? _b : path.resolve(__dirname, `..`, `cache`);
const cacheDir = config.compilerOptions.outDir;
const tsPath = path.resolve(cwd, tsRelativePath);

@@ -60,6 +68,5 @@ let jsAfterCachePath = crossPlatform.getJsAfterCachePath(tsPath);

}
compiler.compileSync({
compiler.compile({
tsPath,
jsPath,
transpileOptions: config.transpileOptions,
compilerOptions: config.compilerOptions,
});

@@ -66,0 +73,0 @@ const loaded = require(jsPath);

import * as tsc from 'typescript';
export interface CompileOptions {
tsPath: string;
jsPath: string;
transpileOptions: tsc.TranspileOptions;
compilerOptions: tsc.CompilerOptions;
}
export declare const compile: (options: CompileOptions) => Promise<void>;
export declare const compileSync: (options: CompileOptions) => void;
export declare const compile: (options: CompileOptions) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.compileSync = exports.compile = void 0;
const fs = require("fs");
const path = require("path");
exports.compile = void 0;
const tsc = require("typescript");
const compile = async (options) => {
const ts = await fs.promises.readFile(options.tsPath);
const tsTranspiled = tsc.transpileModule(ts.toString(), options.transpileOptions);
await fs.promises.mkdir(path.dirname(options.jsPath), {
recursive: true,
const compile = (options) => {
const program = tsc.createProgram({
rootNames: [options.tsPath],
options: options.compilerOptions,
});
await fs.promises.writeFile(options.jsPath, tsTranspiled.outputText);
program.emit();
};
exports.compile = compile;
const compileSync = (options) => {
const ts = fs.readFileSync(options.tsPath);
const tsTranspiled = tsc.transpileModule(ts.toString(), options.transpileOptions);
fs.mkdirSync(path.dirname(options.jsPath), {
recursive: true,
});
fs.writeFileSync(options.jsPath, tsTranspiled.outputText);
};
exports.compileSync = compileSync;
//# sourceMappingURL=compile.js.map
{
"name": "ts-import",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "Import (compile and cache on the fly) TypeScript files dynamically with ease.",

@@ -5,0 +5,0 @@ "license": "MIT",

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