Skip to content

Commit 3617e79

Browse files
committed
chore: remove unnecessary codes
1 parent 02a2649 commit 3617e79

File tree

6 files changed

+17
-41
lines changed

6 files changed

+17
-41
lines changed

.size-limit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
33
"path": "./lib/index.js",
4-
"limit": "1.4kB"
4+
"limit": "1.5kB"
55
}
66
]

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"types": "lib/index.d.ts",
2828
"files": [
2929
"lib",
30-
"shim.d.ts",
3130
"!**/*.tsbuildinfo"
3231
],
3332
"keywords": [
@@ -41,7 +40,7 @@
4140
"build": "run-p -c 'build:*'",
4241
"build:r": "r -f cjs,es2020",
4342
"build:ts": "tsc -b",
44-
"eslint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint --cache",
43+
"eslint": "ESLINT_USE_FLAT_CONFIG=false eslint --cache",
4544
"lint": "run-p 'lint:*'",
4645
"lint:es": "eslint . --cache",
4746
"lint:tsc": "tsc --noEmit",
@@ -97,7 +96,6 @@
9796
"@types/pnpapi": "^0.0.5",
9897
"@types/unist": "^3.0.3",
9998
"clean-pkg-json": "^1.2.1",
100-
"cross-env": "^7.0.3",
10199
"dummy.js": "link:dummy.js",
102100
"eslint": "^9.22.0",
103101
"eslint-import-resolver-typescript": "link:.",

src/helpers.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ export function mangleScopedPackage(moduleName: string) {
1414
return moduleName
1515
}
1616

17-
/** Remove any trailing querystring from module id. */
18-
export function removeQuerystring(id: string) {
19-
const querystringIndex = id.lastIndexOf('?')
20-
if (querystringIndex !== -1) {
21-
return id.slice(0, querystringIndex)
22-
}
23-
return id
24-
}
25-
2617
export const tryFile = (
2718
filename?: string[] | string,
2819
includeDir = false,

src/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isBuiltin } from 'node:module'
1+
import module from 'node:module'
22
import path from 'node:path'
33

44
import type { ResolvedResult } from 'eslint-plugin-import-x/types.js'
@@ -10,14 +10,10 @@ import {
1010
} from 'get-tsconfig'
1111
import { type Version, isBunModule } from 'is-bun-module'
1212
import { ResolverFactory } from 'rspack-resolver'
13-
import stableHash_ from 'stable-hash'
13+
import { stableHash } from 'stable-hash'
1414

1515
import { IMPORT_RESOLVER_NAME, JS_EXT_PATTERN } from './constants.js'
16-
import {
17-
mangleScopedPackage,
18-
removeQuerystring,
19-
sortProjectsByAffinity,
20-
} from './helpers.js'
16+
import { mangleScopedPackage, sortProjectsByAffinity } from './helpers.js'
2117
import { log } from './logger.js'
2218
import { normalizeOptions } from './normalize-options.js'
2319
import type { TypeScriptResolverOptions } from './types.js'
@@ -27,9 +23,6 @@ export * from './helpers.js'
2723
export * from './normalize-options.js'
2824
export type * from './types.js'
2925

30-
// CJS <-> ESM interop
31-
const stableHash = 'default' in stableHash_ ? stableHash_.default : stableHash_
32-
3326
const resolverCache = new Map<string, ResolverFactory>()
3427

3528
const tsconfigCache = new Map<string, TsConfigJsonResolved>()
@@ -65,7 +58,7 @@ export const resolve = (
6558
): ResolvedResult => {
6659
// don't worry about core node/bun modules
6760
if (
68-
isBuiltin(source) ||
61+
module.isBuiltin(source) ||
6962
(process.versions.bun &&
7063
isBunModule(source, process.versions.bun as Version))
7164
) {
@@ -77,6 +70,15 @@ export const resolve = (
7770
}
7871
}
7972

73+
if (process.versions.pnp && source === 'pnpapi') {
74+
return {
75+
found: true,
76+
path: module.findPnpApi(file).resolveToUnqualified(source, file, {
77+
considerBuiltins: false,
78+
}),
79+
}
80+
}
81+
8082
options ||= {}
8183

8284
if (!resolver) {
@@ -91,8 +93,6 @@ export const resolve = (
9193
resolver = cached
9294
}
9395

94-
source = removeQuerystring(source)
95-
9696
options ||= {}
9797

9898
// eslint-disable-next-line sonarjs/label-position, sonarjs/no-labels

src/normalize-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TsconfigOptions } from 'oxc-resolver'
1+
import type { TsconfigOptions } from 'rspack-resolver'
22
import { globSync, isDynamicPattern } from 'tinyglobby'
33

44
import {

yarn.lock

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5886,19 +5886,7 @@ __metadata:
58865886
languageName: node
58875887
linkType: hard
58885888

5889-
"cross-env@npm:^7.0.3":
5890-
version: 7.0.3
5891-
resolution: "cross-env@npm:7.0.3"
5892-
dependencies:
5893-
cross-spawn: "npm:^7.0.1"
5894-
bin:
5895-
cross-env: src/bin/cross-env.js
5896-
cross-env-shell: src/bin/cross-env-shell.js
5897-
checksum: 10/e99911f0d31c20e990fd92d6fd001f4b01668a303221227cc5cb42ed155f086351b1b3bd2699b200e527ab13011b032801f8ce638e6f09f854bdf744095e604c
5898-
languageName: node
5899-
linkType: hard
5900-
5901-
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.1, cross-spawn@npm:^7.0.3, cross-spawn@npm:^7.0.5, cross-spawn@npm:^7.0.6":
5889+
"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.3, cross-spawn@npm:^7.0.5, cross-spawn@npm:^7.0.6":
59025890
version: 7.0.6
59035891
resolution: "cross-spawn@npm:7.0.6"
59045892
dependencies:
@@ -6703,7 +6691,6 @@ __metadata:
67036691
"@types/pnpapi": "npm:^0.0.5"
67046692
"@types/unist": "npm:^3.0.3"
67056693
clean-pkg-json: "npm:^1.2.1"
6706-
cross-env: "npm:^7.0.3"
67076694
debug: "npm:^4.4.0"
67086695
dummy.js: "link:dummy.js"
67096696
eslint: "npm:^9.22.0"

0 commit comments

Comments
 (0)