unimported
Advanced tools
Comparing version 1.12.1 to 1.13.0
@@ -6,2 +6,5 @@ import { CompilerOptions } from 'typescript'; | ||
} | ||
export interface JsConfig { | ||
compilerOptions: CompilerOptions; | ||
} | ||
export interface PackageJson { | ||
@@ -8,0 +11,0 @@ name: string; |
@@ -50,14 +50,17 @@ "use strict"; | ||
function getAliases(projectPath) { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const [packageJson, tsconfig] = yield Promise.all([ | ||
const [packageJson, tsconfig, jsconfig] = yield Promise.all([ | ||
fs.readJson('package.json', projectPath), | ||
fs.readJson('tsconfig.json', projectPath), | ||
fs.readJson('jsconfig.json', projectPath), | ||
]); | ||
const config = yield config_1.getConfig(); | ||
let aliases = {}; | ||
const baseUrl = (_e = (_c = (_a = config === null || config === void 0 ? void 0 : config.rootDir) !== null && _a !== void 0 ? _a : (_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.baseUrl) !== null && _c !== void 0 ? _c : (_d = jsconfig === null || jsconfig === void 0 ? void 0 : jsconfig.compilerOptions) === null || _d === void 0 ? void 0 : _d.baseUrl) !== null && _e !== void 0 ? _e : '.'; | ||
const root = path_1.join(projectPath, baseUrl); | ||
// add support for (meteor) root slash import | ||
aliases['/'] = [`${projectPath}/`]; | ||
aliases['/'] = [`${root}/`]; | ||
// add support for mono-repos | ||
if ((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.repository) === null || _a === void 0 ? void 0 : _a.directory) { | ||
if ((_f = packageJson === null || packageJson === void 0 ? void 0 : packageJson.repository) === null || _f === void 0 ? void 0 : _f.directory) { | ||
const root = path_1.join(projectPath, '../'); | ||
@@ -70,7 +73,13 @@ const packages = yield fs.list('*/', root, { realpath: false }); | ||
// add support for typescript path aliases | ||
if ((_b = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths) { | ||
if ((_g = tsconfig === null || tsconfig === void 0 ? void 0 : tsconfig.compilerOptions) === null || _g === void 0 ? void 0 : _g.paths) { | ||
const paths = tsconfig.compilerOptions.paths; | ||
const root = path_1.join(projectPath, tsconfig.compilerOptions.rootDir || '.'); | ||
const root = path_1.join(projectPath, tsconfig.compilerOptions.baseUrl || '.'); | ||
aliases = Object.assign(aliases, normalizeAliases(root, paths)); | ||
} | ||
// add support for jsconfig path aliases | ||
if ((_h = jsconfig === null || jsconfig === void 0 ? void 0 : jsconfig.compilerOptions) === null || _h === void 0 ? void 0 : _h.paths) { | ||
const paths = jsconfig.compilerOptions.paths; | ||
const root = path_1.join(projectPath, jsconfig.compilerOptions.baseUrl || '.'); | ||
aliases = Object.assign(aliases, normalizeAliases(root, paths)); | ||
} | ||
// add support for additional path aliases (in typescript compiler path | ||
@@ -77,0 +86,0 @@ // like setup) |
{ | ||
"name": "unimported", | ||
"version": "1.12.1", | ||
"version": "1.13.0", | ||
"description": "Scans your nodejs project folder and shows obsolete files and modules", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68312
1133