Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit afb1b74

Browse files
fix(ts): dependency to not resolve using tsconfig paths (#13)
1 parent 3991a1a commit afb1b74

File tree

21 files changed

+58
-12
lines changed

21 files changed

+58
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@esbuild-kit/core-utils": "^2.0.0",
36-
"get-tsconfig": "^4.0.0"
36+
"get-tsconfig": "^4.0.5"
3737
},
3838
"devDependencies": {
3939
"@pvtnbr/eslint-config": "^0.22.0",

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import path from 'path';
12
import fs from 'fs';
23
import Module from 'module';
34
import {
@@ -11,6 +12,7 @@ import { getTsconfig, createPathsMatcher } from 'get-tsconfig';
1112

1213
const isPathPattern = /^\.{0,2}\//;
1314
const isTsFilePatten = /\.[cm]?tsx?$/;
15+
const nodeModulesPath = `${path.sep}node_modules${path.sep}`;
1416

1517
const tsconfig = getTsconfig();
1618
const tsconfigRaw = tsconfig?.config;
@@ -112,8 +114,12 @@ Module._resolveFilename = function (request, parent, isMain, options) {
112114

113115
if (
114116
tsconfigPathsMatcher
117+
115118
// bare specifier
116119
&& !isPathPattern.test(request)
120+
121+
// Dependency paths should not be resolved using tsconfig.json
122+
&& !parent?.filename.includes(nodeModulesPath)
117123
) {
118124
const possiblePaths = tsconfigPathsMatcher(request);
119125
for (const possiblePath of possiblePaths) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('resolve-current-directory');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('should-not-resolve-baseUrl');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('should-not-resolve-paths');

tests/fixtures/tsconfig/node_modules/resolve-current-directory/lib/file.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fixtures/tsconfig/node_modules/resolve-current-directory/lib/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fixtures/tsconfig/node_modules/resolve-current-directory/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/fixtures/tsconfig/node_modules/should-not-resolve-baseUrl/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)