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

resolve-tspaths

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-tspaths - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

12

CHANGELOG.md
## [0.6.0](https://github.com/benyap/resolve-tspaths/compare/v0.5.0...v0.6.0) (2022-05-27)
### Features
* add Typescript as a peer dependency and use it to parse tsconfig ([aa936c5](https://github.com/benyap/resolve-tspaths/commit/aa936c5f12ba5a462ab031614426fbd2b060f4a8))
### Dependencies
* bump @commitlint/cli, ts-jest, ts-node, typescript ([9a8648f](https://github.com/benyap/resolve-tspaths/commit/9a8648f24674cc17df92288beece8485d96438b7))
## [0.5.0](https://github.com/benyap/resolve-tspaths/compare/v0.4.0...v0.5.0) (2022-05-21)

@@ -4,0 +16,0 @@

2

dist/index.js

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

const programPaths = (0, resolvePaths_1.resolvePaths)({ project, src, out }, tsConfig);
const aliases = (0, computeAliases_1.computeAliases)(programPaths.basePath, (_b = (_a = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : {});
const aliases = (0, computeAliases_1.computeAliases)(programPaths.basePath, (_b = (_a = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.options) === null || _a === void 0 ? void 0 : _a.paths) !== null && _b !== void 0 ? _b : {});
const files = (0, getFilesToProcess_1.getFilesToProcess)(programPaths.outPath, ext);

@@ -32,0 +32,0 @@ const changes = (0, generateChanges_1.generateChanges)(files, aliases, programPaths);

@@ -23,7 +23,7 @@ #! /usr/bin/env node

const tsConfig = (0, loadTSConfig_1.loadTSConfig)(options.project);
const { rootDir, outDir, baseUrl, paths } = (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : {};
const { rootDir, outDir, baseUrl, paths } = (_a = tsConfig.options) !== null && _a !== void 0 ? _a : {};
logger.fancyParams("compilerOptions", { rootDir, outDir, baseUrl, paths });
const programPaths = (0, resolvePaths_1.resolvePaths)(options, tsConfig);
logger.fancyParams("programPaths", programPaths);
const aliases = (0, computeAliases_1.computeAliases)(programPaths.basePath, (_c = (_b = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {});
const aliases = (0, computeAliases_1.computeAliases)(programPaths.basePath, (_c = (_b = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.options) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {});
logger.fancyParams("aliases", aliases);

@@ -30,0 +30,0 @@ const files = (0, getFilesToProcess_1.getFilesToProcess)(programPaths.outPath, options.ext);

import type { TSConfig } from "../types";
/**
* Load the tsconfig file. If the file extends another tsconfig,
* it will be recursively loaded.
* Load the tsconfig file using Typescript's built-in config file loader.
*
* @param basePath The path to the tsconfig file.
* @param path The path to the tsconfig file.
*/
export declare function loadTSConfig(basePath: string): TSConfig;
export declare function loadTSConfig(path: string): TSConfig;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadTSConfig = void 0;
const path_1 = require("path");
const load_1 = require("../utils/load");
const typescript_1 = require("typescript");
const errors_1 = require("../utils/errors");
/**
* Load the tsconfig file. If the file extends another tsconfig,
* it will be recursively loaded.
* Load the tsconfig file using Typescript's built-in config file loader.
*
* @param basePath The path to the tsconfig file.
* @param path The path to the tsconfig file.
*/
function loadTSConfig(basePath) {
const baseConfig = (0, load_1.loadJSON)(basePath, "loadTSConfig");
if (!baseConfig.extends)
return baseConfig;
const parentPath = (0, path_1.resolve)((0, path_1.dirname)(basePath), baseConfig.extends);
const parentConfig = loadTSConfig(parentPath);
const parentCompilerOptions = parentConfig.compilerOptions;
const baseCompilerOptions = baseConfig.compilerOptions;
let tsConfig = Object.assign(Object.assign(Object.assign({}, parentConfig), baseConfig), { compilerOptions: Object.assign(Object.assign({}, parentCompilerOptions), baseCompilerOptions) });
const parentPaths = parentCompilerOptions === null || parentCompilerOptions === void 0 ? void 0 : parentCompilerOptions.paths;
const basePaths = baseCompilerOptions === null || baseCompilerOptions === void 0 ? void 0 : baseCompilerOptions.paths;
// If paths from the parent are not overwritten,
// ensure they are resolved relative to the parent
if (parentPaths && !basePaths) {
const baseUrl = parentCompilerOptions === null || parentCompilerOptions === void 0 ? void 0 : parentCompilerOptions.baseUrl;
if (!baseUrl)
throw new errors_1.TSConfigPropertyError("loadTSConfig", "extends > compilerOptions.baseUrl");
tsConfig.compilerOptions.paths = Object.keys(parentPaths).reduce((map, key) => {
map[key] = parentPaths[key].map((path) => (0, path_1.relative)((0, path_1.dirname)(basePath), (0, path_1.join)((0, path_1.dirname)(parentPath), baseUrl, path)));
return map;
}, {});
}
// Remove fields that should not be merged
// See https://www.typescriptlang.org/tsconfig#extends
delete tsConfig.extends;
delete tsConfig.references;
return tsConfig;
function loadTSConfig(path) {
const configFileName = (0, typescript_1.findConfigFile)(process.cwd(), typescript_1.sys.fileExists, path);
if (!configFileName)
throw new errors_1.FileNotFoundError("loadTSConfig", path);
const configFile = (0, typescript_1.readConfigFile)(configFileName, typescript_1.sys.readFile);
const options = (0, typescript_1.parseJsonConfigFileContent)(configFile.config, typescript_1.sys, ".");
return options;
}
exports.loadTSConfig = loadTSConfig;

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

var _a, _b, _c, _d, _e;
const { baseUrl, outDir, paths } = (_a = tsConfig.compilerOptions) !== null && _a !== void 0 ? _a : {};
const { baseUrl, outDir, paths } = (_a = tsConfig.options) !== null && _a !== void 0 ? _a : {};
const out = (_b = options.out) !== null && _b !== void 0 ? _b : outDir;

@@ -24,3 +24,3 @@ if (!out) {

const basePath = (0, path_1.resolve)(configPath, baseUrl);
const srcPath = (0, path_1.resolve)((_e = (_c = options.src) !== null && _c !== void 0 ? _c : (_d = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.compilerOptions) === null || _d === void 0 ? void 0 : _d.rootDir) !== null && _e !== void 0 ? _e : "src");
const srcPath = (0, path_1.resolve)((_e = (_c = options.src) !== null && _c !== void 0 ? _c : (_d = tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.options) === null || _d === void 0 ? void 0 : _d.rootDir) !== null && _e !== void 0 ? _e : "src");
const outPath = (0, path_1.resolve)(out);

@@ -27,0 +27,0 @@ return { basePath, configPath, configFile, srcPath, outPath };

@@ -1,14 +0,4 @@

export interface TSConfig {
extends?: string;
compilerOptions?: TSConfigCompilerOptions;
[key: string]: any;
}
export interface TSConfigCompilerOptions {
baseUrl?: string;
outDir?: string;
rootDir?: string;
paths?: {
[key: string]: string[];
};
}
import type { CompilerOptions, ParsedCommandLine } from "typescript";
export declare type TSConfig = ParsedCommandLine;
export declare type TSConfigCompilerOptions = CompilerOptions;
export interface ProgramOptions {

@@ -15,0 +5,0 @@ /**

{
"version": "0.5.0"
"version": "0.6.0"
}
{
"name": "resolve-tspaths",
"version": "0.5.0",
"version": "0.6.0",
"description": "Transform path mappings in your compiled Typescript code",

@@ -42,3 +42,3 @@ "author": "Ben Yap <contact@benyap.com>",

"dev": "ts-node -r tsconfig-paths/register src/main.ts",
"start": "node dist/main.js",
"start": "node --trace-uncaught dist/main.js",
"test": "jest",

@@ -49,10 +49,12 @@ "test:coverage": "jest --coverage",

},
"peerDependencies": {
"typescript": ">=3.0.3"
},
"dependencies": {
"ansi-colors": "4.1.3",
"commander": "9.2.0",
"fast-glob": "3.2.11",
"jsonc-parser": "3.0.0"
"fast-glob": "3.2.11"
},
"devDependencies": {
"@commitlint/cli": "17.0.0",
"@commitlint/cli": "17.0.1",
"@commitlint/config-conventional": "17.0.0",

@@ -68,7 +70,7 @@ "@release-it/bumper": "4.0.0",

"release-it": "15.0.0",
"ts-jest": "28.0.2",
"ts-node": "10.7.0",
"ts-jest": "28.0.3",
"ts-node": "10.8.0",
"tsconfig-paths": "4.0.0",
"typescript": "4.6.4"
"typescript": "4.7.2"
}
}

@@ -71,10 +71,11 @@ # resolve-tspaths

1. Install as a dev dependency using npm or yarn.
1. Install as a dev dependency using npm or yarn, along with
[Typescript](https://www.npmjs.com/package/typescript) 3.x or later.
```sh
yarn add -D resolve-tspaths
yarn add -D resolve-tspaths typescript
```
```sh
npm install --save-dev resolve-tspaths
npm install --save-dev resolve-tspaths typescript
```

@@ -94,10 +95,11 @@

1. Install as a dev dependency using npm or yarn.
1. Install as a dev dependency using npm or yarn, along with
[Typescript](https://www.npmjs.com/package/typescript) 3.x or later.
```sh
yarn add -D resolve-tspaths
yarn add -D resolve-tspaths typescript
```
```sh
npm install --save-dev resolve-tspaths
npm install --save-dev resolve-tspaths typescript
```

@@ -104,0 +106,0 @@

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