Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve relative path extends in parent directory #77

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -64,7 +64,7 @@
const PACKAGE_JSON = 'package.json';
const TS_CONFIG_JSON = 'tsconfig.json';

export const resolveExtendsPath = (

Check warning on line 67 in src/parse-tsconfig/resolve-extends-path.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Arrow function has a complexity of 33. Maximum allowed is 10
requestedPath: string,
directoryPath: string,
cache?: Cache<string>,
Expand Down Expand Up @@ -144,7 +144,7 @@
}

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
Loading