Skip to content

Commit 14a7688

Browse files
authored
chore: bump rspack-resolver for better P'n'P support (#397)
1 parent 0adca68 commit 14a7688

22 files changed

+10675
-179
lines changed

.changeset/gorgeous-wasps-happen.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"eslint-import-resolver-typescript": patch
3+
---
4+
5+
chore: bump `rspack-resolver` for better P'n'P support
6+
7+
Now `rspack-resolver` resolves `pnpapi` natively.

.github/workflows/codeql.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
with:
4141
languages: ${{ matrix.language }}
4242
queries: +security-and-quality
43+
config: |
44+
paths-ignore:
45+
- tests/pnp/.pnp.*
4346
4447
- name: Autobuild
4548
uses: github/codeql-action/autobuild@v3

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.yarn/*
44
!.yarn/plugins
55
!.yarn/releases
6+
coverage
67
lib
78
node_modules
89
*.log

.prettierignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
.yarn
2-
dist
3-
lib
4-
node_modules
52
/pnpm-lock.yaml
3+
/tests/pnp/.pnp.*
64
**/*.svg

package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"eslint": "ESLINT_USE_FLAT_CONFIG=false eslint",
4444
"lint": "run-p 'lint:*'",
4545
"lint:es": "eslint . --cache",
46-
"lint:tsc": "tsc --noEmit",
46+
"lint:tsc": "tsc -b --noEmit",
4747
"prepare": "simple-git-hooks && yarn-berry-deduplicate || exit 0",
4848
"release": "clean-pkg-json && changeset publish",
4949
"test": "run-p 'test:*'",
@@ -54,6 +54,7 @@
5454
"test:multipleEslintrcs": "yarn eslint --ext ts,tsx tests/multipleEslintrcs",
5555
"test:multipleTsconfigs": "yarn eslint --ext ts,tsx tests/multipleTsconfigs",
5656
"test:nearestTsconfig": "yarn eslint --ext ts,tsx tests/nearestTsconfig",
57+
"test:unit": "vitest --run",
5758
"test:withJsExtension": "node tests/withJsExtension/test.js && yarn eslint --ext ts,tsx tests/withJsExtension",
5859
"test:withJsconfig": "yarn eslint --ext js tests/withJsconfig",
5960
"test:withPaths": "yarn eslint --ext ts,tsx tests/withPaths",
@@ -82,7 +83,7 @@
8283
"dependencies": {
8384
"debug": "^4.4.0",
8485
"get-tsconfig": "^4.10.0",
85-
"rspack-resolver": "^1.2.0",
86+
"rspack-resolver": "^1.2.2",
8687
"stable-hash": "^0.0.5",
8788
"tinyglobby": "^0.2.12"
8889
},
@@ -98,21 +99,25 @@
9899
"@types/node": "^22.13.10",
99100
"@types/pnpapi": "^0.0.5",
100101
"@types/unist": "^3.0.3",
102+
"@vitest/coverage-v8": "3.0.9",
101103
"clean-pkg-json": "^1.2.1",
102104
"dummy.js": "link:dummy.js",
103105
"eslint": "^9.22.0",
104106
"eslint-import-resolver-typescript": "link:.",
105-
"eslint-plugin-import-x": "^4.8.0",
107+
"eslint-plugin-import-x": "^4.9.0",
106108
"is-bun-module": "^1.3.0",
107109
"lint-staged": "^15.5.0",
108110
"npm-run-all2": "^7.0.2",
111+
"path-serializer": "^0.3.4",
109112
"prettier": "^3.5.3",
110113
"react": "^19.0.0",
111114
"simple-git-hooks": "^2.11.1",
112115
"size-limit": "^11.2.0",
113116
"size-limit-preset-node-lib": "^0.3.0",
117+
"tinyexec": "^1.0.0",
114118
"type-coverage": "^2.29.7",
115119
"typescript": "~5.8.2",
120+
"vitest": "^3.0.9",
116121
"yarn-berry-deduplicate": "^6.1.1"
117122
},
118123
"resolutions": {

src/index.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import module from 'node:module'
1+
import { isBuiltin } from 'node:module'
22
import path from 'node:path'
33

44
import type { ResolvedResult } from 'eslint-plugin-import-x/types.js'
@@ -63,20 +63,11 @@ export const resolve = (
6363
options ||= {}
6464

6565
// don't worry about node/bun core modules
66-
if (module.isBuiltin(source) || (options.bun && isBunBuiltin(source))) {
66+
if (isBuiltin(source) || (options.bun && isBunBuiltin(source))) {
6767
log('matched core:', source)
6868
return { found: true, path: null }
6969
}
7070

71-
if (process.versions.pnp && source === 'pnpapi') {
72-
return {
73-
found: true,
74-
path: module
75-
.findPnpApi(file)
76-
.resolveToUnqualified(source, file, { considerBuiltins: false }),
77-
}
78-
}
79-
8071
source = removeQuerystring(source)
8172

8273
if (!resolver) {

tests/pnp/.editorconfig

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root=true
2+
3+
[*]
4+
charset=utf-8
5+
end_of_line=lf
6+
indent_size=2
7+
indent_style=space
8+
insert_final_newline=true

tests/pnp/.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.yarn/** linguist-vendored
2+
/.yarn/releases/* binary
3+
/.yarn/plugins/**/* binary
4+
/.pnp.* binary linguist-generated

tests/pnp/.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.yarn/*
2+
!.yarn/patches
3+
!.yarn/plugins
4+
!.yarn/releases
5+
!.yarn/sdks
6+
!.yarn/versions
7+
8+
# Whether you use PnP or not, the node_modules folder is often used to store
9+
# build artifacts that should be gitignored
10+
node_modules
11+
12+
# Swap the comments on the following lines if you wish to use zero-installs
13+
# In that case, don't forget to run `yarn config set enableGlobalCache false`!
14+
# Documentation here: https://yarnpkg.com/features/caching#zero-installs
15+
16+
!.yarn/cache

0 commit comments

Comments
 (0)