Socket
Socket
Sign inDemoInstall

tsconfig-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsconfig-loader - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

src/__tests__/fixtures/tsconfig-with-extends-npm/tsconfig.json

16

lib/index.js

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

const StripBom = require("strip-bom");
const resolve_1 = require("resolve");
function loadTsconfig({ filename = process.env.TS_NODE_PROJECT, cwd = process.cwd(), } = {}) {

@@ -66,7 +67,12 @@ const configPath = resolveConfigPath(cwd, filename);

if (extendedConfig) {
if (extendedConfig.indexOf('.json') === -1) {
extendedConfig += '.json';
}
const currentDir = path.dirname(configFilePath);
const base = loadTsconfigFile(path.join(currentDir, extendedConfig)) || {};
extendedConfig = resolve_1.sync(extendedConfig, {
basedir: currentDir,
extensions: ['.json'],
packageFilter: (pkg) => {
pkg.main = 'tsconfig.json';
return pkg;
},
});
const base = loadTsconfigFile(extendedConfig) || {};
// baseUrl should be interpreted as relative to the base tsconfig,

@@ -76,3 +82,3 @@ // but we need to update it so it is relative to the original tsconfig being loaded

const extendsDir = path.dirname(extendedConfig);
base.compilerOptions.baseUrl = path.join(extendsDir, base.compilerOptions.baseUrl);
base.compilerOptions.baseUrl = path.relative(path.dirname(configFilePath), path.join(extendsDir, base.compilerOptions.baseUrl));
}

@@ -79,0 +85,0 @@ return deepmerge(base, config);

@@ -24,2 +24,3 @@ {

"json5": "^2.1.1",
"resolve": "^1.15.1",
"strip-bom": "^4.0.0"

@@ -32,2 +33,3 @@ },

"@types/node": "^13.7.7",
"@types/resolve": "^1.14.0",
"husky": "^3.0.8",

@@ -79,3 +81,3 @@ "jest": "^24.9.0",

},
"version": "1.0.0"
"version": "1.1.0"
}

@@ -91,2 +91,10 @@ import {readFileSync} from 'fs';

});
it('should extend npm packages', () => {
const result = loadTsconfig({
cwd: `${__dirname}/fixtures/tsconfig-with-extends-npm`,
});
expect(result?.tsConfig.compilerOptions).toEqual(
require('@forbeslindesay/tsconfig/tsconfig.json').compilerOptions,
);
});
});

@@ -8,2 +8,3 @@ // Extracted & adapted from https://github.com/dividab/tsconfig-paths/blob/6da68cbec7f11aa84ec7aeb14732d9edcdb82b68/src/tsconfig-loader.ts

import StripBom = require('strip-bom');
import {sync as resolve} from 'resolve';
import {JSONSchemaForTheTypeScriptCompilerSConfigurationFile} from './tsconfig';

@@ -88,8 +89,12 @@

if (extendedConfig) {
if (extendedConfig.indexOf('.json') === -1) {
extendedConfig += '.json';
}
const currentDir = path.dirname(configFilePath);
const base = loadTsconfigFile(path.join(currentDir, extendedConfig)) || {};
extendedConfig = resolve(extendedConfig, {
basedir: currentDir,
extensions: ['.json'],
packageFilter: (pkg) => {
pkg.main = 'tsconfig.json';
return pkg;
},
});
const base = loadTsconfigFile(extendedConfig) || {};

@@ -100,5 +105,5 @@ // baseUrl should be interpreted as relative to the base tsconfig,

const extendsDir = path.dirname(extendedConfig);
base.compilerOptions.baseUrl = path.join(
extendsDir,
base.compilerOptions.baseUrl,
base.compilerOptions.baseUrl = path.relative(
path.dirname(configFilePath),
path.join(extendsDir, base.compilerOptions.baseUrl),
);

@@ -105,0 +110,0 @@ }

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