Skip to content

Commit 322cb29

Browse files
committed
feat!: bump globby, use synckit for sync fn
1 parent 1e1b5a6 commit 322cb29

13 files changed

+3135
-3181
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
lib
22
CHANGELOG.md
3+
!/.*.cjs

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"root": true,
23
"extends": [
34
"plugin:prettier/recommended",
45
"plugin:mdx/recommended"

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
- push
5+
- pull_request
46

57
jobs:
68
default:
79
strategy:
810
matrix:
911
node:
10-
- 12
1112
- 14
1213
- 16
13-
os: [macOS-latest]
14+
- 18
15+
os:
16+
- macOS-latest
17+
- windows-latest
18+
- ubuntu-latest
1419
runs-on: ${{ matrix.os }}
1520
steps:
16-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
1722

18-
- uses: actions/setup-node@v2
23+
- uses: actions/setup-node@v3
1924
with:
2025
node-version: ${{ matrix.node }}
2126
cache: yarn

.lintstagedrc.js .lintstagedrc.cjs

File renamed without changes.

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/*
File renamed without changes.

package.json

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
{
22
"name": "eslint-import-resolver-typescript",
33
"version": "2.7.1",
4+
"type": "module",
45
"description": "TypeScript .ts .tsx module resolver for `eslint-plugin-import`.",
56
"repository": "https://github.com/alexgorbatchev/eslint-import-resolver-typescript",
67
"author": "Alex Gorbatchev <alex.gorbatchev@gmail.com>",
78
"contributors": [
89
"JounQin <admin@1stg.me>"
910
],
1011
"license": "ISC",
12+
"packageManager": "yarn@1.22.19",
1113
"engines": {
12-
"node": ">=6"
14+
"node": "^12.20 || ^14.18.0 || >=16.0.0"
1315
},
1416
"main": "lib/index.cjs",
15-
"module": "lib/index.es2015.mjs",
17+
"module": "lib/index.js",
1618
"exports": {
1719
".": {
1820
"require": "./lib/index.cjs",
19-
"import": "./lib/index.es2015.mjs",
21+
"import": "./lib/index.js",
2022
"types": "./lib/index.d.ts"
2123
},
2224
"./package.json": "./package.json"
@@ -25,7 +27,7 @@
2527
"types": "lib/index.d.ts",
2628
"files": [
2729
"lib",
28-
"!*.tsbuildinfo"
30+
"!**/*.tsbuildinfo"
2931
],
3032
"keywords": [
3133
"typescript",
@@ -60,39 +62,39 @@
6062
},
6163
"dependencies": {
6264
"debug": "^4.3.4",
63-
"globby": "^11.1.0",
65+
"globby": "^13.1.2",
6466
"is-glob": "^4.0.3",
65-
"resolve": "^1.22.0",
67+
"resolve": "^1.22.1",
68+
"synckit": "^0.7.1",
6669
"tsconfig-paths": "^4.0.0"
6770
},
6871
"devDependencies": {
69-
"@1stg/lib-config": "^5.4.0",
72+
"@1stg/lib-config": "^6.2.3",
7073
"@types/debug": "^4.1.7",
7174
"@types/glob": "^7.2.0",
7275
"@types/is-glob": "^4.0.2",
73-
"@types/node": "^17.0.23",
74-
"@types/resolve": "^1.20.1",
76+
"@types/node": "^18.0.0",
77+
"@types/resolve": "^1.20.2",
7578
"@types/unist": "^2.0.6",
7679
"dummy.js": "link:dummy.js",
7780
"eslint-import-resolver-typescript": "link:.",
78-
"react": "^18.0.0",
79-
"standard-version": "^9.3.2",
81+
"react": "^18.2.0",
82+
"standard-version": "^9.5.0",
8083
"type-coverage": "^2.21.1",
81-
"typescript": "^4.6.3"
84+
"typescript": "^4.7.4"
8285
},
8386
"resolutions": {
8487
"eslint-import-resolver-typescript": "link:.",
85-
"prettier": "^2.6.2"
88+
"prettier": "^2.7.1"
8689
},
90+
"fes2015": "lib/index.es2015.mjs",
8791
"typeCoverage": {
88-
"atLeast": 99.28,
92+
"atLeast": 100,
8993
"cache": true,
9094
"detail": true,
9195
"ignoreAsAssertion": true,
96+
"ignoreNonNullAssertion": true,
9297
"ignoreCatch": true,
93-
"ignoreFiles": [
94-
"**/*.d.ts"
95-
],
9698
"strict": true,
9799
"update": true
98100
}

src/index.ts

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import path from 'path'
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
23

34
import debug from 'debug'
4-
import { sync as globSync } from 'globby'
55
import isGlob from 'is-glob'
6-
import { isCore, sync, SyncOpts } from 'resolve'
6+
import * as _resolve from 'resolve'
7+
import { createSyncFn } from 'synckit'
78
import {
89
ConfigLoaderSuccessResult,
910
createMatchPath,
@@ -16,6 +17,15 @@ const IMPORTER_NAME = 'eslint-import-resolver-typescript'
1617

1718
const log = debug(IMPORTER_NAME)
1819

20+
const _dirname =
21+
typeof __dirname === 'undefined'
22+
? path.dirname(fileURLToPath(import.meta.url))
23+
: __dirname
24+
25+
const globSync = createSyncFn<typeof import('globby').globby>(
26+
path.resolve(_dirname, 'worker.mjs'),
27+
)
28+
1929
/**
2030
* .mts, .cts, .d.mts, .d.cts, .mjs, .cjs are not included because .cjs and .mjs must be used explicitly.
2131
*/
@@ -31,7 +41,7 @@ const defaultExtensions = [
3141

3242
export const interfaceVersion = 2
3343

34-
export type TsResolverOptions = SyncOpts & {
44+
export type TsResolverOptions = _resolve.SyncOpts & {
3545
alwaysTryTypes?: boolean
3646
/**
3747
* @deprecated use `project` instead
@@ -62,7 +72,7 @@ export function resolve(
6272
source = removeQuerystring(source)
6373

6474
// don't worry about core node modules
65-
if (isCore(source)) {
75+
if (_resolve.isCore(source)) {
6676
log('matched core:', source)
6777

6878
return {
@@ -126,7 +136,7 @@ export function resolve(
126136
}
127137
}
128138

129-
function packageFilterDefault(pkg: Record<string, string>) {
139+
function packageFilterDefault(pkg: _resolve.PackageJSON) {
130140
pkg.main =
131141
pkg.types || pkg.typings || pkg.module || pkg['jsnext:main'] || pkg.main
132142
return pkg
@@ -162,13 +172,13 @@ function resolveExtension(id: string) {
162172
* Like `sync` from `resolve` package, but considers that the module id
163173
* could have a .js or .jsx extension.
164174
*/
165-
function tsResolve(id: string, opts: SyncOpts): string {
175+
function tsResolve(id: string, opts: _resolve.SyncOpts): string {
166176
try {
167-
return sync(id, opts)
177+
return _resolve.sync(id, opts)
168178
} catch (error) {
169179
const resolved = resolveExtension(id)
170180
if (resolved) {
171-
return sync(resolved.path, {
181+
return _resolve.sync(resolved.path, {
172182
...opts,
173183
extensions: resolved.extensions ?? opts.extensions,
174184
})

src/worker.mts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { Options } from 'globby'
2+
import { runAsWorker } from 'synckit'
3+
4+
runAsWorker(
5+
async (
6+
patterns: string | readonly string[],
7+
options: Options & { objectMode: true },
8+
) => {
9+
const { globby } = await import('globby')
10+
return globby(patterns, options)
11+
},
12+
)

tests/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "commonjs",
3+
"private": true
4+
}

tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"extends": "./node_modules/@1stg/tsconfig/lib.json",
2+
"extends": "@1stg/tsconfig/node16",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"declarationMap": false,
65
"outDir": "lib"
76
},
87
"include": ["src"]

0 commit comments

Comments
 (0)