Skip to content

Commit

Permalink
fix(js): handle standalone projects for buildable js libraries (#14615)
Browse files Browse the repository at this point in the history
(cherry picked from commit 4bbd60b)
  • Loading branch information
jaysoo authored and FrozenPandaz committed Jan 27, 2023
1 parent fb49c7f commit 1268789
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions packages/js/src/utils/inline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ExecutorContext, ProjectGraphProjectNode } from '@nrwl/devkit';
import { readJsonFile, normalizePath } from '@nrwl/devkit';
import { normalizePath, readJsonFile } from '@nrwl/devkit';
import {
copySync,
readdirSync,
Expand All @@ -9,6 +9,7 @@ import {
} from 'fs-extra';
import { join, relative } from 'path';
import type { NormalizedExecutorOptions } from './schema';
import { existsSync } from 'fs';

interface InlineProjectNode {
name: string;
Expand Down Expand Up @@ -91,8 +92,22 @@ export function postProcessInlinedDependencies(
}

function readBasePathAliases(context: ExecutorContext) {
const tsConfigPath = join(context.root, 'tsconfig.base.json');
return readJsonFile(tsConfigPath)?.['compilerOptions']['paths'] || {};
return readJsonFile(getRootTsConfigPath(context))?.['compilerOptions'][
'paths'
];
}

export function getRootTsConfigPath(context: ExecutorContext): string | null {
for (const tsConfigName of ['tsconfig.base.json', 'tsconfig.json']) {
const tsConfigPath = join(context.root, tsConfigName);
if (existsSync(tsConfigPath)) {
return tsConfigPath;
}
}

throw new Error(
'Could not find a root tsconfig.json or tsconfig.base.json file.'
);
}

function emptyInlineGraph(): InlineProjectGraph {
Expand Down

0 comments on commit 1268789

Please sign in to comment.