Skip to content

Commit

Permalink
fix: resolve relative path extends in parent directory (#77)
Browse files Browse the repository at this point in the history
Co-authored-by: Hiroki Osame <[email protected]>
  • Loading branch information
nwalters512 and privatenumber committed May 9, 2024
1 parent 9d4437b commit 0a3270e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse-tsconfig/resolve-extends-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const resolveExtendsPath = (
}

const packagePath = findUp(
directoryPath,
path.resolve(directoryPath),
path.join('node_modules', packageName),
cache,
);
Expand Down
38 changes: 38 additions & 0 deletions tests/specs/parse-tsconfig/extends/resolves/node-modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,44 @@ export default testSuite(({ describe }) => {
expect(tsconfig).toStrictEqual(expectedTsconfig);
});

// https://github.com/privatenumber/get-tsconfig/issues/76
test('resolves config in parent node_modules', async () => {
await using fixture = await createFixture({
library: {
src: {
'a.ts': '',
'b.ts': '',
'c.ts': '',
},
'tsconfig.json': createTsconfigJson({
extends: '@monorepo/tsconfig/tsconfig.base.json',
include: ['src'],
}),
},

'node_modules/@monorepo/tsconfig': {
'tsconfig.base.json': createTsconfigJson({
compilerOptions: {
module: 'commonjs',
},
}),
},
});

const originalCwd = process.cwd();
try {
process.chdir(fixture.getPath('library'));
const expectedTsconfig = await getTscTsconfig('.');
delete expectedTsconfig.files;

const tsconfig = parseTsconfig('./tsconfig.json');

expect(tsconfig).toStrictEqual(expectedTsconfig);
} finally {
process.chdir(originalCwd);
}
});

describe('package.json#tsconfig', ({ test }) => {
test('package.json#tsconfig', async () => {
await using fixture = await createFixture({
Expand Down

0 comments on commit 0a3270e

Please sign in to comment.